C Program find Output code snippet SET - 4
| 
   
1. 
 | 
  
   
A short integer is at least 16 bits wide and a long
  integer is at least 32 bits wide. 
 | 
 |||||||
  
 
Workspace 
 | 
 
| 
   
2. 
 | 
  
   
Which of the following correctly shows the hierarchy of arithmetic
  operations in C? 
 | 
 |||||||||||||||
  
 
Workspace 
 | 
 
| 
   
3. 
 | 
  
   
In which order do the following gets evaluated 
  | 
 |||||||||||||||
  
 
Workspace 
 | 
 
| 
   
4. 
 | 
  
   
Associativity has no role to play unless the precedence of operator is
  same. 
 | 
 |||||||
  
 
Workspace 
 | 
 
| 
   
5. 
 | 
  
   
If the binary eauivalent of 5.375 in normalised form is 0100 0000 1010
  1100 0000 0000 0000 0000, what will be the output of the program (on intel
  machine)? 
#include<stdio.h> 
#include<math.h> 
int main() 
{ 
    float a=5.375; 
    char *p; 
    int i; 
    p =
  (char*)&a; 
    for(i=0;
  i<=3; i++) 
        printf("%02x\n", (unsigned char)p[i]); 
    return 0; 
} 
 | 
 |||||||||||||||
  
 
Workspace 
 | 
 
| 
   
6. 
 | 
  
   
A float occupies 4 bytes. If the hexadecimal
  equivalent of these 4 bytes are A, B, C and D, then when this float is
  stored in memory in which of the following order do these bytes gets stored? 
 | 
 |||||||||||||||
  
 
Workspace 
 | 
 
| 
   
7. 
 | 
  
   
What will be the output of the program? 
#include<stdio.h> 
int sumdig(int); 
int main() 
{ 
    int a, b; 
    a =
  sumdig(123); 
    b =
  sumdig(123); 
    printf("%d,
  %d\n", a, b); 
    return 0; 
} 
int sumdig(int n) 
{ 
    int s, d; 
    if(n!=0) 
    { 
        d = n%10; 
        n = n/10; 
        s = d+sumdig(n); 
    } 
    else 
        return 0; 
    return s; 
} 
 | 
 |||||||||||||||
  
 
Workspace 
 | 
 
| 
   
8. 
 | 
  
   
Point out the error in the program 
f(int a, int b) 
{ 
    int a; 
    a = 20; 
    return a; 
} 
 | 
 |||||||||||||||
  
 
Workspace 
 | 
 
| 
   
9. 
 | 
  
   
What will be the output of the program? 
#include<stdio.h> 
#define SQUARE(x) x*x 
int main() 
{ 
    float s=10,
  u=30, t=2, a; 
    a = 2*(s-u*t)/SQUARE(t); 
    printf("Result
  = %f", a); 
    return 0; 
} 
 | 
 |||||||||||||||
  
 
Workspace 
 | 
 
| 
   
10. 
 | 
  
   
Preprocessor directive #undef can be used only on a
  macro that has been #define earlier 
 | 
 |||||||
  
 
Workspace 
 | 
 
| 
   
11. 
 | 
  
   
Which statement will you add to the following program to ensure that
  the program outputs "IndiaBIX" on execution? 
#include<stdio.h> 
int main() 
{ 
    char s[] = "IndiaBIX"; 
    char t[25]; 
    char *ps,
  *pt; 
    ps = s; 
    pt = t; 
    while(*ps) 
        *pt++ = *ps++; 
    /* Add
  a statement here */ 
    printf("%s\n",
  t); 
    return 0; 
} 
 | 
 |||||||||||||||
  
 
Workspace 
 | 
 
| 
   
12. 
 | 
  
   
What will be the output of the program ? 
#include<stdio.h> 
#include<string.h> 
int main() 
{ 
    char str1[20]
  = "Hello",
  str2[20] = "
  World"; 
    printf("%s\n",
  strcpy(str2, strcat(str1, str2))); 
    return 0; 
} 
 | 
 |||||||||||||||
  
 
Workspace 
 | 
 
| 
   
13. 
 | 
  
   
What will be the output of the program ? 
#include<stdio.h> 
int main() 
{ 
    char p[] = "%d\n"; 
    p[1] = 'c'; 
    printf(p, 65); 
    return 0; 
} 
 | 
 |||||||||||||||
  
 
Workspace 
 | 
 
| 
   
14. 
 | 
  
   
What will be the output of the program ? 
#include<stdio.h> 
void swap(char *, char *); 
int main() 
{ 
    char *pstr[2]
  = {"Hello", "IndiaBIX"}; 
    swap(pstr[0],
  pstr[1]); 
    printf("%s\n%s",
  pstr[0], pstr[1]); 
    return 0; 
} 
void swap(char *t1, char *t2) 
{ 
    char *t; 
    t=t1; 
    t1=t2; 
    t2=t; 
} 
 | 
 |||||||||||||||
  
 
Workspace 
 | 
 
| 
   
15. 
 | 
  
   
What will be the output of the program ? 
#include<stdio.h> 
int main() 
{ 
    union var 
    { 
        int a, b; 
    }; 
    union var v; 
    v.a=10; 
    v.b=20; 
    printf("%d\n",
  v.a); 
    return 0; 
} 
 | 
 |||||||||||||||
  
 
Workspace 
 | 
 
| 
   
16. 
 | 
  
   
Nested unions are allowed 
 | 
 |||||||
  
 
Workspace 
 | 
 
| 
   
17. 
 | 
  
   
Can we have an array of bit fields? 
 | 
 |||||||
  
 
Workspace 
 | 
 
| 
   
18. 
 | 
  
   
To scan a and b given below, which
  of the following scanf() statement will you use? 
#include<stdio.h> 
float a; 
double b; 
 | 
 |||||||||||||||
  
 
Workspace 
 | 
 
| 
   
19. 
 | 
  
   
What will be the output of the program? 
#define P printf("%d\n", -1^~0); 
#define M(P) int main()\ 
             {\ 
                P\ 
                return 0;\ 
             } 
M(P) 
 | 
 |||||||||||||||
  
 
Workspace 
 | 
 
| 
   
20. 
 | 
  
   
What will be the output of the program? 
#include<stdio.h> 
int main() 
{ 
    unsigned int res; 
    res =
  (64 >>(2+1-2))
  & (~(1<<2)); 
    printf("%d\n",
  res); 
    return 0; 
} 
 | 
 |||||||||||||||
  
  | 
 
Comments
Post a Comment