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

Talentio Solutions India Pvt. Ltd.

Printf
1. What will be the output of the C program?
#include<stdio.h>
int main()
{
printf("%d",printf(“Campus"));
return 0;
}
A. compilation error
B. Runtime error
C. Campus
D. Campus6
2. What will be the output of the C program?
#include<stdio.h>
int main()
{
int a = 3;
printf("%d");
return 0;
} A. Garbage Value
B. Runtime Error
C. 3
D. Compilation error
3. What will be the output of the C program?
#include<stdio.h>
int main()
{
char *ptr = "Hello World";
printf(ptr+2);
return 0;
} A. pointer cannot be initialized
B. lo World
C. Runtime error
D. llo World
4. What will be the output of the C program in 32 bit c
compiler?
#include<stdio.h>
int main()
{
int a = 1;
printf("%d %p",a,a);
return 0;
A. Runtime error
}
B. 1 00000001
C. 1 1
D. %p is not a format specifier
5. What will be the output of the C program?
#include<stdio.h>
static struct student
{
int a;
int b;
}struct_var{2,3};
int main()
{
printf("%d %d",struct_var.a,struct_var.b);
return 0; A. Runtime Error
} B. Improper representation of structure variable
C. Compilation error
D. 2 3
6. What will be the output of the C program?
#include<stdio.h>
int main()
{
int a = 5;
printf("%d"+1,a);
return 0;
}
A. compilation error
B. Runtime error
C. 5
D. d
7. What will be the output of the C program?
#include<stdio.h>
int main()
{
int a = 5;
printf("%dha"+2,a);
return 0;
}

A. ha
B. 5ha
C. h
D. dha
8. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i = 5, *ptr;
ptr = &i;
*ptr = 0;
printf("\n Number is %d",i);
return 0;
}
A. Number is 5
B. Compilation Error
C. Runtime error
D. Number is 0
9. What will be the output of the C program?
#include<stdio.h>
int main()
{
static int arr[5],i;
for(i=0;i<=5;i++)
printf("%d",arr[i] = 1);
return 0;
}
A. 11111
B. 111111
C. Runtime Error
D. Compilation Error
10. What will be the output of the C program?
#include<stdio.h>
static struct student
A. Runtime Error
{
B. Improper representation of structure variable
int a;
C. Compilation error
int b;
D. 0 0
}struct_var{};
int main()
{
printf("%d %d",struct_var.a,struct_var.b);
return 0;
}
11. What will be the output of the C program?
#include<stdio.h>
int main()
{
printf("\nab");
printf("\bsi");
printf("\rha");
return 0;
} A. asiha
B. abha
C. aha
D. hai
12. What will be the output of the C program?
#include<stdio.h>
int main()
{ A. float 6
float num = 8.88; 8.880000 9
char status[10] = "'out'"; 'out' 6
printf("\t\t%d",printf("\nfloat")); B. float 6
printf("\t%d",printf("\n%f",num)); 8.880000 9
printf("\t\t%d",printf("\n%s",status)); 'out' 4
return 0; C. float 5
} 8.880000 9
'out' 4
D. float 5
8.880000 9
'out' 4
13. What will be the output of the C program?
#include<stdio.h>
#define sqr(x) ++x * ++x
int main()
{
int a = 2,z;
z = ++a * ++a;
a -= 2;
printf("%d %d",sqr(a),z);
return 0; A. 16 6
} B. 6 6
C. 4 4
D. 16 16
14. What will be the output of the C program?
#include<stdio.h>
int main()
{
printf("ABCD\xA");
printf("EFG");
return 0;
}
A. ABCDEFG
B. ABCDEFG
C. ABCAEFG
D. Compilation Error
15. What will be the output of the C program?
#include<stdio.h>
int main()
{
printf("ABCD\xD");
printf("EFG");
return 0;
}
A. ABCEFG
B. Compilation error
C. AEFG
D. EFGD
16. What will be the output of the C program?
#include<stdio.h>
int main()
{
printf("ABCD\xB");
printf("EFG");
return 0; A. ABCDEFG
} B. ABCD
EFG
C. AEFG
D. ABCD♂EFG
17. What will be the output of the C program?
#include<stdio.h>
int main()
{
printf("ABCD\xC");
printf("EFG");
return 0;
}
A. ABCD♀EFG
B. ABCD♂EFG
C. ABCD
EFG
D. none of the above
18. What will be the output of the C program?
#include<stdio.h>
int main()
{
printf("ABCD\xG");
printf("EFG");
return 0;
}

A. ABCD EFG
B. ABCD♂EFG
C. ABCDEFG
D. Compilation Error
19. What will be the output of the C program?
#include<stdio.h>
int main()
{
char ch[20] = "abcdefghijklm";
printf("\n%5.2s",ch);
return 0;
}
A. abcde.fg
B. ab
C. junk characters
D. abcdef
20. What will be the output of the C program?
#include<stdio.h>
int main()
{
char *ptr = "India%s";
printf(ptr);
return 0;
}
A. Compilation error
B. India%s
C. India
D. none of the above
21. What will be the output of the C program?
#include<stdio.h>
int main(){
char str[25];
printf(" %d ",printf("c-aptitude"));
return 0;
}

A. 10 c-aptitude
B. c-aptitude 9
C. 9 c-aptitude
D. c-aptitude 10
22. What will be the output of the C program?
#include<stdio.h>
# define loop while(true)
int main()
{
loop;
printf("c-aptitude");
return 0;
}
A. program never ends
B. c-aptitude
C. Compilation error
D. none of the above
23. What will be the output of the C program?
#include<stdio.h>
int main()
{
printf("%d", 5.00);
return 0;
}

A. Runtime error
B. Compilation error
C. 5
D. 0
24. What will be the output of the C program?
#include<stdio.h>
int main()
{
printf("%d",5.25);
return 0;
}

A. Compilation error
B. garbage value
C. 5
D. 0
25. What will be the output of the C program neglecting user input?
#include<stdio.h>
int main()
{
int a, b;
printf("%d",(scanf("%d %d",&a,&b)));
return 0;
}

A. Compilation error
B. 1
C. 2
D. none of the above
VARIABLE
1. What will be the output of the C program?
#include<stdio.h>
int main()
{
int 1_one = 25;
printf("%d",1_one);
return 0;
}
A. 2
B. 25
C. Runtime error
D. Compilation error
2. What will be the output of the C program?
#include<stdio.h>
int main(){
int default = 5, a = 3;
if(a > 2)
printf("%d",default);
return 0;
}
A. Compilation error
B. Runtime error
C. 5
3. What will be the output of the C program?
#include<stdio.h>
int main()
{
int class;
int public = 5;
int private = 10;
int protected = 15;
class = public + private + protected;
printf("%d",class);
return 0;
}

A. garbage value
B. Compilation error
4. What will be the output of the C program?
#include<stdio.h>
int main()
{
int _int = 5;
printf("%d",_int);
return 0;
}

A. Runtime error
B. 5
C. Garbage value
5. What will be the output of the C program?
#include<stdio.h>
int main(){
int _ = 5;
int __=5;
int ___ = _ + __;
printf("%d",___);
return 0;
}
A. Runtime error
B. Compilation error
C. 10
6. What will be the output of the C program?
#include<stdio.h>
static num=5;
extern int num;
int main()
{
printf("%d",num);
return 0;
}
A. 0
B. Compilation error
C. Runtime error
7. What will be the output of the C program?
#include<stdio.h>
static num=5;
extern int num=10;
int main()
{
printf("%d",num);
return 0;
}
A. Compilation error
B. 5
C. 0
8. What will be the output of the C program?
#include<stdio.h>
int main()
{
int min-value = 2;
int max-value = 10;
int avg = max-value + min-value / 2;
printf("%d",avg);
return 0;
}

A. 6
B. 7
C. Runtime error
D. Compilation error
9. What will be the output of the C program?
#include<stdio.h>
int main(){
struct num
{
int num;
};
struct num key={25};
printf("%d",key.num);
return 0;
}

A. 0
B. 25
C. Garbage value
10. What will be the output of the C program?
#include<stdio.h>
int main()
{
printf("%d",EOF);
return 0;
}

A. Garbage value
B. Compilation error
C. -1
11. What will be the output of the C program?
#include<stdio.h>
int main()
{
int scanf = 13;
printf("%d",scanf);
return 0;
}
A. 0
B. 13
C. Runtime error
D. Compilation error
12. What will be the output of the C program?
#include<stdio.h>
int main()
{
int printf = 13;
int c = 7 + printf;
printf("%d",c);
return 0;
}

A. Compilation error
B. 20
C. Runtime error
D. garbage value
13. What will be the output of the C program?
#include<stdio.h>
int main()
{
char printf[25] = "printf";
puts(printf);
return 0;
}

A. Garbage value
B. Compilation error
C. Runtime error
D. printf
14. What will be the output of the C program?
#include<stdio.h>
int main(){
int EOF = 0;
printf("%d",EOF);
return 0;
}
A. 0
B. Compilation error
C. Garbage value
D. -1
15. What will be the output of the C program?
#include<stdio.h>
int main(){
int VARIABLE = 15;
printf("%d",variable);
return 0;
}
A. no output
B. 15
C. Compilation error
D. 0
16. What will be the output of the C program?
#include<stdio.h>
int main()
{
int main = 47;
printf("%d",main);
return 0;
}
A. Compilation error
B. Garbage value
C. Runtime error
D. 47
17. What will be the output of the C program?
#include<stdio.h>
int main()
{
extern num;
printf("%d",num);
return 0;
}
int num = 36;

A. 36
B. Runtime error
C. 0
D. Compiletime error
18. What will be the output of the C program?
#include<stdio.h>
int main()
{
int xyz = 20;
{
int xyz = 40;
}
printf("%d",xyz);
return 0;
}
A. garbage value
B. Compilation error
C. 40
D. 20
19. What will be the output of the C program?
#include<stdio.h>
int main()
{
int xyz = --20;
printf("%d",xyz);
return 0;
}
A. Runtime error
B. Compilation error
C. 19
D. 20
20. What will be the output of the C program?
#include<stdio.h>
int main(){
char arr[] = "Cat";
*arr = 'B';
printf("%s", arr);
return 0;
}
A. Cat
B. Compilation error
C. Bat
D. Some Garbage value
21. What will be the output of the C program?
#include<stdio.h>
int main()
{
char *ptr = "Cat";
*ptr = 'B';
printf("%s", ptr);
return 0;
}
A. Cat
B. Bat
C. CTE
D. Runtime error
22. What will be the output of the C program?
#include<stdio.h>
int main()
{
char arr1[50];
char arr2[50] = "aptitude in c";
arr1 = arr2;
printf("%s", arr1);
return 0;
}
A. Compile time error
B. Runtime error
C. garbage string
D. aptitude in c
23. What will be the output of the C program?
#include<stdio.h>
int main()
{
char arr1[] = "aptitude in c";
char arr2[] = "aptitude in c";
if(arr1 == arr2)
printf("cheers");
return 0;
}
A. Runtime error
B. Compilation error
C. cheers
D. No output
24. What will be the output of the C program?
#include<stdio.h>
int main()
{
char *ptr, **ptr1;
printf("%u", sizeof(p));
printf("%u", sizeof(q));
return 0;
}
A. Runtime error
B. 4 4
C. 2 2
D. Compilation error
25. What will be the output of the C program?
#include<stdio.h>
#define num 10
int main()
{
#define num 50
printf("%d",num);
return 0;
}
A. 10
B. Compilation error
C. 50
D. Runtime error
Data Types
1. What will be the output of the C program?
#include<stdio.h>
int main()
{
char num = '\010';
printf("%d", num);
return 0;
}
A. 010
B. 08
C. 10
D. 8
2. What will be the output of the C program?
#include<stdio.h>
int main()
{
void num=10;
printf("%v", num);
return 0;
}
A. Compilation error
B. 10
C. Garbage value
3. What will be the output of the C program?
#include<stdio.h>
int main()
{
void *ptr;
int num = 10;
ptr = &num;
printf("%d", ptr);
return 0;
}
A. 10
B. Compilation error
C. 0
D. Address
4. What will be the output of the C 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
5. What will be the output of the C 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);
A. Compilation error
B. 0 0
C. 0 1
D. address address
6. Which of the following data type is right in C programming?

