0% found this document useful (0 votes)
557 views

C Program in Mannar

The document contains 50 multiple choice questions related to C programming. It tests knowledge of basic C concepts like data types, operators, control structures, functions, pointers, arrays, structures and unions. The questions have single correct answers related to analyzing code snippets and predicting output.

Uploaded by

ratheesh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
557 views

C Program in Mannar

The document contains 50 multiple choice questions related to C programming. It tests knowledge of basic C concepts like data types, operators, control structures, functions, pointers, arrays, structures and unions. The questions have single correct answers related to analyzing code snippets and predicting output.

Uploaded by

ratheesh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

1] 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);
return 0;
}
Garbage value
Compilation Error
Run time error
Linker Error
2] A function cannot be defined inside another function
True.
FALSE.
3] 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;
}
This will work
This will not work
Compilation Error
Runtime Error
4] All char array elements are L-value
TRUE.
FALSE.
5] In the following code what is 'P'?
typedef char *charp;
const charp P;
P is a constant
P is a character constant
P is character type
None of the above

6] A float is 4 bytes wide, whereas a double is 8 bytes wide.


TRUE.
FALSE.
7] We want to round off x, a float, to an int value, The correct way to do is
y = (int)(x + 0.5)
y = int(x + 0.5)
y = (int)x + 0.5
y = (int)((int)x + 0.5)
8] Which of the following statements are correct about the program?
#include<stdio.h>

int main()
{
printf("%p", main());
return 0;
}
It prints garbage values infinitely
Runs infinitely without printing anything
Error: main() cannot be called inside printf()
No Error and print nothing
9] The modulus operator cannot be used with a long double.
True.
FALSE.
10] what among the following is a unconditional control structure:
do-while
if-else
goto
for
[11] A char variable can store either an ASCII character or a Unicode character.
True.
FALSE.
12] What will be the output of the program?

#include<stdio.h>
int reverse(int);

int main()
{
int no=5;
reverse(no);
return 0;
}
int reverse(int no)
{
if(no == 0)
return 0;
else
printf("%d,", no);
reverse (no--);
}
Print 5, 4, 3, 2, 1
Print 1, 2, 3, 4, 5
Print 5, 4, 3, 2, 1, 0
Infinite loop
13] If scanf() is used to store a value in a char variable then along with the value a carriage
return(\r) also gets stored it.
True.
FALSE.
14] If a function contains two return statements successively, the compiler will generate
warnings.
YES.
NO.
15] The elements of union are always accessed using & operator
YES.
NO.
16] If the following structure is written to a file using fwrite(), can fread() read it back
successfully?

struct emp
{
char *n;
int age;
};
struct emp e={"IndiaBIX", 15};
FILE *fp;
fwrite(&e, sizeof(e), 1, fp);
YES.
NO.
17] What will be the output of the program?
#include<stdio.h>
int i;
int fun1(int);
int fun2(int);

int main()
{
extern int j;
int i=3;
fun1(i);
printf("%d,", i);
fun2(i);
printf("%d", i);
return 0;
}
int fun1(int j)
{
printf("%d,", ++j);
return 0;
}
int fun2(int i)
{
printf("%d,", ++i);
return 0;
}
int j=1;
3, 4, 4, 3
4, 3, 4, 3
3, 3, 4, 4
3, 4, 3, 4
18] What will be the output of the program?

#include<stdio.h>
int main()
{
char str[]="C-program";
int a = 5;
printf(a >10?"Ps\n":"%s\n", str);
return 0;
}
C-program
Ps
Error
None of above
19] What is the work of break keyword?
Halt execution of program
Restart execution of program
Exit from loop or switch statement
None of the above

20] The default parameter passing mechanism is


call by value
call by reference
call by value result
none of the above
21] Each case statement must end with
end
exit
break
default
22] How will you print \n on the screen?
printf("\n");
echo "\\n";
printf('\n');
printf("\\n");
23] c is a __________ language:
high level
low level
middle level
machine level
24] A C program contains the following declaration int i=8, j=5 what would be the value of
following expression? abs(i-2*j)
2
4
6
8
25] How many times "Gtec" is get printed?

