C-Language Programming MCQs > FREE SET - 4

1. What will be the output of the program given below?
#include
int main()
{
enum status { pass, fail, atkt};
enum status stud1, stud2, stud3;
stud1 = pass;
stud2 = atkt;
stud3 = fail;
printf("%d, %d, %d", stud1, stud2, stud3);
return 0;
}
A 0, 1, 2
B 1, 2, 3
C 0, 2, 1
D 1, 3, 2

Free MCQs www.sharemcq.com     Answer: Option C
Explanation:
Available Soon.

2. What will be the output of the program in Turbo C (in DOS 16-bit OS)?
#include
int main()
{
char *s1;
char far *s2;
char huge *s3;
printf("%d, %d, %d", sizeof(s1), sizeof(s2), sizeof(s3));
return 0;
}
A 2, 4, 6
B 4, 4, 2
C 2, 4, 4
D 2, 2, 2

Free MCQs www.sharemcq.com     Answer: Option C
Explanation:
Available Soon.

3. What will be the output of the program?
#include
int main()
{
struct emp
{
char name[20];
int age;
float sal;
};
struct emp e = {"Tiger"};
printf("%d, %f", e.age, e.sal);
return 0;
}
A 0, 0.000000
B Garbage values
C Error
D None of above

Free MCQs www.sharemcq.com     Answer: Option A
Explanation:
Available Soon.

4. What will be the output of the following program?
#include
int X=40;
int main()
{
int X=20;
printf("%d", X);
return 0;
}
A 20
B 40
C Error
D No Output

Free MCQs www.sharemcq.com     Answer: Option A
Explanation:
Available Soon.

5. What will be the output of the program?
#include
int main()
{
int x = 10, y = 20, z = 5, i;
i = x < y < z;
printf("%d", i);
return 0;
}
A 0
B 1
C Error
D None of these

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

6. What will be the output of the following program?
#include
int main()
{
int a[5] = {2, 3};
printf("%d, %d, %d", a[2], a[3], a[4]);
return 0;
}
A Garbage Value
B 2, 3, 3
C 3, 2, 2
D 0, 0, 0

Free MCQs www.sharemcq.com     Answer: Option D
Explanation:
Available Soon.

7. What will be the output of the following program?
#include
int main()
{
union a
{
int i;
char ch[2];
};
union a u;
u.ch[0] = 3;
u.ch[1] = 2;
printf("%d, %d, %d", u.ch[0], u.ch[1], u.i);
return 0;
}
A 3, 2, 515
B 515, 2, 3
C 3, 2, 5
D None of these

Free MCQs www.sharemcq.com     Answer: Option A
Explanation:
Available Soon.

8. In the following program how long will the for loop get executed?
#include
int main()
{
int i=5;
for(;scanf("%s", &i); printf("%d", i));
return 0;
}
A The for loop would not get executed at all
B The for loop would get executed only once
C The for loop would get executed 5 times
D The for loop would get executed infinite times

Free MCQs www.sharemcq.com     Answer: Option D
Explanation:
Available Soon.

9. What will be the output of the following program?
#include
int main()
{
int X=40;
{
int X=20;
printf("%d", X);
}
printf("%d", X);
return 0;
}
A 40 40
B 20 40
C 20
D Error

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

10. Point out the error in the following program
#include
int main()
{
void v = 0;
printf("%d", v);
return 0;
}
A Error: Declaration syntax error 'v' (or) Size of v is unknown or zero.
B Program terminates abnormally.
C No error.
D None of these.

Free MCQs www.sharemcq.com     Answer: Option A
Explanation:
Available Soon.

11. Point out the error in the following program
#include
struct emp
{
char name[20];
int age;
};
int main()
{
emp int xx;
int a;
printf("%d", &a);
return 0;
}
A Error: in printf
B Error: in emp int xx;
C No error.
D None of these.

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

