# C Programming and Problem Solving Questions and Answers 161 to 170

## C Programming and Problem Solving

### Questions 161 to 170

 161 In ‘C’ which of the following can be used to create the constants for float values i) Enumerations             ii) const                                                iii) # define (a)  i & ii                 (b)  ii only                (c)  ii & iii                 (d)  i & iii                 (e)  iii only. 162 Choose the correct output for the following given program.        # include        void fun(int a, int b, …)        {               int i=0, *p = &b;               for( printf(“    ”);  i void main() {        int a=5, *pa=&a, b=0, *pb=&b, **ppa=&pa;        pb=pa;        a += *pb += **ppa;        printf(“ %d, ”  “%d, ”  “%d”, *pa, b, **ppa); } (a)  20, 0, 20           (b)  20, 20, 20          (c)  Syntax Error      (d)  0, 20, 0             (e)  0, 20, 20. 165 What is the output of the following program        # include        struct temp {                      int j, i;                      }a;        void fun(struct temp *p)        {               printf(“%d, “, *p);         p++;     printf(“%d”, *p);        }        void main()        {               struct temp *z = &a;               z->i = 1,  z->j = 10;               fun(z);        } (a)  10, 10               (b)  10, 1                 (c)  1, 10                 (d)  0, 10                 (e)  10, 0. 166 What would be the values assigned to a, b, c if the following statement is extended with input data item 123456 scanf(“%d %d %d”, &a, &b, &c ); (a)  a=12, b=34, c=56                                                          (b)  a=123456 and nothing is assigned to b, c              (c)  a=1, b=3, c=5                                  (d)  a, b are not assigned any thing but c=123456          (e)  a=123456, b=0, c=0. 167 If the following loop is implemented then ..                {               static int  x;               do {                      --x;                      printf( “%d”, x++);               }while( x >= 0);        } (a)   The program will not enter in the loop                             (b)  There will be a compilation error reported                        (c)  The loop will run infinitely                  (d)  A run time error will be reported (e)  It prints 0 once and terminates the do – while loop successfully. 168 The expression (( fileptr = fopen(“somefile”, “w”)) == NULL ) would be true if (a)  The file somefile is read only           (b)  May be the fileptr is not declared as a FILE pointer          (c)  The file somefile does not exist while fopen function is being executed          (d)  The file somefile could  not be created for writing            (e)  Both (b) and (c) above. 169 The given statement  FILE *fptr; (a)  Defines a pointer to the pre-defined structure type FILE (b)  Defines a pointer to the user-defined structure type FILE (c)  Defines a pointer to the pre-defined data type FILE DESCRIPTOR (d)  Creates a file with the name fptr (e)  Creates a file pointed by fptr. 170 The getchar() library function (a)   Returns a character when any key is pressed (b)   Returns multiple characters when the keys are pressed (c)   Returns multiple characters when the keys are pressed followed by enter key (d)   Both (b) and (c) above (e)   Returns a single character when the keys are pressed followed by enter key.