My C Notes
My C Notes
My C Notes
main()
{
int y,x=5;
y=++x - ++x;
printf("\n%d%d",x,y);
}
a. 7 1 b. 7 -1 c. 7 0 d. 5 1
6. Format specifier %p is used for _______________
a. 0 5 9 13 17
b. 5 9 13 17
c. 12 17 22
d. 16 21
8. What would be the output of the following?
main()
{
int x = 5;
int y = 10;
double z;
z = (double) (5 / 10);
printf("z = %.2f\n", z);
}
a. 1.00
b. 0.50
c. 0.00
d. -0.50
9. What is the output of following program?
main()
{
char x = 0x80;
int y = x;
printf("%d\n", y);
}
a)0
b)128
c)-128
d)Unpredictable
10. What is the output of following program?
#include <stdio.h>
#include <stdio.h>
int main()
{
printf("%c\n", '1' + 1);
return EXIT_SUCCESS;
}
int main()
{
int x = -10;
printf("%d\n", ~x+1);
return EXIT_SUCCESS:
}
a) -11
b) -9
c) 10
d) Size of the integer is required to find out the answer.
12. void main()
{
int const * p=5;
printf("%d",++(*p));
}
13. main()
{
char s[ ]="man";
int i;
for(i=0;s[ i ];i++)
printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
}
14. main()
{
float me = 1.1;
double you = 1.1;
if(me==you)
printf("I love U");
else
printf("I hate U");
}
15. main()
{
static int var = 5;
printf("%d ",var--);
if(var)
main();
}
16. main()
{
int c[ ]={2.8,3.4,4,6.7,5};
int j,*p=c,*q=c;
for(j=0;j<5;j++) {
printf(" %d ",*c);
++q; }
for(j=0;j<5;j++){
printf(" %d ",*p);
++p; }
}
17. main()
{
extern int i;
i=20;
printf("%d",i);
}
18. main()
{
int i=-1,j=-1,k=0,l=2,m;
m=i++&&j++&&k++||l++;
printf("%d %d %d %d %d",i,j,k,l,m);
}
19. main()
{
char *p;
printf("%d %d ",sizeof(*p),sizeof(p));
}
20. main()
{
int i=3;
switch(i)
{
default:printf("zero");
case 1: printf("one");
break;
case 2:printf("two");
break;
case 3: printf("three");
break;
}
}
21. main()
{
printf("%x",-1<<4);
}
22. main()
{
char string[]="Hello World";
display(string);
}
void display(char *string)
{
printf("%s",string);
}
23. main()
{
int c=- -2;
printf("c=%d",c);
}
24. #define int char
main()
{
int i=65;
printf("sizeof(i)=%d",sizeof(i));
}
25. main()
{
int i=10;
i=!i>14;
printf("i=%d",i);
}
26. #include‹stdio.h›
main()
{
char s[]={'a','b','c','\n','c','\0'};
char *p,*str,*str1;
p=&s[3];
str=p;
str1=s;
printf("%d",++*p + ++*str1-32);
}
27. #include‹stdio.h›
main()
{
int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} };
int *p,*q;
p=&a[2][2][2];
*q=***a;
printf("%d----%d",*p,*q);
}
28. main()
{
printf("\nab");
printf("\bsi");
printf("\rha");
}
29. main()
{
int i=5;
printf("%d%d%d%d%d%d",i++,i--,++i,--i,i);
}
30. #define square(x) x*x
main()
{
int i;
i = 64/square(4);
printf("%d",i);
}
31. #define a 10
main()
{
#define a 50
printf("%d",a);
}
32. #define clrscr() 100
main()
{
clrscr();
printf("%d\n",clrscr());
}
33. main()
{
100;
printf("%d\n",100);
}
34. main()
{
printf("%p",main);
}
35. main()
{
int i=400,j=300;
printf("%d..%d");
}
36. void main()
{
int i=5;
printf("%d",i++ + ++i);
}
37. void main()
{
int i=5;
printf("%d",i+++++i);
}
38. #include‹stdio.h›
main()
{
int i=1,j=2;
switch(i)
{
case 1: printf("GOOD");
break;
case j: printf("BAD");
break;
}
}
39. main()
{
int i;
printf("%d",scanf("%d",&i)); // value 10 is given as input here
}
40. main()
{
printf("%d", out);
}
int out=100;
41. main()
{
int i=-1;
+i;
printf("i = %d, +i = %d \n",i,+i);
}
42. main()
{
int a,b;
printf(\"%d\",scanf(\"%d%d\",&a,&b));
}
Answers:
a.2
b.1
c.20,10
d.10,20
43. What will be the output of the below program?
void main()
{
extern int i;
i=20;
printf("%d",i);
}
a) 20
b) Compile time Error
c) i
d) Linker Error - Undefined Symbol '_i'
44. What is the output of the following?
main()
{
int i;
i = 64/square(4);
printf(\"%d\",i);
}
a) 16
b) 4
c) 64
d) error
45. What is the range of "real constants" in 'C'?
a) -3.8 x 10 38 to 3.8 x 10 38
b) -34E37 to 34E37
c) -6.4 x 10 34 to 6.4 x 10 34
d) -68E33 to 68E33
46. How many keywords are there in 'C' ?
a) 24
b) 32
c) 44
d) 52
47. What will be the output of the following statement ?
/* /* printf("hello"); */ */
a) hello
b) no output
c) error
d) "hello"
48. What will be the output of the following statement ?
printf("%i",35,2+8*5%10-2);
a) error
b) 0
c) 35
d) 350
49. What will be the output of the following statement?
a) error
b) 10
c) 10 10
d) none of these
50. What will be the output of the following statement ?
printf("%X%x%ci%x",11,10,'s',12);
a) error
b) basc
c) Bas94c
d) none of these