12. Which of the following is correct about err used in the declaration given below?
typedef enum error { warning, test, exception } err;
A It is a typedef for enum error.
B It is a variable of type enum error.
C The statement is erroneous.
D It is a structure.

Free MCQs www.sharemcq.com     Answer: Option A
Explanation:
Available Soon.

13. Point out the error in the following program
#include
int main()
{
int (*p)() = fun;
(*p)();
return 0;
}
int fun()
{
printf("Microsoft.com");
return 0;
}
A Error: in int(*p)() = fun;
B Error: fun() prototype not defined
C No error
D None of these

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

14. Which of the following declaration is correct?
A int length;
B char int;
C int long;
D float double;

Free MCQs www.sharemcq.com     Answer: Option A
Explanation:
Available Soon.

15. Which of the following operations are INCORRECT?
A int i = 35; i = i%5;
B short int j = 255; j = j;
C long int k = 365L; k = k;
D float a = 3.14; a = a%3;

Free MCQs www.sharemcq.com     Answer: Option D
Explanation:
Available Soon.

16. Which of the following correctly represents a long double constant?
A 6.68
B 6.68L
C 6.68f
D 6.68LF

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

17. What are the different types of real data type in C Language?
A float, double
B short int, double, long int
C float, double, long double
D double, long int, float

Free MCQs www.sharemcq.com     Answer: Option C
Explanation:
Available Soon.

18. What will you do to treat the constant 3.14 as a long double?
A use 3.14LD
B use 3.14L
C use 3.14DL
D use 3.14LF

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

19. Which statement will you add in the following program to work it correctly?
#include
int main()
{
printf("%f", log(36.0));
return 0;
}
A #include
B #include
C #include
D #include

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

20. What will be the output of the following program?
#include
int main()
{
float a=0.7;
if(a < 0.7)
printf("C");
else
printf("C++");
return 0;
}
A C
B C++
C Compiler error
D None of above

Free MCQs www.sharemcq.com     Answer: Option A
Explanation:
Available Soon.

21. What will be the output of the following program?
#include
int main()
{
float fval=7.29;
printf("%d", (int)fval);
return 0;
}
A 0
B 0.0
C 7.0
D 7

Free MCQs www.sharemcq.com     Answer: Option D
Explanation:
Available Soon.

22. What will be the output of the following program?
#include
#include
int main()
{
printf("%f", sqrt(36.0));
return 0;
}
A 6.0
B 6
C 6.000000
D Error: Prototype sqrt() not found.

Free MCQs www.sharemcq.com     Answer: Option C
Explanation:
Available Soon.

23. What will be the output of the following program?
#include
#include
int main()
{
printf("%d, %d, %d", sizeof(3.14f), sizeof(3.14), sizeof(3.14l));
return 0;
}
A 4, 4, 4
B 4, 8, 8
C 4, 8, 10
D 4, 8, 12

Free MCQs www.sharemcq.com     Answer: Option C
Explanation:
Available Soon.

24. What will be the output of the following program?
#include
int main()
{
float a=0.7;
if(a < 0.7f)
printf("C");
else
printf("C++");
return 0;
}
A C
B C++
C Compiler error
D None of above

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

25. What will be the output of the following program?
#include
#include
int main()
{
float n=1.54;
printf("%f, %f", ceil(n), floor(n));
return 0;
}
A 2.000000, 1.000000
B 1.500000, 1.500000
C 1.550000, 2.000000
D 1.000000, 2.000000

Free MCQs www.sharemcq.com     Answer: Option A
Explanation:
Available Soon.

26. What will be the output of the following program?
#include
int main()
{
static char *s[] = {"black", "white", "pink", "violet"};
char **ptr[] = {s+3, s+2, s+1, s}, ***p;
p = ptr;
++p;
printf("%s", **p+1);
return 0;
}
A ink
B ack
C ite
D let

Free MCQs www.sharemcq.com     Answer: Option A
Explanation:
Available Soon.

