C Programming Mock Test C-CAT
C Programming Mock Test C-CAT
This sect ion present s you various set of Mock Test s relat ed t o C Pro gramming Framewo rk. You
can download t hese sample mock t est s at your local machine and solve offline at your convenience.
Every mock t est is supplied wit h a mock t est key t o let you verify t he final score and grade yourself.
Q 2 - In the given belo w co de, the functio n fo pen()uses "r" to o pen the file
so urce.txt in binary mo de fo r which purpo se?
#include<stdio.h>
int main ()
{
FILE *fp;
fp = fopen("source.txt", "r");
return 0;
}
A - For reading
A - True
D - False
Q 5 - Which scanf() statement will yo u use to scan a flo at value (a) and do uble
value (b)?
Float a;
Double b;
A - char p = *malloc(100);
B - char *p = (char*)malloc(100);
D - None of t he above
Q 7 - Which o f the fo llo wing header file can be used to define the NULL macro ?
D - mat h.h
A - Int eger
D - None of above
Q 9 - In the fo llo wing co de, what is 'P'?
const charp P;
A - P is a const ant
B - P is a charact er t ype
C - P is a point er
D - None of t he above
#include<stdio.h>
int main ()
{
typedef char (*(*arrfptr[3])())[10];
arrfptr x
return 0;
}
A - x is a charact er point er
B - x is an array of point er
#include<stdio.h>
#include<stdarg.h>
A - IndiaMAX 1, 7, 11, 0
B - IndiaMAX 1, 7
C - Only 4
D - 1, 7, 11, 0
Q 12 - T he co rrect o rder o f evaluatio n fo r the expressio n z = x + y * z / 4 % 2 1
A - */% =+-
B- /*% - +=
C- - +=*% /
D- */ % +- =
A - */ + -
B - * +- /
C - / *+ -
D- +- / *
A - %L
B - %lf
C - %Lf
D - None of t he above
Q 15 - Which files will get clo sed thro ugh the fclo se() in the fo llo wing pro gram?
#include<stdio.h>
int main ()
{
FILE *fs, *ft, *fp;
fp = fopen("ABC", "r");
fs = fopen("ACD", "r");
ft = fopen("ADF", "r");
fclose(fp, fs, ft);
return 0;
}
B - a=b ? c=30;
A - f1, f2, f3
B - f3, f2, f1
C - f2, f1, f3
#include<stdio.h>
int main()
{
const int i = 0;
printf("%d\n", i++);
return 0;
}
A - 100
B - Infinit y
C-0
A - Yes
D - None of t he above
Float a = 3.14;
Double b = 3.14;
A - %f
B - %lf
C - %Lf
D - None of t he above
A - a, b, d
B - a, b, c
C - b, c, d
D - c, d, a
#include<stdio.h>
int main()
{
const int x = 5;
A - 10
B - 20
C-0
int *ptr[10];
D - None of t he above
Q 26 - What is the ro le o f "r+" o n the file "NOT ES.T XT " in the given belo w co de?
#include<stdio.h>
int main ()
{
FILE *fp;
fp = fopen("NOTES.TXT", "r+");
return 0;
}
Q 27 - In the given belo w co de, what will be return by the functio n get ()?
#include<stdio.h>
int get();
int main()
{
const int x = get();
printf("%d", x);
return 0;
}
int get()
{
return 40;
}
A - 40
B - 20
C-0
D - Error
A - Yes
Q 29 - What value strcmp() functio n returns when two strings are the same?
A-0
B- 2
C-1
D - Error
Q 30 - What will be the o utput o f the given belo w pro gram in T urbo C
#include<stdio.h>
int main()
{
int i = 10, j = 20;
const int *ptr = &i;
D - None of t he above
#include<stdio.h>
int main()
{
const int *ptr = &i;
A - Welcome
B- 0
C - Wel
D - Come
D - print f('\n');
C-
int main()
{
Int char (*argv argc);
)
D - None of t he above
#include<stdio.h>
int main()
{
int y = 100;
const int x = y;
printf("%d\n", x);
return 0;
}
A - 100
B- 0
C - Print x
A - Yes
B - St rst r()
C - st rchr()
D - st rnset ()
Q 36 - If, the given belo w co de finds the length o f the string then what will be the
length?
#include<stdio.h>
while(*s!='\0')
{length++; s++;}
return (length);
}
int main()
{
char d[] = "IndiaMAX";
printf("Length = %d\n", xstrlen(d));
return 0;
}
A-a
B - a, b
C - a, b, c
D- c
A - st rnset ()
B - scanf()
C - st rchr()
D - get s()
char *arr[30];
int (*pf)();
B - pf is a point er
D - None of t he above
Q 41 - extern int fun(); - T he declaratio n indicates the presence o f a glo bal
functio n defined o utside the current mo dule o r in ano ther file.
A - True
B - False
#include<stdio.h>
main ()
int i, j;
A - 5 2, 4 2
B - Compile error
C - 42
D - 5 1, 4 2
#include<stdio.h>
main ()
{
int a=1, b=2, *p=&a, *q=&b, *r=p;
p = q; q = r;
printf("%d %d %d %d\n",a,b,*p,*q);
A - 1 221
B- 21 21
C - 1 21 2
D - Compile error
#include<stdio.h>
void g(void) {
}
main ()
{
void (*f)(void);
f = g;
f();
A - Hello
#include<stdio.h>
int f(int i) {
main ()
printf("%d",f(f(f(f(f(1))))));
A-6
B- 5
C-1
#include<stdio.h>
main ()
{
static int i = 1;
if(i--) {
printf("%d ",i);
main();
}
A-0
B - 0 infinit e
D - Compile error
#include<stdio.h>
main ()
{
printf();
#include stdio.h
D - It compiles.
#include<stdio.h>
main ()
{
int *p = NULL;
#undef NULL
if(p==NULL) printf("NULL");
else printf("Nill");
}
A - NULL
B - Nill
C - Compile error
main()
puts(__DATE__);
B - Print s dat e.
ANSWER SHEET
1 B
2 A
3 C
4 A
5 D
6 B
7 A
8 B
9 A
10 C
11 C
12 D
13 C
14 B
15 D
16 A
17 D
18 D
19 A
20 B
21 A
22 A
23 A
24 D
25 B
26 D
27 A
28 A
29 A
30 C
31 A
32 A
33 A
34 A
35 B
36 B
37 D
38 D
39 D
40 A
41 A
42 D
43 A
44 A
45 C
46 A
47 B
48 D
49 C
50 B