Problem is about C program output where after changing the order in statement the output is different. why so?
535956
A1 k is 0 because the expression got short circuited.  Since i and j are non zero values, the value of the || will always be true, so the right side does not need to be evaluated and k is never incremented.\n\nA2 when you switched to put the || first, no short circuiting can occur (since i and j are non zero, k still needs to be evaluated because of the &&).  The value of m is non-determinate in both cases.
314000
since they are all stored as binary all you need to do is display the results as either octal or decimal.\n//**************************************\n//INCLUDE files for :Convert Hex,dec,oct\n//**************************************\n#include <iostream.h>\n#include <conio.h> //for clrscr() & getche()func\n#include <stdlib.h> // for exit() function...\n//**************************************\n// Name: Convert Hex,dec,oct\n// Description:Converts an inputed number to Hex, dec, or oct.\nThe code was mainly written for education purposes.\n// By: Vagabond\n//\n//\n// Inputs:Inputs are from a main menu screen\n//\n// Returns:None\n//\n//Assumes:None\n//\n//Side Effects:None\n//This code is copyrighted and has limited warranties.\n//Please see http://www.Planet-Source-Code.com/xq/ASP/txtCodeId.10360/lngWId.3/qx/vb/scripts/ShowCode.htm\n//for details.\n//**************************************\n\n//****************************************************************************//\n// //\n// Program Name : ConvDec.cpp //\n// //\n// Programmer : Vagabond//\n//: Novice C++ //\n// //\n// Description : The user is asked to input a number in either Hex, Octal or //\n//Decimal, which is then converted to Hex, Octal & Decimal. //\n//The user can exit the program from the MAIN MENU or by//\n//the Escape key after each convertion.//\n// //\n//Compiler : Borland Turbo C++ v4.5.//\n// Date : 16/03/2006 //\n// //\n//****************************************************************************//\n#include <iostream.h>\n#include <conio.h>// for clrscr() & getche() functions...\n#include <stdlib.h> // for exit() function...\nconst int ESC = 27; // Used for escape sequince\nint main()\n\n\n    {\n    int key = 0;\n    int choise = 0;\n    long number;\n    while(key != ESC)\n\n\n        {\n        cout << "Choose Your Number Base&#92;n";\n        cout << "&#92;n&#92;t1. Hexadecimal.";\n        cout << "&#92;n&#92;t2. Octal.";\n        cout << "&#92;n&#92;t3. Decimal.";\n        cout << "&#92;n&#92;t4. Exit.&#92;n&#92;t";\n        cin >> choise;\n        switch(choise)\n\n\n            {\n            case 1: clrscr();\n             cout << "Enter a Hex number: ";\n             cin >> hex >> number;\n             cout << "&#92;n value in octal = "\n             << oct << number << endl;\n             cout << " value in decimal = "\n             << dec << number << endl;\n             break;\n            case 2: clrscr();\n             cout << "Enter a Octal number: ";\n             cin >> oct >> number;\n             cout << "&#92;nvalue in hex = "\n             << hex << number << endl;\n             cout << " value in decimal = "\n             << dec << number << endl;\n             break;\n            case 3: clrscr();\n             cout << "Enter a dec number: ";\n             cin >> dec >> number;\n             cout << "&#92;n value in octal = "\n             << oct << number << endl;\n             cout << "value in hex = "\n             << hex << number << endl;\n             break;\n            case 4: clrscr();\n             cout << "Program terminated by user...";\n             exit(0);\n             break; //Unreachable code.... \n            default : clrscr();\n             cout << "ERROR ~ Invalid selection&#92;n&#92;n";\n             break;\n            }\n            cout << "Press any key to continue or 'Esc' to exit";\n            key = getche();\n            clrscr();\n            }\n            cout << "Program terminated by user...";\n            return 0;\n
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.
577652
Since you specified that the language is "C", it's\nworth pointing out that the Ansi standard guarantees\nthat the implementation will include a "qsort" function.\n\nAll you need to do is write the simple comparison\nfunction which is passed to qsort, and you're done.\n\nI copied the following (including the little test program)\ndirectly from the qsort man page:\n\n#include <stdlib.h>\n#include <stdio.h>\n\nstatic int\nintcompare(const void *p1, const void *p2)\n{\n  int i = *((int *)p1);\n  int j = *((int *)p2);\n\n  if (i > j)\n    return (1);\n  if (i < j)\n    return (-1);\n  return (0);\n}\n\nint\nmain()\n{\n  int i;\n  int a[10] = { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };\n  size_t nelems = sizeof (a) / sizeof (int);\n\n  qsort((void *)a, nelems, sizeof (int), intcompare);\n\n  for (i = 0; i < nelems; i++)\n    (void) printf("%d ", a[i]);\n\n  (void) printf("&#92;n");\n  return (0);\n}\n\n\nSee the references for the man page as well as the\nsource from the OpenSolaris site.
274717
for( int i = 55; i > 0; i-- )\n  printf( "%d&#92;n", i );
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)
348911
#include <stdio.h>\n#include <strings.h>\n\nint\nmain(int argc, char* argv[])\n{\n  char *token, *string = argv[1];\n  int count = 0;\n\n  while ((token=strtok(string, "&#92;t ")) != 0) {\n    count++;\n    string = 0;\n  }\n    \n  printf("String has %d words&#92;n", count);\n\n  return 0;\n}\n\n\nAnd to show that it works:\n\n$ cc cw.c\n\n$ a.out "this is a simple test"\nString has 5 words
473239
Several problems:\n\n>  bubble_sort(names[3]);\n\nthis is accessing the 4th element of the names array (first 3 elements are at indices 0, 1, and 2). this is why you're getting your output, it's not sorting anything! i'm surprised this program didn't crash. instead you simply want to pass 'names' as the parameter - this means you are passing the entire array as a parameter, not a single element of the array. proper:\n   bubble_sort(names);\n\n>           if (array[j+1] > array[j])\n\nthis would sort the array opposite the way you want it. simple fix is using less-than instead of greater-than. BUT, if i'm not mistaken, you can't compare strings like that. you have to use strcmp, like this:\n            if (strcmp(array[j+1], array[j]) < 0)\notherwise, you are just comparing pointers.
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.
642877
int substitute(char c1, char c2, char *s) {\n// init. counter\nint num = 0;\n\nwhile (*s != '&#92;0') {\n\n// compare string char with 1st char\nif (*s == c1) {\n// if equal substitute with 2nd char and incr. counter\n*s = c2;\nnum++;\n} \n// incr. string pointer\ns++;\n}\n\n// return number of occurrences\nreturn num;\n}
618947
#include <iostream> \n#include <cstdlib> \n#include <iomanip> \n\nint make_odd(int h); \nvoid rec_call(char c, int s); \n\n\nint main( void) \n{ \n    cout << "Enter character to use in the diamond.&#92;t"; \n    char draw; \n    cin >> draw; \n    cin.ignore(1000, '&#92;n'); \n    cout << "How many rows in the diamond (make it an odd number)?&#92;t"; \n    int high; \n    cin >> high; \n    cin.ignore(1000, '&#92;n'); \n    high = (high % 2)? (high/2) + 1 : make_odd(high); \n    rec_call(draw, high); \n    cout << "&#92;n&#92;nPress Enter to Continue . . .&#92;t"; \n    cin.get(); \n    return 0; \n\n\n\n} \n\n\nint make_odd(int h) \n{ \n cout << "That is not an odd number&#92;nUsing " << (h + 1); \n return ((h / 2) + 1); \n\n\n} \n\n\nvoid rec_call(char c, int s)  // c = char to print s = rows to print \n{ \n static int i = 0; \n while(i < s) \n { \n      int width = s + i; \n      int len = 1 + (2 * i); \n      char temp[len + 1]; \n      for(int count = 0; count < len; count++) \n              temp[count] = c; \n      temp[len] = '&#92;0'; \n      cout << endl << setw(width) << temp; \n      i++; \n      rec_call(c, s); \n      if(i == s) \n      { \n         i++; \n         return; \n      } \n\n      cout << endl << setw(width) << temp; \n  } \n\n\n\n}
44673
Your program ran into code it couldn't execute or data it couldn't address.\n\nIf you wrote the code, look for things like uninitialized pointers, overwritten data structures, and anything else that could corrupt your code or data.
38471
Different systems use a different end of line character in the file formatting.  When a file is made and the program writes it out there are a few different end of line characters to choose from (depending on your operating system).  The program is writing it out with an end of line character that the conputer you are viewing it on reads as a ^M rather than an end of line.\n\nAre you viewing it on the same system as your program is writing it?  If so, then look in the program that you are making the page in and find the preference for end of line and change it.
551498
I'm no "C" expert, but in Delphi this is a Windows system call, and I'm sure it will be a similar implementation in C; just alter the syntax as necessary...
860477
Here is a program which first computes all the values and then, print it in the actual table manner. If value is 34, table for 1 to 10 will be printed first, then from 11 to 20, 21 to 30 and then from 31 to 34. \n\n#include <stdio.h>\n#include <conio.h>\n\nvoid main()\n{\n clrscr();\n int a[50][12];\n int n;\n printf("Enter the number till which you need tables ");\n scanf("%d",&n);\n for(int i= 1;i<=n;i++)\n  for(int j=1;j<=12;j++)\n   a[i][j] = i*j;\n\n for(int k=1;k<=n/10;k++)\n {\n\n  for(i = 1;i<=12;i++)\n  {\n   for(int j = (k-1)*10+1;j<=(k-1)*10+10;j++)\n    printf("%d&#92;t",a[j][i]);\n   //printf("&#92;n");\n  }\n  printf("&#92;n");\n  getch();\n }\n\n for(i = 1;i<=12;i++)\n  {\n   for(int j = (n/10)*10+1;j<=n;j++)\n    printf("%d&#92;t",a[j][i]);\n   printf("&#92;n");\n  }\n  printf("&#92;n");\n\n}
24430
It's a memory leak.  A type of bug.  When the program uses a section of memory, it never gives it up when its done - so eventually it expands to include all of your usable space.\n\nFile a bug complaint and wait for a patch.
1024904
Thats a recursive program for you.\nAnd I put an arbitrary limit of 9 there. You can change that for yourself.\n\n#include <stdio.h>\n\nvoid triangle(char ch, int count) {\n        int temp=0;\n        if (count==1) {\n                printf("%c&#92;n", ch);\n                return;\n        }\n        triangle(ch, count-1);\n        for(;temp<count;temp++) {\n                printf("%c", ch);\n        }\n        printf("&#92;n");\n}\n\nint main() {\n        char ch='*';\n        int count=0;\n        while((count<=0)||(count>=10)) {\n                printf("Enter the size of triangle (less than 10)&#92;n");\n                scanf("%d", &count);\n        }\n        triangle(ch, count);\n}