27. What will be the output of the following program?
#include
int main()
{
int i=3, *j, k;
j = &i;
printf("%d", i**j*i+*j);
return 0;
}
A 30
B 27
C 9
D 3

Free MCQs www.sharemcq.com     Answer: Option A
Explanation:
Available Soon.

28. What will be the output of the following program?
#include
int main()
{
int x=30, *y, *z;
y=&x; /* Assume address of x is 500 and integer is 4 byte size */
z=y;
*y++=*z++;
x++;
printf("x=%d, y=%d, z=%d", x, y, z);
return 0;
}
A x=31, y=502, z=502
B x=31, y=500, z=500
C x=31, y=498, z=498
D x=31, y=504, z=504

Free MCQs www.sharemcq.com     Answer: Option D
Explanation:
Available Soon.

29. What will be the output of the following program?
#include
int main()
{
char str[20] = "Hello";
char *const p=str;
*p='M';
printf("%s", str);
return 0;
}
A Mello
B Hello
C HMello
D MHello

Free MCQs www.sharemcq.com     Answer: Option A
Explanation:
Available Soon.

30. What will be the output of the following program if the integer is 4 bytes long?
#include
int main()
{
int ***r, **q, *p, i=8;
p = &i;
q = &p;
r = &q;
printf("%d, %d, %d", *p, **q, ***r);
return 0;
}
A 8, 8, 8
B 4000, 4002, 4004
C 4000, 4004, 4008
D 4000, 4008, 4016

Free MCQs www.sharemcq.com     Answer: Option A
Explanation:
Available Soon.

31. What will be the output of the following program?
#include
int main()
{
char *str;
str = "%s";
printf(str, "K");
return 0;
}
A Error
B No output
C K
D %s

Free MCQs www.sharemcq.com     Answer: Option C
Explanation:
Available Soon.

32. What will be the output of the following program if the size of pointer is 4-bytes?
#include
int main()
{
printf("%d, %d", sizeof(NULL), sizeof(""));
return 0;
}
A 2, 1
B 2, 2
C 4, 1
D 4, 2

Free MCQs www.sharemcq.com     Answer: Option C
Explanation:
Available Soon.

33. What will be the output of the following program?
#include
int main()
{
int arr[2][2][2] = {10, 2, 3, 4, 5, 6, 7, 8};
int *p, *q;
p = &arr[1][1][1];
q = (int*) arr;
printf("%d, %d", *p, *q);
return 0;
}
A 8, 10
B 10, 2
C 8, 1
D Garbage values

Free MCQs www.sharemcq.com     Answer: Option A
Explanation:
Available Soon.

34. What will be the output of the following program?
#include
int main()
{
int arr[3] = {2, 3, 4};
char *p;
p = arr;
p = (char*)((int*)(p));
printf("%d, ", *p);
p = (int*)(p+1);
printf("%d", *p);
return 0;
}
A 2, 3
B 2, 0
C 2, Garbage value
D 0, 0

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

35. What will be the output of the following program?
#include
int main()
{
char *str;
str = "%d";
str++;
str++;
printf(str-2, 300);
return 0;
}
A No output
B 30
C 3
D 300

Free MCQs www.sharemcq.com     Answer: Option D
Explanation:
Available Soon.

36. What will be the output of the following program?
#include
int main()
{
char str[] = "peace";
char *s = str;
printf("%s", s++ +3);
return 0;
}
A peace
B eace
C ace
D ce

Free MCQs www.sharemcq.com     Answer: Option D
Explanation:
Available Soon.

37. What will be the output of the following program?
#include
int main()
{
char *p;
p="hello";
printf("%s", *&*&p);
return 0;
}
A llo
B hello
C ello
D h

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

38. If the size of integer is 4bytes, what will be the output of the following program?
#include
int main()
{
int arr[] = {12, 13, 14, 15, 16};
printf("%d, %d, %d", sizeof(arr), sizeof(*arr), sizeof(arr[0]));
return 0;
}
A 10, 2, 4
B 20, 4, 4
C 16, 2, 2
D 20, 2, 2

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

