what is main segment in c?
446677
I think you might be asking about the main statement.  This takes the form\n\nvoid main (void)\n{\n}\n\n(ok, sometimes other forms such as int main(int, char*){})\n\nIt is normally used to signify the entry point for an execution unit.\n\nBut, knowing this won't help you much.  There are hundreds of books on the subject, but you should start with K&R.  You won't learn C from Yahoo answers.
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.
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
434228
It's a variable in memory that instead of holding a value, it holds an address location which serves as a "pointer" to another piece of data\n\nexample:\n\nint c;\nint * cp; //cp is a pointer\nc = 3;\n\ncp = &c; //cp now points to 3;\n//& is the "address of" operator which returns the address of a variable\n* cp = 4; //* is a C operator which means "dereference"\n//what the * does it says, instead of using the pointer itself\n//use the value pointed to... so when you do '* cp = 4;' you are actually changing the value of c\n\n\nPointers take a bit of practice and understanding. You can do basic arithmatic on them. Arrays are basically just a pointer to the first element of the array. c-strings are just a pointer to the first character in the string, really an array of characters.
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}
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>.
412281
circular segment\n\nhttp://en.wikipedia.org/wiki/Circular_segment
1161264
The above answerer is slightly wrong.  C++ holds a subset of C, it is not the complete C language.\n\nApart from that, You should be able to get a program that executes in C, not in C++.\n\n/* hello.c -- The most famous program of them all ..\n */\n\n#include <stdio.h>\n\nint main(void) {\n  printf("Hello World!&#92;n");\n}\n\nGot from http://www.cis.temple.edu/~ingargio/cis71/code/hello.c
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__ */
628097
Imagine a block of memory from 0 to N. A cyclic buffer fills from 0 towards N, and when it reaches N it starts back at 0 again.\nThis kind of buffer needs to be "serviced" (have the data removed) before new data overwrites data that hasn't been removed yet.\nThere is normally an "in" pointer for incoming data, and an "out" pointer for outgoing data, If the "out" pointer reaches the "in" pointer, the buffer is empty again. If the "in" pointer reaches the "out" pointer, you've overflowed the cyclic buffer!
1065652
void main()\n{\ncout<<"no"<<"/t"<<"id.no"<<"/t"<<"name"<<"/t"<<"sex"<<"/t"<<"department";\ncout<<"1 001/98 sarafcomputerscience&#92;n";\ncout<<"your information";\ncout<<"your information";\ncout<<"your information";\ncout<<"your information";\n\n}\nif u want to get input at runtime try to input thr cin>> statement and get that output by cout statement
253284
#include <stdio.h>\n\nint main(void) {\n\nint i, j, count; //C Sucks, wait till you take java\n\nfor(i=1; i<=1000; i++){&#92;&#92;goes through all numbers 1 to 1000\n    count=0;\n    for(j=2; j<i; j++)&#92;&#92;goes through all numbers 2 to i\n    {\n     if(i%j==0)&#92;&#92;checks to see if it i is evenly div. by i\n        count++;\n    }//nested for\n    if (count ==0)\n        printf("%d&#92;n", i);\n}//for\n\nreturn 0;\n}//main\n\n\n//Hope that helps!
557543
#include<iostream>\nusing namespace std;\nint main ()\n\n\n    {\nint number;\nint answer;\n    cout<<"Please enter number: ";\n    cin>>number;\n    \n    cout<<number<<"! = ";\n    answer = number;\n    while (number>1)\n\n\n        {\n        answer=answer*(number-1);\n        number--; \n    } \n\n    cout<<answer; \n    return 0; \n}
777982
make sure 'a' is defined as a pointer to another variable you've declared. like:\n\n int b = 1;\n int* a = &b;\n\nOtherwise, if you simply declare \n  int* a;\n  *a = 1;\n\n..then you have reserved memory for an address, but not for the contents.  'a' is pointing to a pseudo-random place in memory.\n\n Secondly, printf() of 'a' should return the address you've reserved.  printf() of '*a' should return the 1 as you're expecting.  The most likely reason you're not seeing this is because 'a' is set to (1) - which means it is not a valid pointer.  This can be caused by some compilers in a DEBUG build when a variable goes out of scope.  As in:\n\n  int* a;\n {\n    int b = 1;\n    a = &b;\n  }\n  // 'b' is now out of scope - some compilers will change memory to indicate this during a debug build.  *a is now (0) !\n\n Hope that helps.
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!
676530
In c++\n\n#include <iostream.h>\n\nint main(int argc, char* argv[])\n{\n printf("Hello World!&#92;n");\n return 0;\n}
423103
#include <stdio.h>\n#include <stdlib.h>\n\nint\nmain(int argc, char* argv[])\n{\n  int count = argc>1 ? atoi(argv[1]) : 10;\n  FILE *f = fopen("numfile", "w+");\n  if (!f)\n    perror("fopen"), exit(-1);\n  for (int i=0; i<count; i++)\n    fprintf(f, "%d&#92;n", rand());\n  fclose(f);\n  return 0;\n}