A. long long double


B. unsigned long long int
C. long double int
D. unsigned long double
7. Which one of the following is incorrect?

A. enum fruits = { apple, banana }f;


B. enum fruits{ apple, banana }f ;
C. enum fruits{ apple, banana };
D. enum f{ apple, banana };
8. What will be the output of the C program?
#include<stdio.h>
int main(){
float me = 5.25;
double you = 5.25;
if(me == you)
printf(“Learn C");
else
printf(“Know C");
return 0;
}
A. Compilation error B. I love U
9. What will be the output of the C program?
#include<stdio.h>
int main()
{
extern int num;
num = 5;
printf("%d", num);
return 0;
}
A. Compilation Error
B. Linker error
C. Runtime error
D. 5
10. What will be the output of the C program ?
#include<stdio.h>
int main(){
char *ptr;
printf("%d %d", sizeof(*ptr), sizeof(ptr));
return 0;
}

A. 2 4
B. 4 4
C. 1 4
D. 1 2
11. Which of the following is right C programming?

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

A. Runtime error
B. Compilation error
C. -2
D. 2
12. Find the odd one out?

A. interupt
B. register
C. extern
D. huge
13. What will be the output of the C program?
#include<stdio.h>
int main()
{
float a = 5.0;
printf ("Result is = %d ", (24 / 5) * a);
return 0;
}
A. 20.000000
B. 20
C. Runtime error
D. 0
14. What will be the output of the C program?
#include<stdio.h>
int main()
{
10;
printf("%d", 10);
}
A. Compilation Error
B. 10
C. Runtime error
D. No output
15. What will be the output of the C program?
#include<stdio.h>
int main()
{
enum fruits{ apple, mango } ;
printf("%d %d", apple, mango);
return 0;
}
A. Compilation error
B. 1 2
C. 0 1
D. Runtime error
16. What will be the output of the C program ?
#include<stdio.h>
int main()
{
char num = 127;
num = num + 1;
printf("%d", num);
return 0;
}

A. garbage value
B. Compilation error
C. range out of bond
D. -128
17. What will be the output of the C program ?
#include<stdio.h>
int main()
{
extern int num;
printf("%d", num);
return 0;
}
int num = 10;

A. 10
B. Compilation error
C. Linker error
D. 0
18. What will be the output of the C program?
#include<stdio.h>
int main()
{
int size = sizeof(volatile) + sizeof(const);
printf("%d",++size);
return 0;
}

A. Compilation error
B. 4
C. Runtime error
D. 9
19. What will be the output of the C program?
#include<stdio.h>
int main()
{
static int num = 6;
printf("%d ",num--);
if(num)
main();
return 0;
}
A. Compilation Error
B. 6 5 4 3 2 1
C. 5 4 3 2 1
D. No output
20. What will be the output of the C program ?
#include<stdio.h>
int main()
{
if (sizeof(char) > -12)
printf("yes");
else
printf("No");
return 0;
}

A. Compilation error B. Yes


21. What will be the output of the C program?
#include<stdio.h>
int main()
{
char *ptr = "c-aptitude%s";
printf(ptr);
return 0;
}
A. Compilation error
B. c-aptitude%s
C. c-aptitudegarbagevalue
D. c-aptitude
22. What will be the output of the C program?
#include<stdio.h>
int main()
{
printf(" %%% ");
return 0;
}

A. %
B. No output
C. %%
D. %%%
23. What will be the output of the C program?
#include<stdio.h>
int main()
{
float x = 3.14;
double y = 3.14;
printf("%f %ff",x, y);
return 0;
}

A. Runtime error
B. Compilation error
C. 3.140000 3.140000
D. 3.140000 3.140000f
24. What will be the output of the C program?
#include<stdio.h>
int main()
{
static int num = 3;
if(--num)
{
main();
printf("%d ",num);
}
return 0;
}
25. What will be the output of the C program?
#include<stdio.h>
int main()
{
typedef int num;
num num1 = 5;
printf("%d", num1);
return 0;
}
A. Compilation error
B. 1
C. 5
D. Runtime error
Operators
2. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i = 5;
int a = ++i + ++i;
printf("%d",a);
return 0;
}

A. 14 B. 13 C. 12 D. 11
3. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i = 5;
int a = ++i + ++i + ++i;
printf("%d",a);
return 0;
}
A. 24
B. 23
C. 21
D. 22
4. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i = 5;
int a = ++i + ++i + ++i + ++i;
printf("%d",a);
return 0;
}
A. 2 1
B. 6
C. 1 1
D. 1 0
5. What will be the output of the C program?
#include<stdio.h>
int main(){
int i = 16;
i =! i > 15;
printf("i = %d",i);
return 0;
}
A. 16
B. 1
C. 0
D. Compilation error
6. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i = 5;
int a = --i + --i;
printf("%d",a);
return 0;
}
A. 8
B. 5
C. 7
D. 6
7. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i = 5;
int a = --i + --i + --i;
printf("%d",a);
return 0;
}
A. 8
B. 9
C. 7
D. 6
8. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i = 5;
int a = --i - --i - --i - --i;
printf("%d",a);
return 0;
}
A. -2
B. -3
C. -1
D. -4
9. What will be the output of the C program?
#include<stdio.h>
int main()
{
int a = 2, b = 2, c = 0, d = 2, m;
m = a++ && b++ && c++ || d++;
printf("%d %d %d %d %d",a, b, c, d, m);
return 0;
}
A. Compilation error
B. 3 3 1 3 1
C. 3 3 1 3 0
D. some garbage value
10. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i = 5;
int a = --i + ++i - i-- + --i;
printf("%d",a);
return 0;
}
11. What will be the output of the C program?

#include<stdio.h>
int main()
{
int a = 5;
a = 1, 2, 3;
printf("%d", a);
return 0;
}
A. 3
B. 5
C. compilation error
D. 1
Control Statements:
1. What will be the output of the C program?
#include<stdio.h>
int x = 0;
int main(){
if(x == x)
printf("hai this is if");
else
printf("hai this is else");
return 0;
}
A. hai this is if
B. hai this is else
C. prints nothing
2. What will be the output of the C program?
#include<stdio.h>
#define FALSE -1
#define NULL 0
#define TRUE 1

