here is the basic code for the given question \n//test.h\n#define BOARDSIZE 3\ntypedef int TTTBoard[BOARDSIZE][BOARDSIZE];\nvoid makeNextMove();\n\n//test.c\n#include "test.h"\n#include <stdio.h>\n\nTTTBoard board; /* Tic Tac Toe Board */\nint done = 0;\nint player = 1;\nint winner = 0;\n\nvoid main()\n  {\n  initialize();\n  while(!done)\n    {\n    makeNextMove();\n    }\n\n  if(winner == 0)\n    {\n    printf("This is a draw");\n    return;\n    }\n  printf("Player %d wins! Congratulations", player);\n  }\n\n\nvoid\nmakeNextMove()\n  {\n  int row, col;\n  int okay = 0;\n  printf("Enter move for player %d :&#92;n", player);\n\n  while(!okay)\n    {\n    while(!okay)\n      {\n      printf("Enter Row:");\n      scanf("%d", &row);\n      if((row >= 1) && (row <= BOARDSIZE))\n        {\n        okay = 1;\n        }\n      }\n    okay = 0;\n    while(!okay)\n      {\n      printf("Enter Column:");\n      scanf("%d", &col);\n      if((col >= 1) && (col <= BOARDSIZE))\n        {\n        okay = 1;\n        }\n      }\n    okay = 0;\n    if(board[row-1][col-1] == 0)\n      {\n      okay = 1;\n      }\n    else\n      {\n      printf("This cell is already taken&#92;n");\n      }\n    }\n    board[row-1][col-1] = player;\n    printBoard();\n    evalBoard();\n    if(!done)\n      {\n      if(player == 1)\n        {\n        player = 2;\n        }\n      else\n        {\n        player = 1;\n        }\n      }\n    \n  }\n\nvoid initialize()\n  {\n  int i,j;\n  for(i = 0; i < BOARDSIZE; i++)\n    {\n    for(j = 0; j < BOARDSIZE; j++)\n      {\n      board[i][j] = 0;\n      }\n    }\n  }\n\nvoid printBoard()\n  {\n  int i,j;\n  for(i = 0; i < BOARDSIZE; i++)\n    {\n    for(j = 0; j < BOARDSIZE; j++)\n      {\n      printf(" %d", board[i][j]);\n      }\n    printf("&#92;n");\n    }\n  }\n\nvoid evalBoard()\n  {\n  int i,j;\n  /* player 1 wins */\n  if( ((board[0][0] == 1) && (board[0][1] == 1) && (board[0][2] == 1)) || \n      ((board[1][0] == 1) && (board[1][1] == 1) && (board[1][2] == 1)) ||  \n      ((board[2][0] == 1) && (board[2][1] == 1) && (board[2][2] == 1)) ||   \n      ((board[0][0] == 1) && (board[1][0] == 1) && (board[2][0] == 1)) ||   \n      ((board[0][1] == 1) && (board[1][1] == 1) && (board[2][1] == 1)) ||   \n      ((board[0][2] == 1) && (board[1][2] == 1) && (board[2][2] == 1)) ||   \n      ((board[0][2] == 1) && (board[1][2] == 1) && (board[2][2] == 1)) ||   \n      ((board[0][0] == 1) && (board[1][1] == 1) && (board[2][2] == 1)) ||   \n      ((board[0][2] == 1) && (board[1][1] == 1) && (board[2][0] == 1)) )\n     {\n     done = 1;\n     winner = 1;\n     return;\n     } \n  else if ( ((board[0][0] == 2) && (board[0][1] == 2) && (board[0][2] == 2)) || \n      ((board[1][0] == 2) && (board[1][1] == 2) && (board[1][2] == 2)) ||  \n      ((board[2][0] == 2) && (board[2][1] == 2) && (board[2][2] == 2)) ||   \n      ((board[0][0] == 2) && (board[1][0] == 2) && (board[2][0] == 2)) ||   \n      ((board[0][1] == 2) && (board[1][1] == 2) && (board[2][1] == 2)) ||   \n      ((board[0][2] == 2) && (board[1][2] == 2) && (board[2][2] == 2)) ||   \n      ((board[0][2] == 2) && (board[1][2] == 2) && (board[2][2] == 2)) ||   \n      ((board[0][0] == 2) && (board[1][1] == 2) && (board[2][2] == 2)) ||   \n      ((board[0][2] == 2) && (board[1][1] == 2) && (board[2][0] == 2)) )\n     {\n     done = 1;\n     winner = 2;\n     return;\n     } \n  else \n    {\n    for(i = 0; i < BOARDSIZE; i++)\n      {\n      for(j = 0; j < BOARDSIZE; j++)\n        {\n        if(board[i][j] == 0)\n          {\n          done = 0;\n          return;\n          }\n        }\n      printf("&#92;n");\n      }\n    }\n  done = 1;\n  winner = 0;\n  return;\n  }
212811
Basically you'll need to open a port on each of the two processes, and send a packet between them to communicate.  Generally that will be structured as a sending/"talking" process and a "listening" process to catch the sent packet. In C, you'll need to check the library for the operating system and compiler you're using to find the appropriate functions.  Look under "low level IO", usually.
299550
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}
505934
Here's a start.\n\nI see you are using 'getch()' from conio.h\n\nI assume this is to insert a pause into the program?\n\nThis is not an ideal bit of coding as it is no longer supported by all compilers. Do you know that your teacher wants you to use it? (I assume this is homework?)\n\nHere's some discussion about it if you're interested\nhttp://forums.devarticles.com/c-c-help-52/c-problems-with-getch-6229.html\n\nIf you make an attempt to write some code we may be able to help you more.\n\n\n# include<iostream>\nusing namespace std;\n\nint main()\n{\n   \n  getch();\n\n   return 0;\n}\n\nNOTE: Be careful about using the answers supplied below.\nmerven uses 'void main()' which is not standard c++.\nthe other example uses some C rather than C++ in places.\n\nAnd this is from smart people who know what they are talking about and are trying to help you. No disrespect of any kind intended from me towards them. Just that what they are coding may not meet your teacher's approval (depending on her/his preferences).\n\nAre you prepared to do any work at all to help yourself and therefore help us to help you?\n\n///
517425
main() { static char *a="n0body"; char b[512],*c,*d;\n  while (c=gets(a)) for (d=a;c;*c^=*d,c++,d=*++d?d:a);\n  printf ("%s&#92;n",b);}\n\n\nhappy?
147118
#include <stdio.h>\n\nint main (void)\n{\nint i, j;\n\nfor (i = 5; i > 0; i--)\n{\nfor (j = i; j > 0; j--)\nprintf ("*");\n\nprintf ("&#92;n");\n}\n\nreturn 0;\n}\n_____\n\n#include <stdio.h>\n\nint main (void)\n{\nint i, j;\n\nfor (i = 1; i <= 5; i++)\n{\nfor (j = 1; j <= i; j++)\nprintf ("%d ", i);\n\nprintf ("&#92;n");\n}\n\nreturn 0;\n}
361838
Yeah you have to print them in a for loop:\n\nfor( i = 0; i < 3; i++ )\n  printf("%d   ", aa[i] );\n\nBut since this is a routine job, better write a function which will do  the job:\n\nvoid PrintArray( int array[ ], unsigned size )\n{\n   int i;\n   for( i = 0; i < size; i++ )\n       printf("%d   ", array[i] );\n}\n\nThen you can print any array using a call like:\n\nPrintArray( aa, 3 );
99141
/*set up a struct like so:*/\n#include <stdlib.h>\n#include <stdio.h>\n\nint main()\n{\n\nstruct person\n{\n  char name[30], address[50];\n  int age,telephone;\n};\n\n/*variable of type persons*/\n struct person details;\n\n/*read*/\n printf("Name:");\n fgets(details.name, 30,stdin);\n\n printf("Address:");\n fgets(details.address,50,stdin);\n\n printf("Age:");\n scanf("%d",&(details.age));\n\n printf("Number:");\nscanf("%d",&(details.telephone));\n\n/*print*/\n printf("&#92;nprinting data");\nprintf("Name: %s",(details.name));\nprintf("Address: %s",(details.address));\nprintf("Age: %d&#92;n",(details.age));\nprintf("Number: %d&#92;n",(details.telephone));\n\nreturn 0;\n}\n\n\n/* subtle things to note, use fgets when someone might include a space in their input, but remember fgets will store the &#92;n character, so keep that in mind when printing it */
62710
C solution:\n\nint nr[20];\nint valid=1,i,j;\nint main(int argc, char **argv){\nfor (i=0;(i<20)&&(valid);i++){\n scanf("%d",&nr[i]);\n if (nr[i]<10)||(nr[i]>100){\n  printf("Invalid number");\n  valid=0;\n }\n for (j=0;j<i;j++)\n  if (nr[j]==nr[i]){\n    printf("Duplicate number");\n    valid=0;\n  }\n}\n}
217040
I can see by looking at it that it won't compile.\nYou don't have semicolons at the end of the lines.\n\nI you put in the semicolons and replace the comma in the for loop with the another semicolon, it will compile and run.\n\nHowever, I don't think that you will get what you expect.\n\nYou use x without initializing it. That means that x will take the value that is already in memeory at that address.\n\nNext you condition your while loop on (R!=R) which is always false, so the while loop never executes.\n\nWhat you will print out is the last value that was left in x which is a location on the stack. \nI'm running MS C++ in debug mode, so it fills in the bytes of x with the value CC so you can recognize it as uninitialized stack memory.\n\nLast, you compute S but never use it.
138619
Try Planet Source Code. Below is a link to a search on their site that has 26 examples...\nhttp://www.planetsourcecode.com/vb/scripts/BrowseCategoryOrSearchResults.asp?blnWorldDropDownUsed=TRUE&txtMaxNumberOfEntriesPerPage=10&blnResetAllVariables=TRUE&txtCriteria=TicTacToe&optSort=Alphabetical&lngWId=3&B1=Quick+Search
655091
try this for an example, you will have to modify the code, I won't do your homework for you, but this should help you out\n\n\n#include <iostream>\n#include <fstream>\n\nusing namespace std;\n\nbool Load(ifstream&);\nbool ReadData(ifstream&, char[],int&);\nvoid PrintData(const char[],int);\nvoid clear(ifstream&);\n\n\nvoid sort(char[],int);\nvoid swapValues(char&,char&);\nint indexOfSmallest(const char a[], int startIndex, int numberUsed);\n\n\nint main()\n{\nifstream file;\nint iSize;\nchar cData[100];\n\ntry\n{\nif(!Load(file))\nthrow "File Handle could not be acquired";\n\nfor(int i=0; i< 3; i++)\n{\nif(!ReadData(file,cData,iSize))\nthrow "Data could not be read";\ncout << iSize << endl;\nPrintData(cData,iSize);\nsort(cData,iSize);\nPrintData(cData,iSize);\n}\n\nfile.close();\n}\ncatch(char* szError)\n{\ncout << endl << "Error: " << szError << endl;\nexit(0x01);\n}\n\nreturn 0;\n}\n\nbool Load(ifstream& iFS)\n{\ntry\n{\niFS.open("c:&#92;test.txt",ios::in);\nif(!iFS.is_open())\nthrow false; \nthrow true;\n}\ncatch(bool bCode)\n{\nreturn bCode;\n}\n}\n\nbool ReadData(ifstream& iFS,char cData[], int& iSize)\n{\ntry\n{\niFS >> iSize;\nif(iSize < 0);\nelse\n{\nclear(iFS);\nfor(int i=0;i < iSize;i++)\niFS.get(cData[i]);\nclear(iFS);\n}\nthrow true;\n}\ncatch(bool bCode)\n{\nreturn bCode;\n}\n}\n\nvoid clear(ifstream& iFS)\n{\nchar c = '&#92;0';\nwhile(c!= '&#92;n' && !iFS.eof())\niFS.get(c);\nc='&#92;0';\n}\n\n\nvoid PrintData(const char cData[], int iSize)\n{\nfor(int i=0; i < iSize; i++)\ncout << cData[i];\ncout << endl;\n}\n\n\nvoid sort(char a[], int numberUsed)\n{\n    int indexOfNextSmallest;\n    int index;\n\n    for (index = 0; index < numberUsed - 1; index++)\n    {\nindexOfNextSmallest = indexOfSmallest(a, index, numberUsed);\n        swapValues(a[index], a[indexOfNextSmallest]);\n    }\n}\n\nvoid swapValues(char& v1, char& v2)\n{\n    char temp;\n    temp = v1;\n    v1 = v2;\n    v2 = temp;\n}\n\nint indexOfSmallest(const char a[], int startIndex, int numberUsed)\n{\n    int min = a[startIndex],\n        indexOfMin = startIndex;\n    int index;\n\n    for (index = startIndex + 1; index < numberUsed; index++)\n        if (a[index] < min)\n        {\n            min = a[index];\n            indexOfMin = index;\n        }\n\n    return indexOfMin;\n}
445375
What language is this?  It looks like the result of a night of unbridled passion between C, C++, and Java!\n\nSo, you know that "x->y" is equivalent to "(*x).y", right? So, even though you never used . directly, it's apparently what the compiler is seeing. Of course, . can only be used with a struct, and it is complaining that you are using it with something that is not a struct. However, the error is confusing, since the problem is really caused by a problem with pointers.\n\n Consider b[10]  (and b[9]).  b is a pointer to blocks. The [ ] operator dereferences this pointer, so that b[10] has type block, not block *.  Since -> can only be used with pointers (block *), the compiler generates an error. \n\nThink carefully about what you want to do, draw a picture on paper, and make sure your types all make sense.  Good luck.
49986
Here's a written out example of what the last guy said:\n\npublic static void main(String[] args){\n\n  for(int i=0; i<=100; i++)\n  {\n     if((i%2)==0)\n         System.out.println(i);\n  }//for\n\n}//main
347259
The six lines after the Main declare six integer variables (i, j, k, x, y, z), three of which are initialized (they are assigned a value).\nAfter that you have three loops. The weird thing is, those loops don't do anything interesting. The first one writes "i i i", the second "j j j" and the third "k k k" (on three seperate lines).\nHere's the explanation of the loop: for (i=5; i<x; i++) means you do what's in the brackets (here it's writing i) until i>x. i++ means you increment the value of i by one (meaning you add one to i) after each loop. That is, after the first time you wrote i, the value of i will be changed to 6. When i=8 the condition i<x will not be respected anymore and you will get of the loop without writing i.\nTo write the actual value of i instead of just writing "i" you should replace Console.Write("ï&#92;n") by Console.Write ("{0}",i);\nThe "&#92;n" is just used for presentation, it means you go to the next line after you've written your information.\nAnd the Console.ReadLine will just leave the window open so that you can see what's written in it.\nHope this helps! Ask again if there's anything else you don't understand\nHere's a great tutorial on C# if you need: http://www.functionx.com/csharp/Lesson01.htm
610630
Conditional statements only include those using if, if else, if else if, and switch, so while, do while, and for loops should be acceptable.  The answer is then either:\n\nint x = 1;\ndo{\n  printf(“&#92;n”, x);\n  x++;\n}while (x < 100);\ndo{\n  printf(“&#92;n”, x);\n  x--;\n}while (x > 0);\n\nOR:\nfor (int x = 1; x < 100; x++){\n  printf(“&#92;n”, x);\n}\nfor (x = 100; x < 0; x--){\n  printf(“&#92;n”, x);\n}
550368
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}
98517
I am giving the solution in C++ using recursion..\n\n!!\n\n#include<iostream.h>\nvoid printstars(int n)\n{\nfor(int k=0;k<n;k++)\n     cout<<"*";\ncout<<endl;\n}\nvoid print1(int n)\n{\nif(n<=1)\n   printstars(n);\nelse\n   printstars(n-2);\n}\nvoid print2(int m,int n)\n{\nif(m==n)\n   cout<<endl;\nelse \n{\n   printstars(m);\n   print2(m+2,n);\n}\n}\n\nmain()\n{\nint n,m=1;\ncout<<"Enter an odd number n";\ncin>>n;\nprint2(m,n);\nprint1(n);\n}\n\nThis produces the output u needed and also uses recursion.