You are on page 1of 4

9/5/2017 C Programming Online Quiz - TutorialsPoint

C Programming Online Quiz


Advertisements
LAPCARE 6 CELL
Rs. 1,598.00
(details + delivery)

Questions Page Next Quiz

Following quiz provides Multiple Choice Questions (MCQs) related to C Programming Framework. You will have to read all the given
answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer
button. You can use Next Quiz button to check new set of questions in the quiz.

Q 1 - What is the output of the following code snippet?

#include<stdio.h>

main()
{
int const a = 5;

a++;
printf(%d,a);
}

A-5

B-6

C - Runtime error

D - Compile error

Show Answer

Q 2 - What is the size of the following union definition?

#include<stdio.h>

union abc {
char a,b,c,d,e,f,g,h;
int i;
}abc;

main()
{
printf( "%d", sizeof( abc ));
}

A-1

B-2

C-4

D-8

https://www.tutorialspoint.com/cprogramming/cprogramming_online_quiz.htm 1/4
9/5/2017 C Programming Online Quiz - TutorialsPoint
Show Answer

Q 3 - Following is the invalid inclusion of a file to the current program. Identify it.

A - #include <file>

B - #include file

C - #include < file

D - All of the above are invalid.

Show Answer

Q 4 - Does both the loops in the following programs prints the correct string length?

#include<stdio.h>

main()
{
int i;
char s[] = "hello";

for(i=0; s[i]; ++i);


printf("%d ", i);

i=0;
while(s[i++]);
printf("%d ", i);
}

A - Yes, both the loops prints the correct length

B - Only for loop prints the correct length

C - Only while loop prints the correct length

D - Compile error in the program.

Show Answer

Q 5 - What is the output of the following statement?

#include<stdio.h>

main()
{
printf("%d", !0<2);
}

A-0

B-1

C - False

D - True

Show Answer

Q 6 - In C, what are the various types of real data type (floating point data type)?

A - Float, long double

B - long double, short int

C - float, double, long double

D - short int, double, long int, float

Show Answer

Q 7 - The equivalent pointer expression by using the array element a[i][j][k][2],

https://www.tutorialspoint.com/cprogramming/cprogramming_online_quiz.htm 2/4
9/5/2017 C Programming Online Quiz - TutorialsPoint

A - ((((a+m)+n)+o)+p)

B - *(*(*(*(a+i)+j)+k)+2)

C - *( (((a+m)+n)+o+p)

D - *( ((a+m)+n+o+p)

Show Answer

Q 8 - In the given below code, the function fopen()uses "r" to open the file source.txt in binary mode for which purpose?

#include<stdio.h>

int main ()
{
FILE *fp;

fp = fopen("source.txt", "r");
return 0;
}

A - For reading

B - For reading and writing

C - For creating a new file "source.txt" for reading

D - For creating a new file "source.txt" for writing

Show Answer

Q 9 - During preprocessing, the code #include<stdio.h> gets replaced by the contents of the file stdio.h.

A - Yes

B - During linking the code #include<stdio.h> replaces by stdio.h

C - During execution the code #include<stdio.h> replaces by stdio.h

D - During editing the code #include<stdio.h> replaces by stdio.h

Show Answer

Q 10 - If, the given below code finds the length of the string then what will be the length?

#include<stdio.h>

int xstrlen(char *s)


{
int length = 0;

while(*s!='\0')
{length++; s++;}
return (length);
}
int main()
{
char d[] = "IndiaMAX";

printf("Length = %d\n", xstrlen(d));


return 0;
}

A - Code returns error

B - Code returns the length 8

C - Code returns the length 6

D - Code returns the length 2

Show Answer

Questions Page
https://www.tutorialspoint.com/cprogramming/cprogramming_online_quiz.htm Next Quiz 3/4
9/5/2017 C Programming Online Quiz - TutorialsPoint

Questions Page Next Quiz

Advertisements

Write for us FAQ's Helping Contact


Copyright 2017. All Rights Reserved.

Enter email for newsletter go

https://www.tutorialspoint.com/cprogramming/cprogramming_online_quiz.htm 4/4

You might also like