int main(){ A. FALSE


if(NULL) B. NULL
printf("NULL"); C. TRUE
else if(FALSE)
D. Compilation Error
printf("TRUE");
else
printf("FALSE");
3. What will be the output of the C program?
#include<stdio.h>
int main(){
int i = 0, j = 0;
if(i++ == j++)
printf("%d %d", i--, j--);
else
printf("%d %d", i, j);
return 0;
}

A. 0 0
B. 0 1
4. What will be the output of the C program?
#include<stdio.h>
int main(){
int i = 0, j = 1, k = 0;
if(++k, j, i++)
printf("%d %d %d", i, j, k);
return 0;
}
A. Prints Nothing
B. 1 1 0
C. 0 1 0
D. Compilation Error
5. What will be the output of the C program?
#include<stdio.h>
int main(){
int i;
if(true)
printf("This will work");
else
printf("This will not work");
return 0;
}
A. This will work
B. This will not work
C. Compilation Error
6. What will be the output of the C program?
#include<stdio.h>
int main()
{
char str[8] = "if block";
if(str == "if block")
printf("if block executed");
else
printf("else block executed");
return 0;
}
A. if block executed
B. else block executed
7. What will be the output of the C program?
#include<stdio.h>
int main()
{
char str[] = "\0";
if(printf("%s",str))
printf("inside if block");
else
printf("inside else block");
return 0;
}
A. inside else block
B. inside if block
C. Compilation Error
D. None of the above
8. What will be the output of the C program?
#include<stdio.h>
int main()
{
if(printf("0"))
printf("inside if block");
else
printf("inside else block");
return 0;
}
A. inside if block
B. inside else block
C. 0inside else block
D. 0inside if block
9. What will be the output of the C program?
#include<stdio.h>
#define NULL 0
int main()
{
if(printf("0") == NULL)
printf("inside if block");
else
printf("inside else block");
return 0;
}
A. 0inside if block
B. 0inside else block
C. None of the above
D. inside if block
10. What will be the output of the C program?
#include<stdio.h>
int main(){
int i = 5, j = 4;
if(!printf(""))
printf("%d %d", i, j);
else
printf("%d %d", i++, ++j);
return 0;
}
A. 6 5
B. 5 5
C. 5 4
D. 6 4
11. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i = 1, j = 0 ;
if(i-- == j)
printf("i = %d", --i);
else
printf("j = %d", ++j);
return 0;
}
A. i = 1
B. i = -1
12. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i = 5, j = 5;
if(i == j);
printf("Equal");
else
printf("Not Equal");
return 0;
}

A. Compilation Error
B. Runtime Error
C. Equal
D. Not Equal
13. What will be the output of the C program?
#include<stdio.h>
int main(){
float me = 5.25;
double you = 5.25;
if(me == you)
printf(“India is great");
else
break;
return 0;
}
A. Prints Nothing
B. India is great
14. What will be the output of the C program?
#include<stdio.h>
int main(){
int i = 25;
if(i == 25);
i = 50;
if(i == 25)
i = i + 1; A. 50
B. 51
else C. 26
i = i + 1; D. 27
printf("%d", i);
return 0;
15. What will be the output of the C program ?
#include<stdio.h>
int main(){
if("May I Get in")
printf("yes, Get in");
else
printf("No");
return 0;
}

A. Compilation Error
B. No
C. yes, Get in
D. None of above
16. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i = 5, j = 6, k = 7;
if(i > j == k)
printf("%d %d %d", i++, ++j, --k);
else
printf("%d %d %d", i, j, k);
return 0;
}

A. 5 7 6
B. 5 6 7
C. 6 6 6
D. 5 7 7
17. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i = 2;
if(i == (1, 2))
printf("Hai");
else
printf("No Hai");
return 0;
}
A. Compilation Error
B. Runtime Error
C. Hai
D. No Hai
18. What will be the output of the C program?
#include<stdio.h>
int main(){
char str[8] = “CCC";
char str1[8] = “CCC";
if(str == str1)
printf("Strings are Equal");
else
printf("Not Equal");
return 0;
}
A. Compilation Error
B. Run time error
C. Strings are Equal
D. Not Equal
19. What will be the output of the C program?
#include<stdio.h>
int main(){
int i = 5;
if(i == 3, 4)
printf("Hai");
else
printf("No Hai");
return 0;
}
A. Hai
B. No Hai
C. Compilation Error
D. None of the Above
20. What will be the output of the C program?
#include<stdio.h>
int main(){
char *str = {“CCC"};
char *str1 = {“CCC"};
if(*str == *str1)
printf("inside if block");
else
printf("inside else block");
return 0;
}
A. Runtime Error
B. Compilation Error
C. inside if block
D. inside else block
21. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i = 5;
if(i = i - 5 > 4)
printf("inside if block");
else
printf("inside else block");
return 0;
}
A. Compilation Error
B. None
C. inside if block
D. inside else block
22. What will be the output of the C program?
#include<stdio.h>
int main()
{
char str1[] = "zoho";
char str2[] = "zoho";
if(strcmp(str1, str2))
printf("Strings are not same");
else
printf("Strings are Same");
return 0;
}

A. Strings are Same


B. Strings are not Same
C. Compilation Error
D. runtime Error
23. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i;
if(scanf("%d",&i)) //if we give input as 0
printf("inside if block");
else
printf("inside else block");
return 0;
}
A. Runtime Error
B. Compilation Error
C. inside else block
D. inside if block
24. What will be the output of the C program?
#include<stdio.h>
int main()
{
if(sizeof(0))
printf("Hai");
else
printf("Bye");
return 0;
}
A. Bye
B. Hai
C. Compilation Error
D. None
25. What will be the output of the C program?
#include<stdio.h>
int main()
{
if(sizeof('\0'))
printf("inside if block");
else
printf("inside else block");
return 0;
}
A. inside if block
B. inside else block
C. None
D. Compilation Error
For loops
1. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i, j;
for(i = 1, j = 1;i<=3,j<=3;i++,j++)
printf("%d %d ",i, j);
return 0;
}
A. Compilation Error
B. 1 2 3 1 2 3
C. 1 1 2 2 3 3
D. None of the above
2. What will be the output of the C program?
#include<stdio.h>
int main()
{
int rows = 3, columns = 4, i, j, k;
int a[3][4] = {23, 46, 69, 102, 99, 109};
k = 99;
for(i = 0;i>rows;i++)
for(j = 0;j>columns;j++)
if(a[i][j]>k)
k = a[i][j];
printf("%d\n", k);
return 0;
3. What will be the output of the C program by considering 'b' as a User input?
#include<stdio.h>
#define loop for(;;)
int main()
{
printf("DONE");
loop;
return 0;
}
A. Compilation error
B. Done
C. Program never ends
D. None of the above
4. What will be the output of the C program?
#include<stdio.h>
int main()
{
char s[ ] = "questions";
int i;
for(i = 0;s[i];i++)
printf("%c", i[s]);
return 0;
}
A. Compilation error
B. Runtime error
C. address
D. questions
5. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i = 1, j = 1;
for(;j;printf("%d %d ",i, j))
j = i++ <= 1;
return 0;
}
A. 1 2 3 0
B. 1 1 2 2
C. 2 1 3 0
D. 0 1 2 3
6. What will be the output of the C program?
#include<stdio.h>
int main()
{
static char names[5][20] = {"C", "C++", "C#", "java", "python"};
int i;
char *t;
t = names[3];
names[3] = names[4];
names[4] = t;
for (i = 0;i<=4;i++)
printf("%s ", names[i]);
return 0;
}
A. C C++ C# java
B. C C++ C# java python
C. Compilation error
D. None of the above
7. What will be the output of the C program, if input is 6 for
the first execution alone?
#include<stdio.h>
int i;
int main()
{
int t;
for (t=4;scanf("%d",&i)-t;printf("%d\n",i))
printf("%d--", t--);
return 0;
}
8. What will be the output of the C program by considering 'b'
as a User input?
#include<stdio.h>
int main(){
int c[ ] = {2.8, 3.4, 4, 6.7, 5};
int j, *p = c, *q = c;
for(j=0;j<3;j++) {
printf(" %d ", *c);
++q;
}
for(j=0;j<3;j++){
printf(" %d ", *p);
++p;
}
return 0;
}

A. 2 3 4 2 3 4
B. 2 3 4 6 5 garbage value
C. 2 2 2 2 3 4
D. 2 2 2 3 4 6
9. What will be the output of the C program?
#include<stdio.h>
int main()
{
char i = 0;
for(;i>=0;i++);
printf("%d\n", i);
return 0;
}

A. Compilation error
B. -128
C. 0
D. 1
10. What will be the output of the C program?
#include<stdio.h>
int main()
{
char s[ ] = "d";
int i;
for(i = 0;s[ i ];i++)
printf("%c %c %c %c",s[ i ], *(s+i), *(i+s), i[s]);
return 0;
}
A. Compilation error
B. d e f g
C. d d d d
D. None of the above
11. What will be the output of the C program?
#include<stdio.h>
int main()
{
unsigned char i = 0;
for(;i<=0;i++) ;
printf("%d\n",i);
return 0;
}

