we dont use & in scanf function in c for reading strings .y is it so?
952303
Bcoz, the char itself returns the address...\nso no need for using '&' before it...
359046
#include <ctype.h>\n#include <stdio.h>\n#include <stdlib.h>\n\nstatic char *article[] = { "the","a", "one", "some", "any" };\nstatic char *noun   [] = { "boy","girl", "dog", "town", "car" };\nstatic char *verb   [] = { "drove","jumped", "ran", "walked", "skipped" };\nstatic char *prep   [] = { "to", "from", "over", "under", "on" };\n\nint\nmain()\n{\n  int asize = sizeof(article)/sizeof(article[0]);\n  int nsize = sizeof(noun)/sizeof(noun[0]);\n  int vsize = sizeof(verb)/sizeof(verb[0]);\n  int psize = sizeof(prep)/sizeof(prep[0]);\n\n  char buff[100];\n  for (int i=0; i<20; i++) {\n    (void)sprintf(buff, "%s %s %s %s %s %s.",\n      article[rand()%asize],\n      noun[rand()%nsize],\n      verb[rand()%vsize],\n      prep[rand()%psize],\n      article[rand()%asize],\n      noun[rand()%nsize]);\n    *buff = toupper(*buff);\n    (void)printf("%s&#92;n", buff);\n  }\n  return 0;\n}\n\n\n$ a.out\nSome town walked to a dog.\nThe car ran from any dog.\nAny boy drove under any town.\nOne girl jumped under the girl.\nOne car jumped to one girl.\nAny boy skipped over a dog.\nAny town jumped from some town.\nThe town ran from the town.\nOne car walked to any town.\nOne town ran over one boy.\nAny town jumped on the car.\nSome dog skipped from a boy.\nSome girl skipped over a boy.\nA car walked over some girl.\nThe car jumped from a girl.\nThe boy skipped on the town.\nAny car walked from one girl.\nAny dog ran to a town.\nA car jumped under some car.\nSome boy walked to the car.
499645
20+ years ago, I had a homework assignment to do this. However, I had to do it in PL/C. It is possible, but being so long ago, I don't remember exactly how I did it. I remember it started with something like the following:\n\nvoid main()\n{\ncout << "void main()";\ncout << "{";\n// Oops there's a problem here!!!\ncout << "}";\n}\n\nI have a memory of using an array of strings to store the values, rather than list them out individually. I also remember that each token was in two places: as a command in the program and within the string, so when I discovered a mistake, I needed to correct it in two places.\n\nI was taking an automata theory at the time. Our instructor had us do this exercise to demonstrate the principle of proving things about turing machines by having a program execute itself. This technique is used to prove the halting problem.
775271
if this is a .c file, then the reason is that you have declared local variables AFTER a function call.  This is legal in c++ but not in c.\n\nswap the printf and char lines and it should work.
1110691
Here is something I came up with quickly ( not fully complete, I will leave that to you ! ) \n\nThis quick bit of code will give you a start ( hopefully and no recursion ).\n\nPlease note that this is not complete and you will get a memory leak in swap function ( easily fixed btw ! ).\n\n#include "stdafx.h"\n#include "stdio.h"\n#include "string.h"\n\nvoid manipulate( char* pString, int index );\nchar* swap( char* pString, int pos );\n\nchar pod[255];\n\n\nint main(int argc, char* argv[])\n{\n\n  char* p = "abc";\n  memcpy( pod, p, strlen( p ) );\n  for( int i = 0; i < strlen( p ); i ++ )\n  {\n    manipulate( pod, strlen( p ) );\n  }\n  return 0;\n}\n\n\nvoid manipulate( char* pString, int index )\n{\n  int i = 1;\n  char* p;\n  p = pString;   \n  while( index > 1 ) \n  {\n    p = swap( p, i );\n    index--;\n    i++;\n    memcpy( pod, p, strlen( pString ) );\n    printf( "%s&#92;n", p );\n  }\n}\n\nchar* swap( char* pString, int pos )\n{\n  char* p = new char[ strlen(pString) + 1 ];\n  memset( p, '&#92;0', strlen( pString ) + 1);\n  memcpy( p, pString, strlen( pString ) + 1 );\n  char temp = p[pos];\n  p[pos] = pString[pos-1];\n  p[pos-1] = temp;\n  return p;\n}
790827
main () {char *s, b[100]; while(s=gets(b)) printf (atoi(s)%2 ? "nope&#92;n" : "yep&#92;n");}
755895
Scanner.next() returns a String, and you are assigning it to an int.\nThat's incompatible. Replace it with nextInt() if you expect to read an integer, nextDouble() to get a double etc.\n\nnext time, if you want to get answers from people who actually have programmed in java, I'd recommend that you show a little respect for them by counting your lines yourself, and pointing out where those 21 and 23 are instead of just throwing a page of code, and expecting that somebody will drop what they are doing and fix it for you
526248
There are many answers to this:\n\n1) Take the string, make a reverse copy of it and compare the strings\n\n2) Pointer to the start index of the string and end index of the string and start comparing till you get strlen/2\n\n.... for more solutions and code you can search the web
444754
This sounds like school work, its a fairly simple program. you will probably want to use the cout and cin function which needs you to include iostream.h \n\nsimply use cout to print to screen, ask for input etc. then take the input using cin and store it to a int variable.\n\na good way to do it would be to ask the user what they wish to do, eg subtract, divide and take that operator first, a symbol or a number to show choice. then the next line asks for the numbers to be input.\n\neg:\n\n---------\n\nHello. what do you wish to do:\n1 - subtract\n2 - divide\n3 - etc etc\n\n>\n\n-------------\n\nthen use an if function or maybe a switch to check what their input was and do the artithmatic.\n\nso a very basic prgram may look like this:\nit may have errors i havant checked it.\n\n-----------------\n\n#include <iostream>\n\nint main() \n{\nint number;\n\n    cout << "Hello, input a number" << endl;\n    cin >>number;\n    return 0;\n}\n\n------\n\nEDIT; i re read the req, you might find inputting the selection to a char better, then check the char to see what symbol is stored in it, eg + / -. and maybe use a char array for the number input. simple take the char array, check for the space. split the numbers into 2 and caste then to an int. sounds complicated but it isnt to hard.\n\nsorry about spelling mistakes.
277838
char ch = 'a';\nif(Character.isLowerCase(ch) == true)\n // lowercase\nelse\n // uppercase
1028984
C does not have a boolean data type as in the case of Visual Basic or any other SDK.\nSo, you can't declare a variable like:\n\nbool flag; (wrong)\n\nBut, instead you can do this alternative, using preprocessor directive(#)\n\n#define TRUE 1\n#define FALSE 0\n\nint main()\n{\n    ...\n    ...\n   return 0;\n}\n\nYou can now use the keyword 'TRUE' and 'FALSE' like this:\nif(x = TRUE)\n{\n  ...\n  ...\n}\nelse\n{\n  ...\n  ...\n}\n\nTRUE and FALSE technically are called Symbolic Constants
963718
They could all potentially be valid C statements, depending on what functions and variables have already been defined.\n\nRawlyn.
656675
include <stdio.h>\n\nvoid main(){\n   float no;\n   scanf("%f",&no);\n   if(!( ((int)no)%7!=0 || ((int)no)%2==0 )) \n      printf("No is divisible by 7 and not divisible by 2");\n}\n\nsalam
930564
You just need to modify it a bit:\n\nfor (...)\n{\nif (tstring[a] == ' ')\n{tstring[a] = '_';}\n\nelse\n{lower_case(tstring,a);}\n} // end for\ntstring[0] = toupper(tstring[0]);\n\n\nAlso, your lower_case function isn't really necessary since you can assign tstring[a] = tolower(tstring[a]) straight away. Just a thought. ;)
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.
973633
could cause programs to look in the wrong place for things. change it to c
406293
scanf reads from the input line and printf prints the information you give to the output line.