What is the output of the following C program?
599299
c is a pointer to the 1st element in the array.\n\np and q are also pointers to the 1st element in the array.\n\nthe first loop prints *c which would be 2 (does this 5 times because it never changes the pointer c.\n\nthe second loop prints *p then increments p to the next element in the array (5 times)\n\nfull output would be:\n2222228344  (5 2s from the c pointer, 28344 from the p pointer)
654265
Generically, it is an array of pointers that can change in size.  So you have a number of pointers refering to some data locations in memory, and you add and subtract pointers from the list as the program goes.
404314
C compiler allocates memory for a structure variable by \naligning to a word boundary.\nstruct ex\n{\nchar a;\nchar b;\n};\n the structure has only 2 bytes. So the compiler pads with 2 more bytes as a word is 4 bytes\nYou can also make the compiler not to use the padding
409704
I may not have written many programs in Java, but that sure as hell doesn't look like Java to me.\n\nEdit: It's actually C as you can see from the includes:\n#include<stdio.h>\n#include<conio.h>\n#include<math.h>\n#include<stdlib.h>\n\nC++ doesn't use <something.h> it just uses plain <something>.
642129
ok, here is one declaration, of many;\n\nfloat Doc(int arr[100], int NumCt)\n{\nfloat sum = 0.0;\nfor (int i = 0; i < NumCt; i++)\nsum += arr[i];\n\nif (!NumCt)\nreturn sum;\n\nreturn sum / NumCt;\n}
686663
The asterix indicate which dimension of the array should be output.\n\nprintf allows you to format the output string. Your printf string basically says, "Print four decimal columns. First column, give me the first dimension of the array; second, give me the second dimension; etc."\n\nThe asterixes are pointers. Each asterix indicates which position of the array the statement should output.
368941
I can help you with this program in C (not C++).\n\n#include <stdio.h>\n\nint a;\n\nvoid main(void)\n{\n   for(a = 0; a <= 1000; a++)\n   {\n       printf("%d&#92;n", a);\n   }\n}\n\nThe above program lists numbers starting from 0 to 1000.\nYou can modify the program to add up all those numbers if that is what you want.\n\n#include <stdio.h>\n\nint a, sum = 0;\n\nvoid main(void)\n{\n   for(a = 0; a <= 1000; a++)\n   {\n      printf("%d&#92;n", a);\n      sum = sum + a;\n   }\n   printf("Sum = %d", sum);\n}\n\nThis program prints and also finds the sum to 1000 numbers starting from 0!
195373
Try this:\n\n#include <stdio.h>\n\nmain()\n{\nint size,array[50],n,m,border,max,buf,step;\nint i, j, temp;\n\nprintf("Input number of elements in array:");\nscanf("%d",&size);\n\nfor(n=0;n<size;n++) {\n  printf("input %d. element of array:",n+1);\n  scanf("%d",&array[n]);\n  }\n\n for (i=(size-1);i>=0; i--)\n  {\n   for(j=1;j<=i;j++)\n    {\n     if(array[j-1]>array[j])\n      {\n       temp=array[j-1];\n       array[j-1]=array[j];\n       array[j]=temp;\n      }\n     }\n   }\n\nfor(n=0;n<size;n++)\n   printf("%d. element: %d&#92;n",n+1,array[n]);\n\n}\n\n\n\nHERE IS MY OUTPUT:\n\nInput number of elements in array:8\ninput 1. element of array:6\ninput 2. element of array:2\ninput 3. element of array:3\ninput 4. element of array:5\ninput 5. element of array:1\ninput 6. element of array:4\ninput 7. element of array:5\ninput 8. element of array:7\n1. element: 1\n2. element: 2\n3. element: 3\n4. element: 4\n5. element: 5\n6. element: 5\n7. element: 6\n8. element: 7
121196
I understand you want to convert A,B,C... to {0,1}, right? then. In C, all strings are character arrays, otherwise collection of characters. by converting each character u can do. as u can see each character both printable and other have a numerical value. it is in a table, ASCII table. Here the code\n----------\nvoid binary(char ch)\n{  if(ch>0) binary(ch/2);\n   printf("%d",ch%2);\n}\nvoid toBinary(char*text)\n{  for(i=0;text[i]!='&#92;0';i++)\n   {  binary(test[i]);\n      printf("&#92;n");\n   }\n}\n----------\n\ni hope these two functions helps you.....\ngood luck.
997805
==================\n#include <iostream.h>\n\nint main(void)\n{\n\n   int count; // holds the count\n   float sum, number, avg;\n\n   sum = 0.0;\n   count = 0;\n\n   cout << endl << endl   //  Make some space\n        << endl << "Enter a number.  Enter a zero (0) when you have"\n        << endl << "finished entering numbers and want to compute the"\n        << endl << "average of the inputted numbers." ;\n\n   do {\n         cout << endl << endl << "Data element #" << count + 1\n              << ": ";\n\n         cin >> number;\n\n         if (number != 0.)\n           sum = sum + number;\n           count = count + 1;\n\n      } while (number != 0.0);\n\n      averg = sum / (count-1);\n      cout << endl << "The average is: " << avg\n           << endl << endl ;\n      return 0;\n}\n\n\n==================\n\nThis program computes the average of a set of data values. Commented a bit for you to understand\n\nEnjoy
624892
u didn't mentioned Language ...this is in C....\n\nint i, j, n;\nprintf("Enter no of lines");\nscanf ("%d",&n);\nfor (i=0;i<n;i++)\n{\n    for(j=0;j<=i;j++)\n    {\n        if(j==0||j==(i+1))\n          printf(" 1");\n        else\n          printf(" %d" ,i+2);\n     }\n     printf("&#92;n");\n}
816149
Its neither long nor difficult. Here is the program, which uses recursive function to calculate gcd.\n\n#include<stdio.h>\n#include<conio.h>\n\nint find_gcd(int n1,int n2);\nvoid main()\n{\n clrscr();\n int number1,number2;\n printf("Enter two numbers to get lcd and gcd ");\n scanf("%d %d",&number1,&number2);\n if((number1 <= 0) || (number2 <= 0))\n  {\n   printf("Invalid inputs");\n   return;\n  }\n if(number1 == number2) {printf("GCD is %d LCD is %d",number1,number2);getch();return;}\n if(number1 == 1) {printf("GCD is 1 LCD is %d",number2);getch();return;}\n if(number2 == 1) {printf("GCD is 1 LCD is %d",number1);getch();return;}\n int gcd = find_gcd(number1,number2);\n int lcd = ((double)number1 * (double)number2)/gcd;\n printf("GCD is %d and LCD is %d",gcd,lcd);\n getch();\n\n}\n\nint find_gcd(int n1,int n2)\n{\n if(n1 == n2) return n1;\n if(n1 == 1) return 1;\n if((n2 % n1) == 0) return n1;\n if(n1 < n2) return(find_gcd(n2-n1,n1));\n else return(find_gcd(n1-n2,n1));\n}
966120
try this stuff... pls understand the logic...\n\n#include<stdio.h>\n\nint main()\n{\nint no,rem;\nscanf("%d",&no);\nwhile (no)\n{\nrem = no % 10;\nprintf("%d",rem);\nno = no / 10;\n}\n}
671787
There is a C language tutorial available on the net.It is available in PDF format.You can search for it on yahoo search.
195727
Here is one way of doing it, using only what we've seen so far: \n\n#include <stdio.h>\n\nextern int getline(char [], int);\nextern int reverse(char [], int);\n\nint main()\n{\nchar line[100];\nint len;\n\nwhile((len = getline(line, 100)) != EOF)\n{\nreverse(line, len);\nprintf("%s&#92;n", line);\n}\n\nreturn 0;\n}\n\nint reverse(char string[], int len)\n{\nint i;\nchar tmp;\nfor(i = 0; i < len / 2; i = i + 1)\n{\ntmp = string[i];\nstring[i] = string[len - i - 1];\nstring[len - i - 1] = tmp;\n}\nreturn 0;\n}\n\nIn practice, it would be a nuisance to have to pass the length of the string to the reverse function. Strings in C are always terminated by the ``zero'' or ``nul'' character, represented by &#92;0. Therefore, reverse (or any piece of code) can always compute the length of a string, either by searching for the &#92;0, or by calling the library function strlen, which computes the length of a string by searching for the &#92;0. Here is how the program might look if the reverse function did not require that the length of the string be passed in: \n#include <stdio.h>\n#include <string.h>\n\nextern int getline(char [], int);\nextern int reverse(char []);\n\nint main()\n{\nchar line[100];\n\nwhile(getline(line, 100) != EOF)\n{\nreverse(line);\nprintf("%s&#92;n", line);\n}\n\nreturn 0;\n}\n\nint reverse(char string[])\n{\nint len = strlen(string);\nint i;\nchar tmp;\nfor(i = 0; i < len / 2; i = i + 1)\n{\ntmp = string[i];\nstring[i] = string[len - i - 1];\nstring[len - i - 1] = tmp;\n}\nreturn 0;\n}
750295
check out http://www.planet-source-code.com for examples.  I don't do C, but I use that site all the time.
979933
I'm giving u the program (in C), just go through it, then write the algo. It'll be easier.\n\n// Program :  MERGE  SORT\n\n#include<stdio.h>\n#include<conio.h>\n\nvoid mergesort(int *,int);\n\nvoid main()\n{\nint x[30],n,i;\nclrscr();\nprintf("Enter total no. of elements");\nscanf("%d",&n);\nprintf("Enter %d nos.",n);\nfor(i=0;i<n;i++)\n   scanf("%d",&x[i]);\n\nmergesort(x,n);\n\nprintf("After sorting in descending order :&#92;n");\nfor(i=n-1;i>=0;i--)\n  printf(" %d",x[i]);\n\ngetch();\n}\n\n\n\nvoid mergesort(int x[],int n)\n{\n  int aux[30],l1,l2,u1,u2,i,j,k,size;\n  size=1;   // merges file of size 1\n  while(size<n)\n  {\n    l1=0;   // initialize lower-bound of 1st. file\n    k=0;    // k is index for auxilliary array\n    while(l1+size<n)\n    {\n      // initialize remaining parameters...\n      l2=l1+size;\n      u1=l2-1;\n      u2=(l2+size-1)<n ? (l2+size-1):(n-1);\n      for(i=l1,j=l2;i<=u1 && j<=u2;k++)\n if(x[i]<=x[j])\n   aux[k]=x[i++];\n else\n   aux[k]=x[j++];\n      while(i<=u1)\n      aux[k++]=x[i++];\n      while(j<=u2)\n      aux[k++]=x[j++];\n\n      l1=u2+1;\n    } /* end of 2nd. while-loop */\n    for(i=l1;k<n;i++)\n       aux[k++]=x[i];\n    for(i=0;i<n;i++)\n       x[i]=aux[i];\n\n    size*=2;\n  } /* end of 1st. while-loop */\n}