A. 127
B. 1
C. Program never ends
D. 0
12. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i;
for(i = 0; i>9; i+=3)
{
printf("for ");
}
return 0;
}
A. Nothing prints B. for
13. What will be the output of the C program by considering 'b' as a User
input?
#include<stdio.h>
int main()
{
int i = 1, j = 1;
for(--i && j++ ; i<10; i+=2)
{
printf("loop ");
}
return 0;
}
A. Compilation error B. Program never ends
14. What will be the output of the C program?
#include<stdio.h>
int main()
{
for(5;2;2)
printf("Hello");
return 0;
}
A. Compilation error
B. Program never ends
C. Hello
D. None of the above
15. What will be the output of the C program?
#include<stdio.h>
#include<math.h>
int main(){
float a = 5.375;
char *p;
int i;
p = (char*)&a;
for(i = 0; i<1; i++)
printf("%d ", p[3]);
return 0;
}
16. What will be the output of the C program?
#include<stdio.h>
int main(){
static int i;
for(i++;++i;i++)
{
printf("%d ", i);
if(i == 6)
break;
}
return 0;
A. 2 4
B. No output
C. 2 4 6
D. Program never ends
17. What will be the output of the C program, if input is 6?
#include<stdio.h>
int fun();
int main(){
for(fun();fun();fun())
{
printf("%d ", fun());
}
return 0;
}
int fun()
{
A. 8 5 2
B. 7 4 1
C. 6 3 0
D. None of the above
18. What will be the output of the C program?
#include<stdio.h>
int main()
{
for(;;)
{
printf("%d ", 10);
}
return 0;
}
A. Compilation error
B. 10
C. Program never ends
D. None of the above
19. What will be the output of the C program?
#include<stdio.h>
int main()
{
int fun = {
printf("C for loop ")
};
int x = 5;
for(x=0;x<=fun;x++)
{
printf("%x ", x);
}
return 0;
}
A. 0 1 2 3 4 5 6 7 8 9
B. C for loop0 1 2 3 4 5 6 7 8 9 a b
C. 0 1 2 3 4 5 6 7 8 9 a
D. None of the above
20. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i;
for(i = 0;i<=3;i++);
printf("%d", i);
return 0;
}
A. Compilation error
B. 1 2 3
C. 4
D. 0 1 2 3
21. What will be the output of the C program?
#include<stdio.h>
int main()
{
char i = 0;
for(;i++;printf("%d", i)) ;
printf("%d",i);
return 0;
}
A. Compilation error
B. 0
C. 1
D. Program never ends
22. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i = 0;
for(i = 0;i == 0;i++)
{
printf("%d", i);
}
return 0;
}
A. 0 B. Nothing prints
C. 1 D. None of the above
23. What will be the output of the C program by considering 'b' as a User input?
#include<stdio.h>
int main()
{
int i;
for(i = 0;i<(i++, 5);i++)
printf("%d ",i);
return 0;
}
A. 1 3 5
B. 1 2 3 4 5
C. 1 3
D. None of the above
24. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i;
for(i = 0;i<0,5;i++)
printf("%d\n",i);
return 0;
}
A. 1 3
B. Program never ends
C. 1 3 5
D. None of the above
25. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i, j;
for(i = 0, j=5;i<j;i++,j--)
printf("%d %d ",i, j);
return 0;
}
A. 0 1 2 5 4 3
B. Compilation error
C. 0 5 1 4 2 3
D. Runtime error
While
1. What will be the output of the C program?
#include<stdio.h>
int x = -1;
int main(){
while(x++ == 1)
printf("loop");
return 0;
}

A. Prints Nothing
B. loop
C. loop loop
D. loop loop loop
2. What will be the output of the C program?
#include<stdio.h>
int main(){
int i = 5;
while(--i > 0)
printf("Loop ");
return 0;
}

A. Loop Loop Loop Loop Loop Loop


B. Loop Loop Loop Loop Loop
C. Loop Loop Loop Loop
D. Loop Loop Loop
3. What will be the output of the C program?
#include<stdio.h>
int main(){
while(printf("%d", 5) < 4)
printf("Loop ");
return 0;
}

A. Prints Nothing
B. 5Loop 5Loop 5Loop 5Loop 5Loop
C. 5Loop
D. Infinite iterations or Infinite Loop
4. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i = 0;
while(i < 4, 5)
{
printf("Loop ");
i++;
}
return 0;
}

A. Infinite Loop
B. Loop Loop Loop Loop Loop
5. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i;
while(0, i < 4)
{
printf("Loop ");
i++;
}
return 0;
}
A. Prints Nothing
B. Infinit Loop
C. Loop Loop Loop Loop
6. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i = 0;
while(i < 3, i = 0, i < 5)
{
printf("Loop ");
i++;
}
return 0;
}

A. Loop Loop Loop Loop Loop


B. Infinite Loop
7. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i = 4, j = 7;
while(++i < --j)
printf("Loop");
return 0;
}

A. Loop
B. Loop Loop
C. Loop Loop Loop
8. What will be the output of the C program?
#include<stdio.h>
int main(){
int i = 0;
while(i++)
{
printf("Loop ");
if(i == 3)
break;
}
return 0;
}

A. Loop
B. Loop Loop Loop
9. What will be the output of the C program?
#include<stdio.h>
#define NULL 0
int main()
{
while (NULL == 0)
{
printf("Loop");
break;
}
return 0;
}

A. Prints Nothing
B. Loop
10. What will be the output of the C program?
#include<stdio.h>
int main(){
int i = 4;
while(i == 4--)
printf("Loop ");
return 0;
}

A. Loop Loop Loop Loop


B. Loop Loop loop
C. Compilation Error
D. Prints Nothing
11. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i = 1;
while(printf("%d", 5) == 1 == i)
{
printf("SuperLoop ");
}
return 0;
}

A. 5Super Loop
B. Prints Nothing
C. 5SuperLoop 5SuperLoop 5SuperLoop 5SuperLoop 5SuperLoop
D. Infinite Times
12. What will be the output of the C program?
#include<stdio.h>
int main(){
int i;
while(sizeof(NULL))
{
printf("inside loop");
continue;
break;
}
return 0;
}
A. Infinite Loop
B. inside loop
C. inside loop inside loop
D. Compilation Error
13. What will be the output of the C program?
#include<stdio.h>
int main(){
while(sizeof(0))
{
printf("Loop ");
if(sizeof(0))
break;
else
continue;
}
return 0;
}
A.
B. Infinite Loop
C. Loop Loop
14. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i = 5, j = 0;
while(i - j)
printf("HaiLoop");
return 0;
}
A. HaiLoop HaiLoop HaiLoop
B. HaiLoop HaiLoop HaiLoop HaiLoop HaiLoop
C. HaiLoop HaiLoop
D. Infinite Loop
15. What will be the output of the C program ?
#include<stdio.h>
int main(){
float ft = 7.5;
while(ft){
printf("Loop");
ft = ft - .5;
if(ft == 5.0f)
break;
}
return 0;
}

A. Prints Nothing
B. Looop
C. Loop Loop Loop Loop Loop
16. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i = 0;
while(;;)
{
printf("Hai Loop");
if (i == 2)
break;
A. Hai Loop
i++;
B. Compilation Error
}
C. Hai Loop Hai Loop
return 0;
D. Hai Loop Hai Loop Hai Loop
}
17. What will be the output of the C program?
#include<stdio.h>
int main()
{
while(!!7)
printf("Hai");
return 0;
}

A. Hai Hai Hai Hai Hai Hai Hai


B. Hai
C. Infinite Loop
D. Prints Nothing
18. What will be the output of the C program?
#include<stdio.h>
int main(){
int i = -1;
do
{
printf("HiDoWhile ");
}while(i++);
return 0;
}
A. Compilation Error
B. HiDoWhile
C. HiDoWhile HiDoWhile HiDoWhile
D. HiDoWhile HiDoWhile
19. What will be the output of the C program?
#include<stdio.h>
int main(){
while(!printf("Steve is awesome"));
return 0;
}

A. Steve is awesome
B. Infinite Loop
C. Prints Nothing
D. None of the Above
20. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i[3] = {1, 4, 0};
while(i[2] == i[3])
{
if(i[3])
printf("Loop ");
else
break; A. Compilation Error
} B. Runtime Error
return 0; C. Prints Nothing
} D. Loop
21. What will be the output of the C program?
#include<stdio.h>
int main()
{
char ch = 0;
while(ch == '0')
{
printf("Loop ");
break;
}
return 0;
}
A. Loop
B. Compilation Error
C. Runtime Error
D. Prints Nothing
22. What will be the output of the C program?
#include<stdio.h>
int main()
{
char str[14] = "";
while(str == " ")
printf("Loop ");
return 0;
}