39. Point out the compile time error in the program given below.
#include
int main()
{
int *x;
*x=100;
return 0;
}
A Error: invalid assignment for x
B Error: suspicious pointer conversion
C No error
D None of above

Free MCQs www.sharemcq.com     Answer: Option C
Explanation:
Available Soon.

40. Point out the error in the program given below.
#include
int main()
{
int a[] = {10, 20, 30, 40, 50};
int j;
for(j=0; j<5; j++)
{
printf("%d", a);
a++;
}
return 0;
}
A Error: Declaration syntax
B Error: Expression syntax
C Error: LValue required
D Error: Rvalue required

Free MCQs www.sharemcq.com     Answer: Option C
Explanation:
Available Soon.

41. Which of the statements is correct about the program given below?
#include
int main()
{
int i=10;
int *j=&i;
return 0;
}
A j and i are pointers to an int
B i is a pointer to an int and stores address of j
C j is a pointer to an int and stores address of i
D j is a pointer to a pointer to an int and stores address of i

Free MCQs www.sharemcq.com     Answer: Option C
Explanation:
Available Soon.

42. Which of the statements is correct about the program?
#include
int main()
{
int arr[3][3] = {1, 2, 3, 4};
printf("%d", *(*(*(arr))));
return 0;
}
A Output: Garbage value
B Output: 1
C Output: 3
D Error: Invalid indirection

Free MCQs www.sharemcq.com     Answer: Option D
Explanation:
Available Soon.

43. How will you free the allocated memory?
A remove(var-name);
B free(var-name);
C delete(var-name);
D dalloc(var-name);

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

44. What is the similarity between a structure, union and enumeration?
A All of them let you define new values
B All of them let you define new data types
C All of them let you define new pointers
D All of them let you define new structures

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

45. What will be the output of the following program?
#include
int main()
{
enum days {MON=-1, TUE, WED=6, THU, FRI, SAT};
printf("%d, %d, %d, %d, %d, %d", MON, TUE, WED, THU, FRI, SAT);
return 0;
}
A -1, 0, 1, 2, 3, 4
B -1, 2, 6, 3, 4, 5
C -1, 0, 6, 2, 3, 4
D -1, 0, 6, 7, 8, 9

Free MCQs www.sharemcq.com     Answer: Option D
Explanation:
Available Soon.

46. What will be the output of the following program?
#include
int main()
{
int i=4, j=8;
printf("%d, %d, %d", i|j&j|i, i|j&j|i, i^j);
return 0;
}
A 12, 12, 12
B 112, 1, 12
C 32, 1, 12
D -64, 1, 12

Free MCQs www.sharemcq.com     Answer: Option A
Explanation:
Available Soon.

47. Which of the following statements correct about the below code?
maruti.engine.bolts=25;
A Structure bolts is nested within structure engine.
B Structure engine is nested within structure maruti.
C Structure maruti is nested within structure engine.
D Structure maruti is nested within structure bolts.

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

48. What will be the output of the program (16-bit platform)?
#include
#include
int main()
{
int *p;
p = (int *)malloc(20);
printf("%d", sizeof(p));
free(p);
return 0;
}
A 4
B 2
C 8
D Garbage value

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

49. What will be the output of the following program?
#include
int main()
{
int i;
i = scanf("%d %d", &i, &i);
printf("%d", i);
return 0;
}
A 1
B 2
C Garbage value
D Error: cannot assign scanf to variable

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

50. How many times the while loop will get executed if a short int is 2 byte wide?
#include
int main()
{
int j=1;
while(j <= 255)
{
printf("%c %d", j, j);
j++;
}
return 0;
}
A Infinite times
B 255 times
C 256 times
D 254 times

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.


No comments:

Post a Comment

Your Feedback is hearty Requested to make the MCQs Collection better.

Popular Posts