Вы находитесь на странице: 1из 9

DATATYPES AND FORMAT SPECIFIERS

1. Which of the following is integral data type?

A. void B) char C) float D) double

2. We want to round off x, a float, to an int value, The correct way to do is

A. y = (int)(x + 0.5) B. y = int(x + 0.5)


C. y = (int)x + 0.5 D.y = (int)((int)x + 0.5)

3. By default a real number is treated as a

A. Float B. double
C. long double D.far double

4. A c source file can be


A. compiled only B. interpreted only
C. Both compiled and interpreted D.nothing
5. What is the correct prototype of printf function?

A.printf (char *p,...); B.printf (const *char *p,...);

C.printf (const char *p,...); D.printf (const *char p,...);

6. What is the proto-type of scanf function?


7. What is the output of the given question when input of s is 5?
main ()
{
int s;
s=scanf(“%d”,&s);
printf(“%d”,s);
}
8. main ()
{
Int i=0xffffffff;
Printf(“%d\n”,i);
}
9. main()

Printf (“%%%s”,”hello”);
}
A. %s B. Hello C. %%s D. %hello
10. main ()
{

int x=48;

printf(“x=%s\n”,x);

A. 10 B. 0 C. Run time error D. Compilation error


11. main ()
{

int i= 24;

printf(“%xd”,i);

}
A. 18 B. 24 C. 18d D. Compile time error
12. main ()
{

Int i=10;

Printf(“%d”,j);

Printf(“%d”,i);

}int j=20;

A. J=20,i=10. B. J=junk, i=10. C. Compile time error D. Run time error


13. main ( )
{

Int i,j;

I=06;

J=09;

Printf (“%d\n%d”,i,j);

A. 6 9 B. 6 11 C. 06 09 D. Compilation error
14. main ()
{

Int i=1,2;

Printf(“%d”,i);

}
A. 1 B.2 C. Error D. None

15. . int a=5;

main ()

Printf (“%d”, i);

}int a;

A. 5 B. 6 C. Error D. None
16. main ()

Printf(“%c %s ”,’he’,”hello”);

A. he hello B. hehello C. compile time error D. h hello

17. int main()


{
char num = '\010';
printf("%d", num);
}
18. int main()

int i=43;

printf("%d\n",printf("%d",printf("%d",i)));

}
A. 4321 B.43434 C.4311 D. error
19. main()

Printf(“%c”,’1’+1);

A. 2 B. 49 C. 50 D. Error
20. main ()

int a=5;

Printf (“%d”+1, a);

A. 5 B. compile time error C. 6


21. main ()

#include<stdio.h>

int a =90;

printf(“%d”,a);

A. 90 B. Compilation error C. Linker error D. Run time error


22. main ()

Printf(“%[s]%s”,”hello”);

A. hellohello B. %[s]hello C. %[s]%s D. Run time error

23. int main()


{
void num=10;
printf("%v", num);
}
24. What is the output of the given question when input of s is 5?
main ()
{
int s;
s=scanf(“%d”,&s);
printf(“%d”,s);

25. int main()


{
char num=127;
num=num+1;
Printf(“%d”,num);
}
26. main()
{

float k=3.4156;

printf("%f %f ",floor(k),ceil(k));

27. main()

int number =25;

char name ='A';

printf("The addition of the name and the number is %o ",name+number);

28. main()

printf("%u",main);

} ans: 0

29. main()
{

printf("%p",main);

30. main()

printf("%u",main());

31. main()

printf("%d", sizeof(""));

32. main()

printf("%f %f",floor(-2.8),ceil(-2.8));

33. main()

printf("\%d ", 100);

printf("\\% ");

printf("%% ");

printf("\%%");

34. main()

char c;
int i = 456;

c = i;

printf("%d", c);

}ans: -56

35. main()

int d,a=5,b=3,c=(a,b);

d=(a,b);

printf("%d %d",c,d);

36. main()

int a=5,b=3,c=a,d;

d=(a,b);

printf("%d %d",c,d);

} ans: 5 3

37. main()

int a=5,b=3,c=(a,b),d;

d=(a,b);

printf("%d %d",c,d);

38. main()

int a=5,b=3,c=(a,b),d;
d=a,b;

printf("%d %d",c,d);

39. main()

int z = 4;

printf("%d", printf(" %d %d ", z, z));

40. int a=1;

int ab=4;

int main()

int b=3,a=2;

printf("%i*/%i*/%*/i",a,b,ab);

41. main()

int x;

printf("\n%d",x=0,x=20,x=40);

}ans: 0

42. main()

printf("%u",-1);

43. int main()


{

printf("%d", 5.00);

return 0;

44. main()

int a=5,b=6,c=7;

printf(“%d %d %d”);

printf(“%d%d%d”,a,b,c);

a. Garbage value, garbage value, garbage value.


567
b. 5 6 7
567
c. 7 6 5
567
d. Compiler error

Вам также может понравиться