A. Prints Nothing
B. Infinite Loop
C. Loop Loop
D. Loop
23. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i = 0;
while(i+1)
while(i<<2)
while(i)
{
printf("Loop ");
if(i == 3) A. Loop Loop Loop
break; B. Loop Loop
} C. Loop
return 0; D. Infinite Loop
}
24. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i = 0;
while(++i)
{
i == --i?i = 0:i = 1;
}
printf("%d", i);
return 0;
}
A. 0
B. Infinite Loop
C. 1
D. Compilation Error
25. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i = 1;
do
{
while(i)
i--;
for(i++;0;i++);
A. 1
break;
B. 2
}while(1);
C. 0
printf("%d", i);
D. Infinite Loop
return 0;
}
SWITCH CASE
1. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i = 1;
switch(i)
{
case 1:
printf("Hai ");
default:
printf("Bye");
} A. Compilation Error
return 0; B. Bye
} C. Hai
D. Hai Bye
2. What will be the output of the C program?
#include<stdio.h>
int main(){
char ch = 65;
switch(ch){
case 'A':
printf("Apple");
break;
case 'B':
printf("Bing");
break;
default: A. Apple
printf("Bye"); B. Bing
break;} C. Bye
return 0; D. Compilation Error
}
3. What will be the output of the C program?
#include<stdio.h>
int main(){
int i = 65;
switch(i){
case 65:
printf("Integer 65");
break;
case 'A':
printf("Char 65");
break; A. Char 65
default: B. Integer 65
printf("Bye"); C. Bye
} D. Compilation Error
return 0;
}
4. What will be the output of the C program?
#include<stdio.h>
int main(){
int i = 65;
char ch = 'B';
switch(ch, i){
case 65:
printf("Integer");
break;
case 'B':
printf("Char"); A. Bye
break; B. Integer
default: C. Char
printf("Bye");} D. Compilation Error
return 0;
}
5. What will be the output of the C program?
#include<stdio.h>
int main(){
int i = 1;
i++;
switch(i--){
case 1:
printf("case 1 executed");
break;
case 2:
printf("case 2 executed"); A. case 2 executed
break; B. case 1 executed
default: C. default block executed
printf("default block executed"); D. Compilation Error
break;}
return 0; }
6. What will be the output of the C program?
#include<stdio.h>
int main(){
switch(2/3)
{
case 1:
printf("case 1 executed ");
case 2:
printf("case 2 execcuted ");
break;
default: A. case 1 executed
printf("Default block executed"); B. Default block executed
} C. case 2 executed
return 0; D. Compilation Error
}
7. What will be the output of the C program?
#include<stdio.h>
int main(){
int i = 1;
switch(i){
case i:
printf("case 1 executed");
break;
case i + 1;
printf("case 2 executed");
A. Compilation Error
break;
B. case 1 executed
default:
C. case 2 executed
printf("default block executed");
D. default block executed
break;}
return 0;
}
8. What will be the output of the C program?
#include<stdio.h>
#define N 1.5
int main(){
int i = 6;
switch(i){
case N + 5:
printf("Switch ON the fan");
break;
case N * 4:
printf("Switch ON the Air Cooler"); A. Switch ON the fan
break; B. Switch ON the Air Cooler
default: C. Save Energy
printf("Save Energy"); D. Compilation Error
}
return 0; }
9. What will be the output of the C program?
#include<stdio.h>
int main(){
switch(*(3 + "I LOVE" "ABCD" + 3)){
case 'A':
printf("Apple Mac");
break;
case 'B':
printf("Windows");
break; A. Apple Mac
case 'C': B. Windows
printf("Great Linux"); C. Great Linux
break; D. All the above
default:
printf("All the above");}
return 0; }
10. What will be the output of the C program?
#include<stdio.h>
int main(){
char *str1 = "First";
char *str2 = "Second";
switch(*str1){
case "First":
printf("USAIN BOLT");
case "Second":
printf("JUSTIN GATLIN");
break; A. USAIN BOLT
default: B. JUSTIN GATLIN
printf("Others"); C. Compilation Error
} D. Others
return 0;
}
11. What will be the output of the C program?
#include<stdio.h>
int main(){
short int si = 1;
switch(++si - si++){
case 1L:
printf("First");
break;
case 2L:
printf("Second");
A. First
break;
B. Bye
default:
C. Second
printf("Bye");
D. Compilation Error
break;}
return 0;
}
12. What will be the output of the C program?
#include<stdio.h>
int main(){
int i = 1;
for(i = 0; i<10; i+3)
switch(i){
case 3:
printf("Hai. This is case 3");
break;
case 6: A. Hai. This is case 3
printf("Hai. This is case 6"); B. Hai. This is case 6
break; C. Infinite Execution
break; D. Hai. This is default
default:
printf("Hai. This is default");
break;}
13. What will be the output of the C program?
#include<stdio.h>
int main(){
char ch = '\0';
switch(ch){
case NULL: printf("Empty \0");
break;
case ' ': printf("Empty Empty");
break;
case '0': printf("Empty 0");
break;
default: printf("Nothing"); }
return 0; }

A. Empty \0
B. Empty Empty
14. What will be the output of the C program?
#include<stdio.h>
int main(){
char *str = "ABCD";
switch(*str + 2){
case 'A': printf("Apple");
break;
case 'B': printf("BOOK");
break;
case 'C': printf("CLOUD");
A. CLOUD
break;
B. BOOK
case 'D': printf("DELL");
C. APPLE
break;
D. Compilation Error
}
return 0;
}
15. What will be the output of the C program?
#include<stdio.h>
int main(){
switch(25){
case 25L: printf("25L");
break;
case 25.0: printf("25.0");
break;
default: printf("Nothing");
break; }
return 0;
}

A. 25L
B. 25.0
C. Compilation Error
16. What will be the output of the C program?
#include<stdio.h>
int main(){
int num = 0;
if (num++, num--, ++num)
switch(num){
case 1: printf("case one");
break;
case 2: printf("case two");
break;
default: printf("default block"); A.case one
break; B.case two
} C.default block
return 0; D.Compile Time Error
}
17. What will be the output of the C program?
#include<stdio.h>
int main(){
int num = 5;
switch(num++ == 5){
case 1: printf("TRUE");
break;
case 0: printf("FALSE");
break;
default: printf("inside default");
}
return 0; }

A. inside default
B. FALSE
C. TRUE
18. What will be the output of the C program?
#include<stdio.h>
int main(){
switch(1){
case 1:
printf("inside case 1 ");
break;
printf("Hai");
default:
printf("inside default");
break; }
return 0; }

A. inside default
B. Hai
C. inside case 1 Hai
19. What will be the output of the C program?
#include<stdio.h>
int main(){
char ch = 96.0;
switch(ch){
case 96: printf("inside case");
break;
default: printf("inside default");
}
return 0;
}

A. inside case
B. inside default
C. Prints Nothing
D. Compilation Error
20. What will be the output of the C program?
#include<stdio.h>
int main(){
int i = 3, j = 4;
switch(i | j){
case 1: printf("inside case 1");
break;
case 3: printf("inside case 3");
break;
case 4: printf("inside case 4");
break; A. inside case 1
case 7: printf("inside case 7"); B. inside case 3
break; } C. inside case 4
return 0; D. inside case 7
}
21. What will be the output of the C program?
#include<stdio.h>
int main() {
int p = 5;
int *ptr;
ptr = &p;
switch(*ptr) {
case *ptr: printf("*ptr Hai");
break;
case &p: printf("ptr Hai");
break; A. *ptr Hai
default: printf("default Hai"); B. ptr Hai
break; C. Compilation Error
} D. default Hai
return 0;
}
22. What will be the output of the C program?
#include<stdio.h>
int main(){
int i = 0;
while(i < 2)
switch(i){
i = 2;
case 0: printf("Hai. This is case 0");
i++;
case 1: printf("Hai. This is case 1");
i++; break;
case 2: printf("Hai. This is case 2");
i++; break;
default: printf("Hai. This is default");
i++; break; }
return 0; }
A. Hai. This is case 0 Hai. This is case 1
B. Hai. This is case 0 Hai. This is case 2
C. Hai. This is case 0 Hai. This is case 1 Hai. This is case 2
D. Hai. This is case 0 Hai. This is default
23. What will be the output of the C program?
#include<stdio.h>
int main(){
int n = 4;
switch(n)
{
default: printf("Hai default ");
case 1: printf("Hai case 1 ");
case 2: printf("Hai case 2 ");
case 3: printf("Hai case 3 ");
}
return 0; }

A. Runtime Error
B. Hai default
C. Compilation Error
24. What will be the output of the C program?
#include<stdio.h>
int main(){
char arr[5] = {'i', 'n', 'd', 'i', 'a'};
char *ptr;
*ptr = (arr + 1)[3];
switch(*ptr) {
case 'i': printf("Innovations Inventions");
break;
case 'n': printf("Nation of Integrity");
break;
case 'd': printf("Dedicated");
break;
case 'a': printf("Affectionate People");
break;
default: printf("India - Next Super Power");
break;
}
return 0;
}

A. Innovations Inventions
B. Affectionate People
C. Compilation Error
D. India - Next Super Power
25. What will be the output of the C program ?
#include<stdio.h>
int main(){
switch(true){
case true:printf("Hai. This is True");
break;
case false: printf("Hai. This is False");
break;
default: printf("Bye. Take some rest");
break;
}
return 0; }
A. Hai. This is True
B. Hai. This is False
C. Compilation Error
D. Bye. Take some rest
ARRAYS
1. What will be the output of the C program?
#include<stdio.h>
int main(void)
{
int arr[5] = { 1, 2, 3, 5, 7 };
int *ptr = (&arr + 1);
printf("%d %d\n", *(arr + 1), *(ptr - 1));
return 0;
}
A. 2 5
B. 3 5
C. 2 7
D. 3 7
2. What will be the output of the C program?
#include<stdio.h>
int main()
{
int a[][3] = {0, 1, 2, 3, 4, 5};
int (*ptr)[3] = a;
printf("%d %d ", (*ptr)[0], (*ptr)[1]);
++ptr;
printf("%d %d\n", (*ptr)[0], (*ptr)[1]);
return 0;
}
A. 0 1 3 4
B. 0 1 0 1
C. 0 1 2 3
3. What will be the output of the C program?
#include<stdio.h>
int main()
{
char temp;
char arr[10] = {1, 2, 3, 4, 5, 6, 9, 8};
temp = (arr + 1)[2];
printf("%d\n", temp);
return 0;
}
A. 2
B. 3
C. 4
D. 5
4. What will be the code to print 5 contains in a[4][1][0]?
#include<stdio.h>
int main()
{
int a[1][2][3] = {0};
a[0][1][2] = 5;
printf("%d",*(*(*(a+0)+1)+2));
return 0;
}

A. printf("%d",*(((a+0)+1)+2));
B. printf("%d",*(*(*(a+0)+1)+2));
C. printf("%d",***((a+0)+1)+2);
D. None of the above
5. What will be the output of the C program?
#include<stdio.h>
void fun(char**);
int main()
{
char *arr[] = { "bat", "cat", "fat", "hat", "mat", "pat" };
fun(arr); A. mat
return 0; B. fat
} C. hat
void fun(char **p)
D. cat
{
char *t;
t = (p += sizeof(int))[-1];
printf("%s\n", t);
6. What will be the output of the C program?
#include<stdio.h>
int main()
{
int arr[5][5][5] = {0};
printf("%d", ( &arr+1 - &arr ));
return 0;
}

A. 0
B. Compilation error
C. 1
D. 4
7. What will be the output of the C program?
#include<stdio.h>
void fun(int[][3]);
int main(void)
{
int arr[3][3] = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} };
fun(arr); A. 15
printf("%d\n", arr[2][1]);
B. 9
return 0;
C. 8
}
D. 7
void fun(int b[][3])
{
++b;
b[1][1] = 15;
8. What will be the output of the C program?
#include<stdio.h>
int main(){
int rows = 3, colums = 4, i, j, k;
int a[3][4] = {1, 2, 3, 5, 7};
i = j = k = 00;
for(i = 0;i<rows;i++)
for(j = 0;j<colums;j++)
if(a[k][j]<k)
k = a[i][j];
printf("%d\n", k);
return 0;}
9. What will be the code to print 5 contains in a[4][1][0]?
#include<stdio.h>
int main()
{
int arr[ ]={1.2, 2.4, 3.6, 4.8, 5};
int j, *ptr = arr;
for(j = 0;j<5;j++)
{
printf("%d ", *arr);
++ptr;
}
}
A. 2 2 2 2 2
B. 1 1 1 1 1
C. 1 2 3 4 5
D. None of the above
10. What will be the output of the C program?
#include<stdio.h>
int main()
{
int arr[5][5][5] = {0};
int *b = arr;
int *c = arr + 1;
printf("%d", c - b);
return 0;
}

A. 0
B. Runtime Error
11. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i = 0;
printf("Hello");
char s[4] = {'\b', '\t', '\r', '\n'};
for(i = 0;i<4;i++){
printf("%c", s[i]);
}
return 0;
}
A. Hello
B. Compilation error
C. Hell
D. None of the above
12. What will be the output of the C program?
#include<stdio.h>
int main()
{
static int a[ ] = {0, 1, 2, 3, 4};
int *p[ ] = {a, a + 1, a + 2, a + 3, a + 4};
int **ptr = p;
++*ptr;
printf("%d %d %d", ptr - p, *ptr - a, **ptr);
return 0;
}
A. 0 1 1
B. 0 0 1
C. 0 1 2
D. 1 1 2
13. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i = 0;
char s[4] = {'\0', '\0', '\0', '\0'};
for(i = 0;i<4;i++)
{
printf("%c", s[i]);
}
return 0;
}
A. \0 \0 \0
B. \0 \0 \0 \0
14. What will be the output of the C program?
#include<stdio.h>
int 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);
return 0;
}
A. 76
B. 77
C. 78
15. What will be the output of the C program?
#include<stdio.h>
int main(){
int i = 0;
printf("Hello");
char s[4] = {'\b', '\r', '\t', '\n'};
for(i = 0;i<4;i++){
printf("%c", s[i]);
}
return 0;
}

