logo

CuriousTab

CuriousTab

Discussion


Home Technical Questions Programming Comments

  • Question
  • What would be the output of the following program? /* sample.c */ main ( int argc, char **argv ) { argc = argc - (argc -1); printf ("%s", argv[argc - 1]); }


  • Correct Answer
  • C: \SAMPLEEXE 


  • Programming problems


    Search Results


    • 1. Point out the error, if any, in the following program. # include "stdio.h" main() { FILE *fp; char str[80]; fp = fopen ("trail", "r"); while (!feof (fp)) { fgets (str, 80, fp); puts (str); } fclose (fp); }
    • Discuss
    • 2. How would you check whether the contents of two structure variables are same or not?
    • Discuss
    • 3. What would be the output of the following program? main() { struct emp { char *n; int age; }; struct emp e1 = { "Dravid", 23}; struct emp e2 = e1; strupr (e2.n); printf ("\n%s",e1.n); }
    • Discuss
    • 4. If the following structure is written to a file using fwrite(), can fread() read it back successfully? struct emp { char *n; int age; }; struct emp e = { "Sujay",15}; FILE *fp; fwrite (&e, sizeof (e), 1, fp);
    • Discuss
    • 5. Point out the error, ifany, in the followingb code? typedef struct { int data; NODEPTR link; } *NODEPTR;
    • Discuss
    • 6. If the following program (myprog) is run from the command line as myprog 1 2 3 what would be the output? main(int argc, char *argv[]) { int i, j = 0; for (i = 0; i < argc ; i++) j = j + atoi ( argv[i]); printf ("%d", j); }

    • Options
    • A. 123
    • B. 6
    • C. Error
    • D. "123"
    • Discuss
    • 7. What would be the output of the following program ? main() { unsigned int a = oxffff; ~a; printf ("%x", a); }

    • Options
    • A. ffff
    • B. 0000
    • C. 00ff
    • D. None of the above
    • Discuss
    • 8. Answer the following Program #define CHARSIZE 8 #define MASK(y) (1 << y % CHARSIZE) #define BITSLOT (y) (y / CHARSIZE) #define SET(x,y) ( x[BITSLOT(y)] = MASK(y) ) #define TEST(x,y) ( x[BITSLOT(y)] & MASK(y) ) #define NUMSLOTS(n) ((n + CHARSIZE - 1) / CHARSIZE) Give the above macros how would you 1. declare an array arr of 50 bits 2. put the 20th bit on 3. test whether the 40th bit is on or off
    • Discuss
    • 9. In the following code can we declare a new typedef name emp even though struct employee has not been completely defined while using typedef? < Yes / No> typedef struct employee *ptr; struct employee { char name[20]; int age; ptr next; };
    • Discuss
    • 10. Improve the following code using typedef. struct node { int data1; float data2; struct node *left; struct node *right; }; struct node *ptr; ptr = (struct node *) malloc (sizeof (struct node) );
    • Discuss


    Comments

    There are no comments.

Enter a new Comment