#include<stdio.h>
int main()
{
int x;
for(x=-1; x<=10; x++)
{
if(x < 5)
continue;
else
break;
printf("Gtec");
}
return 0;
}
Infinite times
11 times
0 times
10 times
26] A function may have several declarations, but only one definition
TRUE.
FALSE.

27] Is the following statement a declaration or definition?


extern int i;
Declaration
Definition
Function
Error
28] While calling the fprintf() function in the format string conversion specifier %s can be used
to write a character string in capital letters.
TRUE.
FALSE.
29] The output of the following is . int a=75; printf(“%d%%”, ;
75
75%%
0.75
None of the above
30] What does the following declaration mean?

int (*ptr)[10];
ptr is array of pointers to 10 integers
ptr is a pointer to an array of 10 integers
ptr is an array of 10 integers
ptr is an pointer to array
31] What will be the output of the program?

#include<stdio.h>

int main()
{
char far *near *ptr1;
char far *far *ptr2;
char far *huge *ptr3;
printf("%d, %d, %d\n", sizeof(ptr1), sizeof(ptr2), sizeof(ptr3));
return 0;
}
4, 4, 8
4, 4, 4
2, 4, 4
2, 4, 8
32] What is the result of 16>>2?
4
8
3
33] Let x be an array. Which of the following operation is not illegal?
++ x
x+1
x++
x*2
34] The statement print f ("%d", 10 ? 0 ? 5 : 1 : 12); will print?
10
12
1
35] What does the following declaration mean?
int (*ptr)[10];
ptr is array of pointers to 10 integers
ptr is a pointer to an array of 10 integers
ptr is an array of 10 integers
ptr is an pointer to array
36] What will be the output of the program?
#include<stdio.h>
void fun(int*, int*);
int main()
{
int i=5, j=2;
fun(&i, &j);
printf("%d, %d", i, j);
return 0;
}
void fun(int *i, int *j)
{
*i = *i**i;
*j = *j**j;
}
5, 2
10, 4
2, 5
25, 4
37] Which is executed quickly?
++p
P++
Both
P+1
38] Queue is a _____________ list.
LIFO
LILO
FILO
FIFO
39] Is there any difference int the following declarations?
int fun(int arr[]);
int fun(int arr[2]);
YES.
NO.
40] Which among the following is odd one out?
printf
fprintf
putchar
scanf
41] A program must have a main()
TRUE.
FALSE.
42] Which of the following is not a stream that is opened by every c program?
stdlog
stdout
stdin
stderr
43] Which of the following keyword does not indicate a storage class?
const keyword
extern keyword
static keyword
auto keyword
44] 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;
}
hai this is if
hai this is else
prints nothing
Compile Time Error
45] In a function two return statements should never occur.
TRUE.
FALSE.
46] Conditional operator should be prefixed if statement
TRUE.
FALSE.
47] How many times the while loop will get executed if a short int is 2 byte wide?

#include<stdio.h>
int main()
{
int j=1;
while(j <= 255)
{
printf("%c %d\n", j, j);
j++;
}
return 0;
}
Infinite times
255 times
256 times
254 times
48] Which of the following expressions is true for the below code fragment?
struct s{
int i;
float f;
};

union u {
int i;
float f;
};
sizeof(struct s) > sizeof(union u)
sizeof(struct s) < sizeof(union u)
sizeof(struct s) == sizeof(union u)
sizeof(struct s) <= sizeof(union u)
49] Default case should be present in a switch statement
TRUE.
FALSE.

50] What will be the output of the program?

#include<stdio.h>

int main()
{
void fun(char*);
char a[100];
a[0] = 'A'; a[1] = 'B';
a[2] = 'C'; a[3] = 'D';
fun(&a[0]);
return 0;
}
void fun(char *
{
a++;
printf("%c", *;
a++;
printf("%c", *;
}
AB
BC
CD
No output

You might also like