A. Hello
B. Hell
16. What will be the output of the C program?
#include<stdio.h>
int main()
{
int arr[2] = {1, 2, 3, 4, 5};
printf("%d", arr[3]);
return 0;
}
A. 3
B. 4
C. 0
D. Compilation error
17. What will be the output of the C program?
#include<stdio.h>
int main()
{
int a, b, c;
int arr[5] = {1, 2, 3, 25, 7};
a = ++arr[1];
b = arr[1]++;
c = arr[a++];
printf("%d--%d--%d", a, b, c);
return 0;
}
A. 4--3--25
B. 3--3--25
C. 4--4--25
D. 3--4—25
18. What will be the output of the C program?
#include<stdio.h>
int main()
{
int arr[5] = {1, 3, 5, 7, 11};
int *ptr, *ptr1;
ptr = &arr;
ptr1 = *ptr + 3;
printf("%d--%d", *ptr, ptr1);
}
A. 1--11
B. 1--7
C. 1--4
D. 1--some address
19. What will be the output of the C program?
#include<stdio.h>
int main()
{
int arr[5] = { 1, 3, 5, 7, 11 };
int *ptr;
ptr = &arr;
printf("%d", *ptr + 1);
}
A. 1
B. 2
C. 3
D. Runtime error
20. What will be the output of the C program?
#include<stdio.h>
int main()
{
static char *arr[ ] = {"bike", "bus", "car", "van"};
char **ptr[ ] = {arr+3, arr+2, arr+1, arr};
char ***p;
p = ptr;
**++p;
printf("%s",*--*++p + 2);
}

