I can't figure out this program (Pascal Programming Language)?
831941
You're supposed to print a table, right? The question is poorly written, so it's not clear, but I'll assume that's the goal.\n\nWell, it sounds like you can write your loop, so shouldn't you just print out the sine, cosine, and tangent of the angle in the body of the loop?  It's not clear what the stumbling block is.  You realize that there are built in functions that compute sine, cosine, etc.?
83035
#define __TEST__\n\n#include <stdio.h>\n\n#ifdef __TEST__\n#include <conio.h>\n#include <stdlib.h>\n#endif\n#define STACKSIZE 64\n\n\nint stack[STACKSIZE];\nstatic int stack_ptr=0;\n\nvoid overflow_test( int pos )\n{\nif( pos >= STACKSIZE )\n{\nputs( "Stack overflow!&#92;n" );\nexit(1);\n}\n}\n\nvoid underflow_test( int pos )\n{\nif( pos < 0 )\n{\nputs( "Stack underflow!&#92;n" );\nexit(1);\n}\n}\n\nvoid push( int value )\n{\noverflow_test( stack_ptr+1 );\nstack[stack_ptr++] = value;\n}\n\nint pop( void )\n{\nunderflow_test( --stack_ptr );\nreturn stack[stack_ptr];\n}\n\n#ifdef __TEST__\n\nvoid wait4keypress( void )\n{\nwhile( !kbhit())\n;\n}\n\nint main( void )\n{\natexit(wait4keypress); \npush(1);\npush(2);\npush(3);\nprintf( "%d&#92;n", pop());\nprintf( "%d&#92;n", pop());\nprintf( "%d&#92;n", pop());\n/* must cause stack underflow */\nprintf( "%d&#92;n", pop());\nreturn 0;\n}\n\n#endif  /* __TEST__ */
457195
the simple program given above if fine.. in terms of the conncept.. but there's a bug... \nthe problem is with looping.. coz when u enter a number such as 80301  or 55302 ( a no. having 0 in between), the loop breaks at the point when zero is encountered.\n\n so the output in the first eg. is  8 0 ,sum= 8 (instead of correct 8 0 3 0 1 , sum=12\n\n\nso the logic of handling the number is absolutely correct but the looping is a comparatively difficult job in this case!
869459
void main()\n{\nint n,rev=0,ro,n1;\ncout<<"enter the number";\ncin>>n;\nn1=n;\nwhile(n>0)\n{\nro=n%10;\nrev=rev*10+ro\nn=n/10;\n}\nif ( rev== n1)\n cout<<"the number is palindrom";\nelse\ncout<<"the number is not palindrom";\n}
253055
Off the top of my head, don't hate me if there are errors...\n\nclass MyVar\n{\npublic:\n  int a;\n  MyVar ( MyVar& src )\n  { a = src.a; }\n}\n\n...\nMyVar p;\np.a = 5;\nMyVar q(p);\n// q.a==5 is true
1162110
http://www.qbasicnews.com/sections.php?id=4\n\nThis link provides the actual QBasic program ... the post below this one has a link to a qbasic compiler called firstbasic, not the qbasic program. The link from the poster below is dead anyway so here is the direct one for the program ... just unzip it and execute it and you are set. Happy programming\nhttp://qbasicnews.com/files/qb11.zip
150391
It is a strings proccessing alg which uses a failure function to improve the run time rather than bm alg\nrun time:m+n\nm:the length of the pattern\nn: the length of the text\nwe use tis algorithm to find the pat string in the text string..\nmore details \nmail me at ziko@math.com\ni can provid a pascal source for it
41764
you can find a very good tutorial at the link.\n\nNo need to write whats already writtenm =)
400012
a programmer wont waste his/her time here!\nso there is no one to answer you ;)
657146
Time for Pascal's Triangle.\n.......1\n......1 1\n.....1 2 1\n....1 3 3 1\n...1 4 6 4 1\n..1 5 10 10 5 1\n1 6 15 20 15 6 1\n\n1 chance in 64 of 6 Heads and 0 Tails\n6 chances in 64 of 5 Heads and 1 Tail\n15 chances in 64 of 4 Heads and 2 Tails\n20 chances in 64 of 3 Heads and 3 Tails\n15 chances in 64 of 2 Heads and 4 Tails\n6 chances in 64 of 1 Heads and 5 Tails\n1 chance in 64 of 0 Heads and 6 Tails\n\nChance of exactly 3 tails: 20 in 64\nChance of 3 or more tails: 42 in 64\nChance of more than 3 tails (4 or more) : 22 in 64\n\nAnyone who think the chance of 3 tails in 6 tosses is 50% is generalising wildly.\n\nThe chance of 1 tail in 1 toss is 50%\nThe chance of 1 head & 1 tail in 2 tosses is 2 chances in 4\nThe chance of 2 heads & 2 tails in 4 tosses is 6 chances in 16. (37.5%)\nThe chance of 3 heads & 3 tails in 6 tosses is 20 chances in 64. (31.25%)\nThe chance of 4 heads & 4 tails in 8 tosses is 70 chances in 256. (27.34%)\nThe chance of 5 heads & 5 tails in 10 tosses is 252 chances in 1024. (24.61%)\n\n(read the middle number in each row of Pascal's Triangle, and extend it downwards)\nThe bigger the number of tosses, the probability of tossing exactly half of the tosses as tails keeps on falling. This should not surprise us. There are so many more possible outcomes.
781094
Nobody is going to do your homework for you. \n\nIf you're supposed to write code examples that illustrate how two comparable programs might look, then do this. Write some simple programs in C, and then re-write the same program in C++ but put the functions your void main calls in a class and instantiate the class.
423398
here...I'll tell you what to write and you write it...\n\n/* outline the program */\n\n// void main()...etc..\n\n/* define your variables */\n/* you'll need a pair of char pointers */\n/* and some numbers to hold converted values */\n\n\n/* input the first binary as a string */\n\n/* input the second binary as a string */\n\n/* convert them to decimal */\n\n/* add them */\n\n/* fprintf them */\n\n/* end program */\n\n\nthat's all.\nI write all my programs in commented logic first then fill in the blanks so that it does what I meant.  When I'm done, the program follows the flow and is already commented for the next person to follow.
943372
u have to ponit it or use\n\nthese are the 2 way's:\n\n#include <iostream>\nusing namespcae std;\nint main()\n{\nint num[8];\nint index;\n\nnum[0] = 42;\nnum[1] = 2001;\nnum[2] = 7;\nnum[3] = 180;\nnum[4] = 99;\nnum[5] = 1993;\n\nfor(index = 0; index <= 5; index++)\n{\nstd::cout<< index[num] << endl;\n}\n system("pause");\nreturn 0;\n}\n\nor\n\n#include <iostream>\n#define MAX 20\nusing namespcae std;\n\nint main()\n{\n\nint a[MAX] = {23,43,4,5,34,343,12,14};\nint b;\n\ncout.setf(ios::right);\n\nfor(b = 0; b < MAX; b++){\n\ncout << endl << endl;\n\ncout << "The Elemnt in ";\n\ncout.width(2);\n\ncout << (b +1) << " is ";\n\ncout.width(2);\n\nstd::cout << b[a];\n}\nreturn 0;\n}
740336
1. 101\n2.  There are 2 ones.  The first and last entries of the row.\n3.  Each entry is the sum of the 2 entries above and to     each side of it.\n4.  If the 2'nd entry in a row is a prime, it divides each of the other entries in the row (except for the last entry in the row which is always a 1)\n\nCheck out http://ptri1.tripod.com/ for all manner of kewl sh|t about Pascal's Triangle.  Also Fibonacci Series and other fun things ☺\n\n\nDoug\n\nEDIT:  Give Peter D the points.  He needs 'em worse than I do ☺
747804
There are multiple units usable.  Try pascals, psi, torr, atm
758683
Hm.  There are lots of good sites on the web about Pascal's triangle and the Binomial expansion.\n\nTo understand how to get the coefficients, consider as an example trying to compute:\n\n(x + y)³\n= (x + y)(x + y)(x + y)\n= (xx + xy + yx + yy)(x + y)\n= xxx + xyx + yxx + yyx + xxy + xyy + yxy + yyy\n= xxx + (xyx + yxx + xxy) + (yyx + xyy + yxy) + yyy\n\nI deliberately didn't simplify to make it clear what is happening.\n\nNotice that all the terms in parentheses are the same (x²y and xy²), and will ultimately add together....\n\n....but also notice that you can think of these four groupings as:\n\n-- The number of ways to form a string of length 3 where each character is an x.\n-- The number of ways to form a string of length 3 where two characters are x and the other one is a y.\n-- The number of ways to form a string of length three where two characters are y and the other one is an x.\n-- The number of ways to form a string of length 3 where each character is a y.\n\nBut, when you group them to add them, order no longer makes a difference: xxy = xyx = yxx = x²y, and yyx = yxy = xyy = xy².\n\nSo to compute a particular value in the triangle in the nth row and in the mth column, what you are really trying to do is to calculate "how many strings of length n can I create using (n - m + 1) x's and (m - 1) y's"?  (the extra +1 and -1 are there so you don't have to call the first column the "0th column".)\n\nFor example, take the 4th row, 2nd column.  This would be the coefficient of x³y in the binomial expansion of (x+y)^4.\n\nThe equivalent question is:\n\n"How many strings of length 4 can you create using (4 - 2 + 1) = 3 x's and (2 -1) = 1 y?"\n\nYou could write them all out: xxxy xxyx xyxx yxxx.\n\nOr you can say, I have 4 places for the first x, 3 places for the second x, 2 places for the third x, and only one left for the y, for a total of 4! = 24 arrangements.  But since the x's can't be distinguished from each other, you have to divide by the factorial of the number of x's. 4! / 3! = 4.\n\nHopefully this is familiar to you: it's a combination.\n\nSo, in general, to compute the value in the mth column and nth row of the triangle, the formula is:\n\nC(n, m-1) = n! / [(m - 1)! (n - m + 1)!]\n\nOr if you're ok with calling the calling the first column "column zero", then it's simpler:\n\nC(n, m) = n! / [m! ( n - m)!]\n\nHope that gives you an idea.  :)
397803
/*\n\ni need to know an example of writting a program in c\nlanguage under linux using threads?\n\nwrite aprogram to calculate the result of the equation\nY=3sin(x)+6cos(x)+5x2 so each term accomplished by a\nthread. The main thread will calculate the result.\n\n*/\n\n\n#include <pthread.h>\n#include <math.h>\n#include <stdlib.h>\n#include <stdio.h>\n\n/* static global location -- all threads will read */\nstatic double x;\n\nstatic void*\nthree_sinx(void*p)\n{\n  double* result = (double*)p;\n  *result = 3 * sin(x);\n  return 0;\n}\n\nstatic void*\nsix_cosx(void*p)\n{\n  double* result = (double*)p;\n  *result = 6 * cos(x);\n  return 0;\n}\n\nstatic void*\nfive_x_squared(void*p)\n{\n  double* result = (double*)p;\n  *result = 5 * x * x;\n  return 0;\n}\n\n/*\n *\n * Y = 3sin(x) + 6cos(x) + 5x2\n *\n */\n\nint\nmain(int argc, char* argv[])\n{\n  double result[3]; /* one location for each thread */\n  pthread_t tid[3];\n  void *r;\n  int i;\n\n  /* Set "x" to double value passed in on command line */\n  x = argc>1 ? strtod(argv[1], 0) : 0;\n\n\n  /*\n   *  Since result areas are distinct, no mutex needed\n   */\n  if (pthread_create(&tid[0], NULL,\n    three_sinx, &result[0]) != 0) {\n    perror("pthread_create[0]"), exit(-1);\n  }\n\n  if (pthread_create(&tid[1], NULL,\n    six_cosx, &result[1]) != 0) {\n    perror("pthread_create[1]"), exit(-1);\n  }\n\n  if (pthread_create(&tid[2], NULL,\n    five_x_squared, &result[2]) != 0) {\n    perror("pthread_create[2]"), exit(-1);\n  }\n\n  /* Synchronize on the completing child threads */\n  for (i=0; i<3; i++) {\n    if (pthread_join(tid[i], &r) != 0) {\n      perror("pthread_join");\n      exit(-1);\n    }\n  }\n\n  /* main thread will now combine the result */\n  printf("For y=3sin(x)+6cos(x)+5x2, when x=%f, y=%f&#92;n",\n      x, result[0]+result[1]+result[2]);\n\n  return 0;\n}\n\n\n\nTo show that it works:\n\n$ cc pthr.c -lpthread -lm\n\n$ a.out 3.14159\nFor y=3sin(x)+6cos(x)+5x2, when x=3.141590, y=43.347947\n\n$ a.out 0\nFor y=3sin(x)+6cos(x)+5x2, when x=0.000000, y=6.000000