#Include Extern Int Int Do Do While While Return Int
#Include Extern Int Int Do Do While While Return Int
#Include Extern Int Int Do Do While While Return Int
(2)
What will be output of following c code?
#include<stdio.h>
int main(){
int i=2,j=2;
while(i+1?--i:j++)
printf("%d",i);
return 0;
}
(3)
What will be output of following c code?
#include<stdio.h>
int main(){
int x=011,i;
for(i=0;i<x;i+=3){
printf("Start ");
continue;
printf("End");
}
return 0;
}
#include<stdio.h>
int main(){
int i,j;
i=j=2,3;
while(--i&&j++)
printf("%d %d",i,j);
return 0;
}
#include<stdio.h>
int main(){
static int i;
for(++i;++i;++i) {
printf("%d ",i);
if(i==4) break;
}
return 0;
}
(10)
#include<stdio.h>
int main(){
int i;
for(i=0;i<=5;i++);
printf("%d",i)
return 0;
}
1. #include <stdio.h>
2. struct temp
3. {
4. int a;
5. int b;
6. int c;
7. } p[] = {0};
8. main()
9. {
10. printf("%d", sizeof(p));
11. }
a)4
b)12
c)16
d)Can’t be estimated due to ambigous initialization of array
17. What is the output of this C code?
1. #include <stdio.h>
2. struct student
3. {
4. char *name;
5. };
6. struct student s[2];
7. void main()
8. {
9. s[0].name = "alan";
10. s[1] = s[0];
11. printf("%s%s", s[0].name, s[1].name);
12. s[1].name = "turing";
13. printf("%s%s", s[0].name, s[1].name);
14. }
1. #include <stdio.h>
2. struct student
3. {
4. char *name;
5. };
6. struct student s[2], r[2];
7. void main()
8. {
9. s[0].name = "alan";
10. s[1] = s[0];
11. r = s;
12. printf("%s%s", r[0].name, r[1].name);
13. }
a) alan alan
b) Compile time error
c) Varies
d) Nothing
19. What is the output of this C code?
1. #include <stdio.h>
2. struct student
3. {
4. char *name;
5. };
6. void main()
7. {
8. struct student s[2], r[2];
9. s[1] = s[0] = "alan";
10. printf("%s%s", s[0].name, s[1].name);
11. }
a) alan alan
b) Nothing
c) Compile time error
d) Varies
20. What is the output of this C code?
1. #include <stdio.h>
2. struct student
3. {
4. };
5. void main()
6. {
7. struct student s[2];
8. printf("%d", sizeof(s));
9. }
a)2
b)4
c)8
d) 0
1. #include <stdio.h>
2. main()
3. {
4. int a = 1;
5. printf("size of a is %d, ", sizeof(++a));
6. printf("value of a is %d", a);
7. };
a. size of a is 4, value of a is 1
b. size of a is 4, value of a is 2
c. size of a is 2, value of a is 2
d. size of a is 2, value of a is 2
22. Which among the following is right?
a. sizeof(struct stemp*) > sizeof(union utemp*) > sizeof(char *)
b. sizeof(struct stemp*) < sizeof(union utemp*) < sizeof(char *)
c. sizeof(struct stemp*) = sizeof(union utemp*) = sizeof(char *)
d. The order Depends on the compiler
23. Comment on the following C code?
1. #include <stdio.h>
2. printf("%d", sizeof(strlen("HELLOWORLD")));
a. Output, 4
b. Output, 10
c. Output, 16
d. Error, sizeof cannot evaluate size of a function.
1. #include <stdio.h>
2. (sizeof double = 8, float = 4, void = 1)
3. #define PI 3.14
4. int main()
5. {
6. printf("%d", sizeof(PI));
7. }
a. Output is 8
b. Output is 4
c. Output is 1
d. Error, we can’t use sizeof on macro-definitions
1. #include <stdio.h>
2. struct p
3. {
4. int x;
5. char y;
6. };
7. int main()
8. {
9. struct p p1[] = {1, 92, 3, 94, 5, 96};
10. struct p *ptr1 = p1;
11. int x = (sizeof(p1) / 3);
12. if (x == sizeof(int) + sizeof(char))
13. printf("%d\n", ptr1->x);
14. else
15. printf("falsen");
16. }
a)Compiletimeerror
b)1
c)Undefinedbehaviour
d)false
27. What is the output of this C code?
1. #include <stdio.h>
2. struct p
3. {
4. int x;
5. char y;
6. };
7. int main()
8. {
9. struct p p1[] = {1, 92, 3, 94, 5, 96};
10. struct p *ptr1 = p1;
11. int x = (sizeof(p1) / sizeof(ptr1));
12. if (x == 1)
13. printf("%d\n", ptr1->x);
14. else
15. printf("false\n");
16. }
a)Compiletimeerror
b)1
c)false
d)Undefinedbehaviour
28. What is the output of this C code?
1. #include <stdio.h>
2. struct p
3. {
4. int x;
5. char y;
6. };
7. typedef struct p* q*;
8. int main()
9. {
10. struct p p1[] = {1, 92, 3, 94, 5, 96};
11. q ptr1 = p1;
12. printf("%d\n", ptr1->x);
13. }
a)Compiletimeerror
b)1
c)Undefinedbehaviour
d)Segmentationfault
29. What is the output of this C code?
1. #include <stdio.h>
2. struct p
3. {
4. int x;
5. char y;
6. };
7. void foo(struct p* );
8. int main()
9. {
10. typedef struct p* q;
11. struct p p1[] = {1, 92, 3, 94, 5, 96};
12. foo(p1);
13. }
14. void foo(struct p* p1)
15. {
16. q ptr1 = p1;
17. printf("%d\n", ptr1->x);
18. }
a)Compiletimeerror
b)1
c)Segmentationfault
d) Undefined behaviour
1. #include <stdio.h>
2. void main()
3. {
4. char *a[10] = {"hi", "hello", "how"};
5. int i = 0, j = 0;
6. a[0] = "hey";
7. for (i = 0;i < 10; i++)
8. printf("%s\n", a[i]);
9. }
a) hi hello how Segmentation fault
b) hi hello how followed by 7 null values
c) hey hello how Segmentation fault
d) Depends on compiler
31. What is the output of this C code?
1. #include <stdio.h>
2. void main()
3. {
4. char *a[10] = {"hi", "hello", "how"};
5. printf("%d\n", sizeof(a));
6. }
a)10
b)13
c)Runtimeerror
d) 40
1. size of array is = 20
2. size of array is = 40
3. size of array is = 4
4. Error
1. Error
2. 1 3 4 5 6 7 8 9 10 11
3. 1230000000
4. 0000000000
1. Error
2. 10...40
3. 10...300
4. 10....400
1. 12345
2. 10 20 30 40 50
3. 11 22 33 44 55
4. Error