Exercise

1. What is the output of this program?

void main()
{
int x = 10;
float x = 10;
printf("%d", x)
}

A. Compilations Error
B. 10
C. 10.0000
D. 10.10

View Answer


2. What is the output of this program?

#include <stdio.h> int main()
{
int i;
for (i = 0;i < 5; i++)
int a = i;
printf("%d", a);
}

A. Syntax error in declaration of a
B. No errors, program will show the output 5
C. Redeclaration of a in same scope throws error
D. a is out of scope when printf is called

View Answer


3. What is the output of this program?

#include <stdio.h>
int var = 20;
int main()
{
int var = var;
printf("%d ", var);
return 0;
}

A. Garbage Value
B. 20
C. Compiler Error
D. None of these

View Answer


4. What is the output of this program?

int main()
{
char ch;
ch = 128;
printf("%d\n", ch);
return 0;
}

A. 128
B. -128
C. Depends on compiler
D. None of the above

View Answer


5. What is the output of this program?

int main()
{
float x = 'a';
printf("%f", x);
return 0;
}

A. a
B. a.000000
C. 97.000000
D. Run time error

View Answer


6. How would you round off a value from 6.66 to 7.0?

A. ceil(6.66)
B. floor(6.66)
C. roundup(6.66)
D. roundto(6.66)

View Answer


7. What will be the output of the program in 16 bit platform ?

#include<stdio.h>
int main()
{
extern int i;
i = 20;
printf("%d\n", sizeof(i));
return 0;
}

A. 2
B. 4
C. 8
D. Linker Error

View Answer


8. What will be output when you will execute following c code?

#include<stdio.h>
int main()
{
printf("%d\t",sizeof(5.5));
printf("%d\t",sizeof(50000));
printf("%d",sizeof('A'));
return 0;
}

A. 4 2 1
B. 8 4 4
C. 8 4 2
D. compiler dependent

View Answer


9. What is the output of this program?

void main()
{
int i=0, j=1, k=2, m;
m = i++ || j++ || k++;
printf("%d %d %d %d", m, i, j, k);
}

A. 1 1 2 3
B. 1 1 2 2
C. 0 1 2 2
D. 0 1 2 3

View Answer


10. What is the output of this program?

void main()
{
int c = - -14;
printf("%d", c);
}

A. 13
B. 14
C. -14
D. Compilation Error

View Answer


11. What is the output of this program?

void main()
{
int i=5;
i = !i>10;
printf("%d", i);
}

A. 5
B. 10
C. 0
D. None of the above

View Answer


12. What is the output of this program?

void main()
{
int p, q, r, s;
p = 1;
q = 2;
r = p, q;
s = (p, q);
printf("p=%d q=%d", p, q);
}

A. p=1 q=1
B. p=1 q=2
C. p=2 q=2
D. Invalid Syntex

View Answer


13. What is the output of this program?

void main()
{
printf("%x",-1<<4);
}

A. fff0
B. fff1
C. fff2
D. fff3

View Answer


14. What is the output of this program?

#include<stdio.h>
void main()
{
int a=1, b=2, c=3, d;
d = (a=c, b+=a, c=a+b+c);
printf("%d %d %d %d", d, a, b, c);
}

A. 11 3 5 11
B. 11 1 5 11
C. 11 3 2 11
D. 11 3 3 11

View Answer


15. What is the output of this program?

void main()
{
int a, b = 5, c;
a = 5 * (b++);
c = 5 * (++b);
printf("%d %d",a,c);
}

A. 30 35
B. 30 30
C. 25 30
D. 25 35

View Answer

16. What is the output of this program?

#include<stdio.h>
int main(){
printf("%d",EOF);
return 0;
}

A. 0
B. 1
C. -1
D. NULL

View Answer


17. What is the output of this program?

#include<stdio.h>
int main(){
char num = '\010';
printf("%d", num);
return 0;
}

A. 010
B. 08
C. 10
D. 8

View Answer


18. What is the output of this program?

#include<stdio.h>
int main(){
void num=10;
printf("%v", num);
return 0;
}

A. Compilation error
B. 10
C. Garbage value
D. 0

View Answer


19. What is the output of this program?

#include<stdio.h>
int main(){
printf("%d\t",sizeof(2.5));
printf("%d\t",sizeof(2));
printf("%d",sizeof('A'));
return 0;
}

A. 8 4 2
B. 8 4 1
C. 4 4 1
D. 2.5 2 A

View Answer


20. What is the output of this program?

#include<stdio.h>
int main(){
signed a;
unsigned b;
a = 6u + -16 + 16u + -6;
b = a + 1;
if(a == b)
printf("%d %d",a,b);
else
printf("%u %u",a, b);
return 0;
}

A. Compilation error
B. 0 0
C. 0 1
D. address address

View Answer



Discussion

* You must be logged in to add comment.