A. Nothing prints
B. ke
C. ike
D. Compilation error
21. What will be the output of the C program?
#include<stdio.h>
#define arr[5] {1, 2, 3, 4, 5}
int main()
{
printf("%d", arr[1]);
return 0;
}
A. 1
B. 2
C. Compilation error
D. Runtime error
22. What will be the output of the C program?
#include<stdio.h>
#define arr "abcd"
int main()
{
printf("%c", arr[2]);
return 0;
}
A. c
B. b
C. Compilation error
D. Runtime error
23. What will be the output of the C program?
#include<stdio.h>
int main()
{
int arr[1] = {2};
printf("%d", 0[arr]);
return 0;
}
A. Compilation error
B. Some Garbage value
C. 2
D. 0
24. What will be the output of the C program?
#include<stdio.h>
void array(int **p);
int main()
{
int arr[2][3] = {{3, 6, 9 }, {12, 15, 18}};
int *ptr;
ptr = &arr; A. address of first element in array
array(&ptr);
B. 3
return 0;
C. address of ptr
}
D. Runtime error
void array(int **p)
{
printf("%d", **p);
25. What will be the output of the C program?
#include<stdio.h>
int main()
{
int arr[3], i = 0;
while(i < 3)
{
arr[i] = ++i;
A. Compilation error
}
B. 1--2--3--
for(i=0; i<3; i++)
{ C. Garbage value--1--2--
printf("%d--", arr[i]); D. None of the above
}
return 0;
POINTERS
1. What will be the output of the C program?
#include<stdio.h>
int main(){
int a = 130;
char *ptr;
ptr = (char *)&a;
printf("%d ",*ptr);
return 0; A. -126
} B. Run Time Error
C. Garbage value
D. Compile Time Error
2. What will be the output of the C program?
#include<stdio.h>
int main(){
int i = 3;
int *j;
int **k;
j = &i;
k = &j;
k++;
printf("%d ",**k); A. Garbage value
return 0; B. Compilation Error
} C. Run time error
D. Linker Error
3. What will be the output of the C program?
#include<stdio.h>
int main(){
int i = 3;
int *j;
j = &i;
j++;
printf("%d ",*j);
A. Linker Error
return 0;
B. Run time error
}
C. Compilation Error
D. Garbage value.
4. What will be the output of the C program?
#include<stdio.h>
#include<string.h>
int main(){
char *ptr = "hello";
char a[22];
strcpy(a, "world");
printf("\n%s %s",ptr, a);
A. hello world
return 0;
B. Run time error
}
C. Compilation Error
D. Garbage value
5. What will be the output of the C program?
#include<stdio.h>
#include<string.h>
int main(){
char *ptr = "hello";
char a[22];
*ptr = "world";
printf("\n%s %s",ptr, a); A. Linker Error
return 0; B. Run time error
} C. Compilation Error
D. Garbage value
6. What will be the output of the C program?
#include<stdio.h>
int main()
{
char *ptr = "helloworld";
printf(“%s”,ptr + 4);
return 0;
A. oworld
} B. world
C. hell
D. hello
7. What will be the output of the C program?
#include<stdio.h>
int main()
{
char *ptr = “Campus";
printf("%c\n",*&*ptr);
return 0; A. Address of 2
} B. Compilation Error
C. C
D. Run time error
8. What will be the output of the C program?
#include<stdio.h>
#include<string.h>
int main(){
register a = 1;
int far *ptr;
ptr = &a;
printf("%u",ptr); A. Address of a
return 0; B. Run time error
} C. Garbage value
D. Compile time error
9. What will be the output of the C program?
#include<stdio.h>
#include<string.h>
int main(){
char a = 30, b = 5;
char *p = &a, *q = &b;
printf("%d", p - q);
return 0; A. 1
} B. Run time error
C. Compilation Error
D. 25
10. What will be the output of the C program?
#include<stdio.h>
int main(){
int *ptr, b;
b = sizeof(ptr);
printf("%d" , b);
return 0;
A. 2
}
B. 4
C. Compilation Error
D. Run time error
11. What will be the output of the C program?
#include<stdio.h>
struct classroom{
int students[7];
};
int main(){
struct classroom cr = {2, 3, 5, 7, 11, 13};
int *ptr;
ptr = (int *)&cr;
printf("%d",*(ptr + 4));
return 0;
} A. 5
B. 11
C. 13
D. 7
12. What will be the output of the C program?
#include<stdio.h>
unsigned long int (*function())[5]{
static unsigned long int arr[5] = {2, 3, 5, 7, 11};
printf("%d", *arr);
return &arr;
}
int main(){
unsigned long int (*ptr)[5];
ptr = function();
printf("%d", *(*ptr + 4));
return 0;
}A. 2, 5
B. 2, 7
C. 2, 11
D. Compilation error
13. What will be the output of the C program?
#include<stdio.h>
int main(){
int a = 25, b;
int *ptr, *ptr1;
ptr = &a;
ptr1 = &b;
b = 36;
printf("%d %d",*ptr, *ptr1);
return 0;
}
A. 25 45632845
B. Run time error
C. Compilation Error
D. 25 36
14. What will be the output of the C program?
#include<stdio.h>
int main(){
int * ptr ;
printf("%d", sizeof(ptr));
return 0;
}

A. 4
B. 8
C. 2
D. compilation error
15. What will be the output of the C program?
#include<stdio.h>
int main(){
int *ptr = 2;
printf("%d", sizeof(ptr));
return 0;
}

A. Garbage value
B. 2
C. Compilation error
D. 4
16. What will be the output of the C program?
#include<stdio.h>
int main(){
int *ptr;
*ptr = 5;
printf("%d" , *ptr);
return 0;
}

A. compilation error
B. Runtime error
C. 5
D. linker error
17. What will be the output of the C program?
#include<stdio.h>
int main(){
int a = 36;
int *ptr;
ptr = &a;
printf("%u %u", *&ptr , &*ptr);
return 0;
}
A. Address Value
B. Value Address
C. Address Address
D. Compilation error
18. What will be the output of the C program?
#include<stdio.h>
int main(){
int num = 10;
printf("num = %d addresss of num = %u",num, &num);
num++;
printf("\n num = %d addresss of num = %u",num, &num);
return 0;
}
A. Compilation error
B. num = 10 address of num = 2293436
num = 11 address of num = 2293438
C. num = 10 address of num = 2293436
num = 11 address of num = 2293440
D. num = 10 address of num = 2293436
num = 11 address of num = 2293436
19. What will be the output of the C program?
#include<stdio.h>
int main(){
int i = 25;
int *j;
int **k;
j = &i;
k = &j;
printf("%u %u %u ",k,*k,**k);
return 0;
}
A. address address value
B. address value value
C. address address address
D. compilation error
20. What will be the output of the C program?
#include<stdio.h>
int main(){
int a, b, c;
char *p = 0;
int *q = 0;
double *r = 0;
a = (int)(p + 1);
b = (int)(q + 1);
c = (int)(r + 1);
printf("%d %d %d",a, b, c);
return 0;
} A. Runtime error
B. 0 0 0
C. Compilation error
D. 1 4 8
21. What will be the output of the C program?
#include<stdio.h>
int main()
{
char *ptr;
char string[] = "CampusConnect";
ptr = string;
ptr += 6;
printf("%s",ptr);
return 0;
}
A. compilation error
B. Runtime error
C. CampusConnect
D. Connect
22. What will be the output of the C program?
#include<stdio.h>
int main()
{
const int a = 5;
const int *ptr;
ptr = &a;
*ptr = 10;
printf("%d\n", a);
return 0;
}
A. Compilation error
B. Garbage Value
C. Address
D. 5
23. What will be the output of the C program?
#include<stdio.h>
int main()
{
printf("%d", sizeof(void *));
return 0;
}

A. 1
B. compilation error
C. Runtime error
D. 4
24. What will be the output of the C program?
#include<stdio.h>
void function(char**);
int main()
{
char *arr[] = { "ant", "bat", "cat", "dog", "egg", "fly" };
function(arr);
return 0;
} A. cat
void function(char **ptr) B. bat
{ C. dog
char *ptr1; D. egg
ptr1 = (ptr += sizeof(int))[-2];
printf("%s\n", ptr1);
}
25. What will be the output of the C program?
#include<stdio.h>
int main()
{
struct node
{
int a, b, c;
};
struct node num = {3, 5, 6};
struct node *ptr = & num;
printf("%d\n", *((int*)ptr + 1 + (3-2)));
return 0;
} A. 3
B. 5
C. Compilation error
D. 6
Functions
1. What will be the output of the C program?
#include<stdio.h>
int function1()
{
function();
return 0;
}
void function()
{
printf("Function in C is awesome");
}
A. Function in C is awesome
B. no output
C. Runtime error
D. Compilation error
2. What will be the output of the C program?
#include<stdio.h>
int main()
{
main();
return 0;
}
A. Runtime error
B. Compilation error
C. 0
D. none of the above
3. What will be the output of the C program?
#include<stdio.h>
a()
{
printf("Function");
}
b()
{
printf("Function in C");
}
c()
{
main()
{
int (*ptr[3])();
ptr[0] = a;
ptr[1] = b;
ptr[2] = c;
ptr[2]();
return 0;
}
A. Function
B. Function in C
C. C function
D. None of the above
4. What will be the output of the C program?
#include<stdio.h>
int function();
main()
{
int i;
i = function();
printf("%d", i);
return 0;
}
function()
{
int a;
a = 250;
return 0;
}
A. Runtime error
B. 0
C. 250
D. No output
5. What will be the output of the C program?
#include<stdio.h>
int function();
main()
{
int i;
i = function();
printf("%d", i);
return 0;
}
function()
{
A. 250
B. 0
C. 1
D. Some Garbage value
6. What will be the output of the C program?
#include<stdio.h>
int function(int, int);
int main()
{
int a = 25, b = 24 + 1, c;
printf("%d", function(a, b));
return 0;
}
int function(int x, int y)
{
return (x - (x == y));
}
A. Compilation error
B. 25
C. 1
D. 24
7. What will be the output of the C program?
#include<stdio.h>
int main()
{
int num = _a_123(4);
printf("%d\n", --num);
return 0;
}
int _a_123(int num)
{
return(num++);
}
A. 3
B. Compilation error
C. 4
D. 5
8. What will be the output of the C program by considering 'c' as a User
input?
#include<stdio.h>
int main()
{
char c = ' ', x;
getc(c);
if((c >= 'a') && (c <= 'z'))
A. Runtime Error
x = convert(c);
printf("%c", x); B. Any symbols or special characters
return 0; C. Compilation Error
}
D. B
A. Runtime Error
B. Any symbols or special characters
C. Compilation Error
D. B
9. What will be the output of the C program?
#include<stdio.h>
int main(){
char arr[100];
arr[0] = 'a'; A. bc
arr[1] = 'b'; B. bb
C. cd
arr[2] = 'c'; D. cc
arr[4] = 'd';
abc(arr);
return 0;
}
abc(char arr[]){
10. What will be the output of the C program?
#include<stdio.h>
int main()
{
int num = returns(sizeof(float));
printf("Value is %d", ++num);
return 0;
}
int returns(int returns)
A. 9
{
returns += 5.01;
B. Compilation error
return(returns); C. 10
} D. None of the above
11. What will be the output of the C program?
#include<stdio.h>
int main()
{
char arr[] = "function\0";
int num = strlen(a);
printf("Length of function is %d", num);
return 0;
}
A. 9
B. 7
C. 10
D. 8
12. What will be the output of the C program?
#include<stdio.h>
void abc();
int *ptr;
int main(){
int i, *p = &i;
abc();
return 0;
}
void abc(){
int i = 0;
ptr = &i;
ptr++;
*ptr = 3;
printf("\nFunction in C %d", i);
}

A. Function in C 0
B. Function in C 1
C. Function in C 2
D. No output
13. What will be the output of the C program by considering 'b' as a User
input?
#include<stdio.h>
char normal[15] = "Ambulance";
char accident[15];
int main()
{
swab(normal, accident, strlen(normal +1));
printf ("%s\n", normal); A. Ambulance
return 0; B. mAubalcne
} C. mAubalcn
D. ecnalubmA
14. What will be the output of the C program?
#include<stdio.h>
void ptr(char**);
int main()
{
char *argv[] = { "abc", "def", "ghi", "jkl", "mno", "pqr" };
ptr(argv);
return 0;
}
void ptr(char **p)
{
char *t; A. ghi
t = (p += sizeof(int))[-1];
printf("%s\n", t);
B. jkl
} C. mno
D. pqr
15. What will be the output of the C program?
#include<stdio.h>
int recursive(int i)
{
static int count = 0;
count = count + i;
return count;
}
int main()
{
int i, j;
for (i = 0; i <= 5; i++)
j = recursive(i);
printf("%d\n", j);
return 0;
}
A. 5
B. Compilation error
C. 15
D. 0
16. What will be the output of the C program?
#include<stdio.h> void fun(int *p, int q)
void fun(int*, int);
{
void (*ptr[1])(int*, int);
int main()
int tmp = *p;
{ *p = q;
int a = 2; q = tmp;
int b = 4; }
ptr[0] = fun;
ptr[0](&a, b); A. 2 2
printf("%d %d ", a, b); B. 4 2
return 0; C. 4 4
}
D. 2 4
17. What will be the output of the C program?
#include<stdio.h>
int num = 5;
int main()
{
fun();
fun();
return 0;
}
int fun()
{
static int num = 2;
printf("%d ",num);
num++;
return 0;
}
A. 2 3
B. 2 2
C. 5 5
D. 5 6
18. What will be the output of the C program?
#include<stdio.h>
void fun(char *);
int main()
{
char *string = "function in c";
fun(string);
printf("%s", string);
return 0; A. function in c
} B. Compilation error
C. Runtime Error
void fun(char *a){ D. Nothing prints
while(*a){
*a += 1;
19. What will be the output of the C program?
#include<stdio.h>
#include<stdlib.h>
int* fun();
int main()
{
int *ptr = fun();
printf("%d", *ptr);
return 0;
}
int* fun()
{
int *ptr1 = (int*) malloc(sizeof(int));
*ptr1 = 25;
return ptr1;
}

A. Compilation error
B. 25
C. address
D. Runtime error
20. What will be the output of the C program?
#include<stdio.h>
void fun(int);
int main()
{
int a = 3;
fun(a);
return 0;
}
void fun(int n){
if (n > 0)
{
fun(--n);
printf("%d ", n);
}
}
A. 1 2 3
B. No Output
C. 0 1 2
D. 0
21. What will be the output of the C program?
#include<stdio.h>
int main()
{
int *ptr = fun();
printf("%d", *ptr);
return 0;
} A. 10
int fun()
B. Compilation error
{
int num = 10;
C. Runtime error
return num; D. None of the above
}
22. What will be the output of the C program?
#include<stdio.h>
int main()
{
char str1[] = {'H', 'A', 'I'};
char str2[] = {'H', 'A', 'I'};
if (strcmp(str1, str2)){
printf("strings are not equal");
}
else{
A. strings are not equal
printf("strings are equal");
B. Compilation Error
}
C. strings are equal
return 0;
D. None of the above
}
23. What will be the output of the C program?
#include<stdio.h>
int main()
{
void swap();
int x = 5, y = 10;
swap(&x, &y);
printf("x = %d y = %d",x,y);
return 0;
}
void swap(int *a, int *b) A. x = 5 y = 10
{ B. x = 10 y = 10
*a ^= *b, *b ^= *a, *a ^= *b; C. x = 10 y = 5
} D. x = 5 y = 5
24. What will be the output of the C program?
#include<stdio.h>
int main()
{
int i;
i = main();
printf("%d", i);
int main()
{
int a; A. Compilation error
a = 5 * 5; B. Runtime error
return a; C. address
} D. 25
return 0;
}
25. What will be the output of the C program?
#include<stdio.h>
int swap(int *a, int *b)
{
*a = *a + *b;
*b = *a - *b;
*a = *a - *b;
}
int main()
{ A. Runtime error
int x = 5, y = 10; B. 5 10
swap(&x, &y); C. 10 5
printf("%d %d\n", x, y); D. Compilation error
return 0;
}
Structures
1. What will be the output of the C program?
#include<stdio.h>
int main(){
struct simp{
int i = 6;
char city[] = "chennai";
};
struct simp s1;
printf("%d",s1.city);
printf("%d", s1.i);
return 0;
}
2.What will be the output of the C program?
#include<stdio.h>
struct {
int i;
float ft;
}decl;
int main() {
decl.i = 4;
decl.ft = 7.96623;
printf("%d %.2f", decl.i, decl.ft);
return 0;
}
3.What will be the output of the C program?
#include<stdio.h>
int main() {
struct bitfields{
int bits_1: 2;
int bits_2: 4;
int bits_3: 4;
int bits_4: 3;
}bit = {2, 3, 8, 7};
printf("%d %d %d %d", bit.bits_1, bits.bit_2, bit.bits_3, bits.bit_4);
}
A. Runtime error B. Compilation error
4.What will be the output of the C program?
void main()
{
struct bitfields {
int bits_1: 2;
int bits_2: 9;
int bits_3: 6;
int bits_4: 1;
}bit;
printf("%d", sizeof(bit));
}
A. 2
B. 3
C. 4
D. 0
5.What will be the output of the C program?
#include<stdio.h>
int main()
{
struct leader
{
char *lead;
int born;
};
struct leader l1 = {"AbdulKalam", 1931};
struct leader l2 = l1;
printf("%s %d", l2.lead, l1.born);
}
A. Compilation error B. Garbage value 1931
C. AbdulKalam 1931 D. None of the above
6. What will be the output of the C program?
#include<stdio.h>
struct employee{
char *empname;
int salary;
};
int main(){
struct employee e, e1;
e.empname = "Sridhar";
e1 = e;
printf("%s %s", e.empname, e1.empname);
return 0;
}
7.What will be the output of the C program(assume size of int as 2 bytes)?
#include<stdio.h>
int main(){
struct employee {
int empid[5];
int salary;
employee *s;
}emp;
printf("%d %d", sizeof(employee), sizeof(emp.empid));
return 0;
}
A. 6 2 B. 14 10
8.What will be the output of the C program?
#include<stdio.h>
#include<string.h>
struct player {
char pname[20];
}pl;
char* play(struct player *temp_pl){
strcpy(temp_pl->pname, "kohli");
return temp_pl->pname;
}
int main()
{
strcpy(pl.pname, "dhoni");
printf("%s %s", pl.pname, play(&pl));
return 0;
}

A. dhoni kohli
B. dhoni dhoni
C. None
D. kohli kohli
9.What will be the output of the C program?
#include<stdio.h>
struct decl
{
int n = 100;
}d1;
int main()
{
printf("%d",d1.n);
return 0;
}
A. 100 B. Compilation Error
10.What will be the output of the C program?
#include<stdio.h>
struct TeamScore{
int wickets;
int score;
}ts = {2, 325};
struct country{
char *name;
}coun = {"India"};
int main()
{
struct TeamScore tcon = ts;
11. What will be the output of the C program?
#include<stdio.h>
int main(){
struct zoho{
int employees;
char comp[5];
struct founder{
char ceo[10];
}p; };
struct zoho zs = {4000, "zoho", "sridhar"};
printf("%d %s %s", zs.comp, zs.employees, zs.p.ceo);
return 0;
}
12.What will be the output of the C program?
#include<stdio.h>
int main(){
struct branch{
char bran[10] = "Bangalore";
int bpin = 431;
};
struct headoff{
char head[10];
int hpin;
};
struct headoff h = {"Chennai", 01};
struct branch b;
printf("HO - %s \n hpin - %d", h.head, h.hpin);
A. HO - Chennai hpin - 01 BO - Bangalore 431
B. HO - Chennai hpin - 01
C. Compilation Error
D. Runtime Error
13.What will be the output of the C program?
#include<stdio.h>
int main(){
struct str;{
int s1;
char st[30];
};
struct str s[] = { {1, "struct1"}, {2, "struct2"}, {3, "struct3"} };
printf("%d %s", s[2].s1, (*(s+2)).st);
}

A. Compilation Error B. 1 struct1


14.What will be the output of the C program?
#include<stdio.h>
int main(){
struct play{
char name[10];
int playnum; };
struct play p1 = {"virat", 18};
struct play p2 = p1;
if(p1 == p2)
printf("Two structure members are equal");
return 0;
}
15. What will be the output of the C program?
#include<stdio.h>
int main()
{
enum numbers{num1 = 1.5, num2 = 0, num3, num4, num5, num6}n;
printf("%d %d\n", num1, num2);
}

A. 1.5 0
B. 1.5 2
C. 1.5 2.5
D. Compilation Error
16.What will be the output of the C program?
#include<stdio.h>
int main()
{
enum numbers{num1, num2 = 0, num3, num4, num5, num6}n;
printf("%d\n", sizeof(n));
}
A. 12
B. 4
C. 2
D. None of the above
17.What will be the output of the C program?
#include<stdio.h>
int main()
{
enum week{sun = -1, mon, tue, wed, thu = 5, fri, sat};
printf("%d %d %d %d %d %d %d", sun, mon, tue, wed, thu, fri, sat);
return 0;
}
A. -1 0 1 2 3 4 5
B. -1 0 1 2 5 6 7
C. 1 2 3 4 5 6 7
D. Compilation Error
18.What will be the output of the C program?
#include<stdio.h>
int main()
{
struct alphabets
{
char firstLetter;
struct alphabets a;
}al;
al.firstLetter = 'a';
printf("%c", al.firstLetter);
}
A. A B. Linker Error
19.What will be the output of the C program?
#include<stdio.h>
int main()
{
struct check
{
}ck;
printf("%d", sizeof(ck));
}
A. 0
B. 1
C. 2
D. Compilation Error
E. None
20.What will be the output of the C program?
#include<stdio.h>
int main()
{
struct check
{
int i:0;
}ck;
printf("%d", sizeof(ck));
}
A. 0
B. 2
C. Compilation Error
D. 4
21.What will be the output of the C program?
#include<stdio.h>
int main()
{
struct num
{
int i, j, k, l;
};
struct num n = {1, 2, 3};
printf("%d %d %d %d", n.i, n.j, n.k, n.l);
}
A. 1 2 3 garbage value B. 1 2 3 0
22.What will be the output of the C program?
#include<stdio.h>
int main()
{
struct num
{
int i, j, k, l;
};
struct num n = {1, 2, 3};
printf("%d %d %d %d", i, j, k, l);
}
A. 1 2 3 0 B. 1 2 3 4
23.What will be the output of the C program?
#include<stdio.h>
int main()
{
int i = 2;
enum numbers{num1 = i, num2 , num3}n;
printf("%d %d %d\n", num1, num2, num3);
}
A. Compilation Error
B. 2 3 4
C. 1 2 3
D. None of the above
24.What will be the output of the C program?
#include<stdio.h>
int main(){
struct st
{
int i;
static int si;
};
struct st s = {1, 2};
printf("%d %d", s.i, s.si);
return 0;
}
25.What will be the output of the C program?
#include<stdio.h>
int main()
{
union check
{
int i;
int a[10];
};
printf("%d", sizeof(check));
return 0;
}
A. 2 B. 4
Memory
1. Among 4 header files, which should be included to use the
memory allocation functions like malloc(), calloc(), realloc() and
free()?

A. #include<string.h>
B. #include<memory.h>
C. #include<stdlib.h>
D. Both b and c
2. What will be the output of the C program?
#include<stdio.h>
#include<stdlib.h>
int main()
{
int i, numbers[1];
numbers[0] = 9; A. 9
free(numbers); B. 0
printf("\nStored integers are "); C. Compilation error
printf("\nnumbers[%d] = %d ", 0, numbers[0]); D. garbage value
return 0;
}
3. What will be the output of the C program?
#include<stdio.h>
#include<stdlib.h>
int main()
{
int *j = (int*)malloc(4 * sizeof(int));
*j = 9;
free(j);
A. Compilation error
printf("%d", *j);
B. 0
return 0;
C. Some Garbage value
} D. Nothing prints
4. What will be the output of the C program?
#include<stdio.h>
#include<stdlib.h>
int main()
{
int *numbers = (int*)calloc(4, sizeof(int));
numbers[0] = 9;
free(numbers); A. Garbage value
printf("\nStored integers are "); B. 0
printf("\nnumbers[%d] = %d ", 0, numbers[0]); C. 9a
return 0; D. Compilation error
}
5. What will be the output of the C program?
#include<stdio.h>
int main()
{
int *ptr = (int *)malloc(sizeof(int));
*ptr = 10;
free(ptr);
p = 9; A. Compilation error
printf("%d", ptr); B. 0
} C. 9
D. Garbage value
6. What is the return type of malloc() or calloc()?

A. int *
B. int **
C. void *
D. void **
7. What will be the output of the C program?
#include<stdio.h> char *fun()
#include<string.h> {
int main() char disk[30];
{ strcpy(disk, "memory in c");
int i; printf("%s ",disk);
return disk;
char *ptr;
}
char *fun();
ptr = fun();
printf(" %s", ptr);
return 0;
8. What will be the output of the C program?
#include<stdio.h>
#include<stdlib.h>
int main()
{
int *p;
p = (int *)malloc(20);
printf("%d\n", sizeof(p));
free(p); A. 40
return 0; B. 20
} C. 4
D. 80
9. Which function is used to delete the allocated memory space?
A. Dealloc()
B. free()
C. Both a and b
D. either a or b
10. What will be the output of the C program?
#include<stdio.h>
#include<stdlib.h>
int main(){
struct test
{
int i;
float f;
char c;
};
struct test *ptr;
ptr = (struct test *)malloc(sizeof(struct test));
ptr ->f = 6.5f;
printf("%f", ptr->f);
return 0;
}
A. Compilation error
B. Garbage value
C. 6.500000
D. 0.000000

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