100 MCQ on C Programming

Question: 51

What is the extension of File produced by compiler on Windows?

(A) .a
(B) .exe
(C) .out
(D) .obj

Compiler  Forum
[ Beginner : compilation ] [ Posted by - Admin : Chicago, USA ]


Question: 52

#include "stdio.h"
int main()
{
int a@ = 10;
printf("%d", a@);
return 0;
}

(A) 10
(B) 10@
(C) @
(D) [Error] stray '@' in program

Compiler  Forum
[ Beginner : variables ] [ Posted by - Admin : Chicago, USA ]


Question: 53

#include "stdio.h"
int main()
{
int a = 10;
printf("%d", a);
int a = 20;
printf("%d",a);
return 0;
}

(A) 1020
(B) 1010
(C) 2020
(D) Error: Redeclartion of a

Compiler  Forum
[ Beginner : variables ] [ Posted by - Admin : Chicago, USA ]


Question: 54

#include "stdio.h"
int a = 20;
int main()
{
int a = 10;
printf("%d", ::a);
return 0;
}

(A) 10
(B) 20
(C) ::20
(D) ::10

Compiler  Forum
[ Beginner : variables ] [ Posted by - Admin : Chicago, USA ]


Question: 55

#include "stdio.h"
int a = 20;
int main()
{
int a = 10;
printf("%d", a);
return 0;
}

(A) 20
(B) Ambiguity Error
(C) 10
(D) 0

Compiler  Forum
[ Beginner : variables ] [ Posted by - Admin : Chicago, USA ]


Question: 56

#include "stdio.h"
int main()
{
int __a = 10;
printf("%d",__a);
return 0;
}

(A) Compilation Error
(B) 10
(C) __10
(D) __a

Compiler  Forum
[ Beginner : variables ] [ Posted by - Admin : Chicago, USA ]


Question: 57

#include "stdio.h"
int main()
{
int 2a = 10;
printf("%d",2a);
return 0;
}

(A) 10
(B) 20
(C) 2a
(D) Compilation Error

Compiler  Forum
[ Practitioner : variables ] [ Posted by - Admin : Chicago, USA ]


Question: 58

#include "stdio.h"
int main()
{
int @a = 10;
printf("%d",@a);
return 0;
}

(A) 10
(B) @10
(C) 10@
(D) Compilation Error

Compiler  Forum
[ Beginner : variables ] [ Posted by - Admin : Chicago, USA ]


Question: 59

#include  "stdio.h"
int main()
{
    int a = 10, b = 20;
    if(a=b)
    {   
        printf("Easy");
    }
    else
    {
        printf("Hard");
    }

    return 0;
}

(A) Easy
(B) Hard
(C) EasyHard
(D) Error in program

Compiler  Forum
[ Practitioner : loops ] [ Posted by - Admin : Chicago, USA ]


Question: 60

#include  "stdio.h"
int main()
{
    if(printf("C programming is"))
    {   
        printf("Easy");
    }
    else
    {
        printf("Hard");
    }

    return 0;
}

(A) Easy
(B) Hard
(C) C programming is Easy
(D) None of the above

Compiler  Forum
[ Practitioner : loops ] [ Posted by - Admin : Chicago, USA ]


Question: 61

#include  "stdio.h"
int main()
{
    int a = 0;
    if(a = printf("How old are you?"))
    {   
        printf("%d - too young", a);
        
    }

    return 0;
}

(A) 0 - too young
(B) Compilation Error
(C) Nothing is printed
(D) How old are you? 16 - too young

Compiler  Forum
[ Practitioner : loops ] [ Posted by - Admin : Chicago, USA ]


Question: 62

#include  "stdio.h"
int main()
{
    int a;
    if(a == printf("cppbuzz-"))
    {   printf("Bad place to learn C");
        
    }
    else
    {
        printf("Good place to learn C");
    }
        
    return 0;
}

(A) cppbuzz-Bad place to learn C
(B) cppbuzz-Good place to learn C
(C) Bad place to learn C
(D) Good place to learn C

Compiler  Forum
[ Practitioner : conditional ] [ Posted by - Admin : Chicago, USA ]


Question: 63

#include  "stdio.h"
int main()
{
    int a;
    if(a = printf("cppbuzz-"))
    {
        printf("Good place to learn C");
    }
    else
    {
        printf("Bad place to learn C");
    }
        
    return 0;
}

(A) cppbuzz-Good place to learn C
(B) cppbuzz-Bad place to learn C
(C) Good place to learn C
(D) Bad place to learn C

Compiler  Forum
[ Practitioner : conditional ] [ Posted by - Admin : Chicago, USA ]


Question: 64

Which gcc flag is used to enable all Compiler warnings?

(A) gcc -W
(B) gcc -w
(C) gcc -Wall
(D) gcc - wall

Compiler  Forum
[ Expert : gcc ] [ Posted by - Admin : Chicago, USA ]


Question: 65

Which gcc flag is used to generate maximum debug information?

(A) gcc -g0
(B) gcc -g1
(C) gcc -g
(D) gcc -g3

Compiler  Forum
[ Expert : gcc ] [ Posted by - Admin : Chicago, USA ]


Question: 66

Which gcc flag is used to genarate debug information for any binary file?

(A) gcc -g
(B) gcc -a
(C) gcc -e
(D) gcc -b

Compiler  Forum
[ Expert : gcc ] [ Posted by - Admin : Chicago, USA ]


Question: 67

Which command is to compile C code without linking using gcc compiler?

(A) gcc -o cppbuzz.c
(B) gcc -c cppbuzz.c
(C) gcc -e cppbuzz.c
(D) gcc cppbuzz.c

Compiler  Forum
[ Expert : gcc ] [ Posted by - Admin : Chicago, USA ]


Question: 68

Which macro is used to insert assembly code in C program (VC++ compiler)?

(A) __asm__
(B) _asm_
(C) __asm
(D) asm

Compiler  Forum
[ Expert : gcc ] [ Posted by - Admin : Chicago, USA ]


Question: 69

Which macro is used to insert assembly code in C program (GCC compiler)?

(A) __asm__
(B) _asm_
(C) __asm
(D) asm

Compiler  Forum
[ Expert : gcc ] [ Posted by - Admin : Chicago, USA ]


Question: 70

Which gcc option is used to generate assembly code from C code on Linux?

(A) -asm
(B) -S
(C) -o
(D) -c

Compiler  Forum
[ Expert : gcc ] [ Posted by - Admin : Chicago, USA ]


Question: 71

What is the job of Assembler in C programming?

(A) It converts source code into assembly code
(B) It converts a assembly language program into machine language
(C) It convert code generated by Preprocessor to assembly code
(D) None of the above

Compiler  Forum
[ Beginner : gcc ] [ Posted by - Admin : Chicago, USA ]


Question: 72

Will compiler produce any compilation error if same header file is included two times?

(A) Yes
(B) No

Compiler  Forum
[ Beginner : preprocessor ] [ Posted by - Admin : Chicago, USA ]


Question: 73

Which of the following ways are correct to comment out preprocessing of any line?

(A) -- #include<stdio.h>
(B) // #include<stdio.h>
(C) ''#include<stdio.h>
(D) ##include<stdio.h>

Compiler  Forum
[ Practitioner : preprocessor ] [ Posted by - Admin : Chicago, USA ]


Question: 74

What should be the output of below program?

#define # @
@include "stdio.h"

int main()
{
 	printf("CppBuzz.com");
 	return 0;
}

(A) CppBuzz.com
(B) Nothing
(C) Compilation Error
(D) Depends on Compilor

Compiler  Forum
[ Practitioner : preprocessor ] [ Posted by - Admin : Chicago, USA ]


Question: 75

Does this program get compiled successfully?

#include stdio.h

int main()
{
	printf("CppBuzz.com");
	return 0;
 	
}

(A) Yes
(B) No
(C) Depends on Compiler

Compiler  Forum
[ Beginner : loops ] [ Posted by - Admin : Chicago, USA ]


Question: 76

What should be the output of below program ?

##include "stdio.h"

int  main()
{
	printf("CppBuzz.com");
	return 0;
 	
}

(A) CppBuzz.com
(B) No output
(C) Compilation Error in preprocessing
(D) None of above

Compiler  Forum
[ Practitioner : preprocessor ] [ Posted by - Admin : Chicago, USA ]


Question: 77

Which one of the following is invalid macro in C programming?

(A) #pragma
(B) #error
(C) #ifndef
(D) #elseif

Compiler  Forum
[ Expert : macros ] [ Posted by - Admin : Chicago, USA ]


Question: 78

Which of the following ways are correct to include header file in C program?

(A) #include<stdio.h>
(B) #include"stdio.h"
(C) Both A & B

Compiler  Forum
[ Practitioner : datatype ] [ Posted by - Admin : Chicago, USA ]


Question: 79

Which of the following ways can be used to include header file in C programs?

(A) #include<stdio.h>
(B) #include"stdio.h"
(C) Both A & B

Compiler  Forum
[ Practitioner : preprocessor ] [ Posted by - Admin : Chicago, USA ]


Question: 80

Which of the following ways are correct to include header file in C program?

(A) #include<stdio.h>
(B) #include"stdio.h"
(C) Both A & B

Compiler  Forum
[ Expert : datatype ] [ Posted by - Admin : Chicago, USA ]


Question: 81

__FILE__ is predefined macro and contains the current filename as a string. Is this true/false?

(A) Yes
(B) No

Compiler  Forum
[ Expert : preprocessor ] [ Posted by - Admin : Chicago, USA ]


Question: 82

What is the extension of output file produced by Preprocessor?

(A) .h
(B) .exe
(C) .i
(D) .asm

Compiler  Forum
[ Expert : preprocessor ] [ Posted by - Admin : Chicago, USA ]


Question: 83

Is there any limit in adding no of header files in program?

(A) Yes
(B) No

Compiler  Forum
[ Practitioner : preprocessor ] [ Posted by - Admin : Chicago, USA ]


Question: 84

Which compilation unit is responsible for adding header files content in the source code?

(A) Linker
(B) Compiler
(C) Assembler
(D) Preprocessor

Compiler  Forum
[ Expert : preprocessor ] [ Posted by - Admin : Chicago, USA ]


Question: 85

Preprocessor includes content of header files added in source code?

(A) Yes
(B) No

Compiler  Forum
[ Beginner : preprocessor ] [ Posted by - Admin : Chicago, USA ]


Question: 86

In compilation process at what sequence Preprocessor comes into picture?

(A) 1
(B) 2
(C) 3
(D) 4

Compiler  Forum
[ Beginner : preprocessor ] [ Posted by - Admin : Chicago, USA ]


Question: 87

What is the Latest Version of C Language?

(A) C11
(B) C99
(C) C95
(D) C89

Compiler  Forum
[ Practitioner : other ] [ Posted by - Admin : Chicago, USA ]


Question: 88

The ASCII code of ‘0’ (zero) is?

(A) 48D
(B) 32H
(C) 0011 1000
(D) 42H

Compiler  Forum
[ Beginner : loops ] [ Posted by - Admin : Chicago, USA ]


Question: 89

The ASCII code of ‘A’ is?

(A) 66D
(B) 41H
(C) 0100 0010
(D) 0110 0011

Compiler  Forum
[ Beginner : other ] [ Posted by - Admin : Chicago, USA ]


Question: 90

Numbers are stored and transmitted inside a computer in which format?

(A) binary form
(B) ASCII code form
(C) decimal form
(D) alphanumeric form

Compiler  Forum
[ Beginner : other ] [ Posted by - Admin : Chicago, USA ]


Question: 91

#include <stdio.h>

char * f();
char a = 'a';

int main(int argc, char *argv[])
{	
char *temp = f();
printf("%%", temp);
return 0;
}

char *f()
{ 
return &a;
}

(A) a
(B) %a
(C) %%
(D) %

Compiler  Forum
[ Expert : function ] [ Posted by - Admin : Chicago, USA ]


Question: 92

#include "stdio.h"

char * f();
char a = 'a';

int main(int argc, char *argv[])
{	
char *temp = f();
printf("%&", temp);
return 0;
}

char *f()
{ 
return &a;
}

(A) a
(B) %
(C) Compilation Error
(D) Nothing is printed

Compiler  Forum
[ Practitioner : function ] [ Posted by - Admin : Chicago, USA ]


Question: 93

#include "stdio.h"
char * f();
char a = 'a';

int main(int argc, char *argv[])
{	
char *temp = f();
printf("%s", temp);
return 0;
}

char *f()
{ return &a;
}

(A) a
(B) "a"
(C) nothing
(D) Compilation Error

Compiler  Forum
[ Practitioner : function ] [ Posted by - Admin : Chicago, USA ]


Question: 94

#include <stdio.h>

int main(int argc, char *argv[]) {	

char str1 [] = "CppBuzz";
int a = 10;
char str2[12] ;
sprintf (str2, "%s-%d", str1, a) ;
printf ( "%s", str2 ) ; 

return 0;

}

(A) CppBuzz10
(B) CppBuzz-10
(C) CppBuzz 10
(D) Compilation Error

Compiler  Forum
[ Expert : function ] [ Posted by - Admin : Chicago, USA ]


Question: 95

#include "stdio.h"
#include "stdlib.h"

int main(int argc, char *argv[]) {	
    char temp[20];
    gcvt(23.45,2, temp);
    printf("%s", temp);
    return 0;
}

(A) .4
(B) 23
(C) 23.45
(D) 23.

Compiler  Forum
[ Practitioner : function ] [ Posted by - Admin : Chicago, USA ]


Question: 96

#include "stdio.h"
#include "stdlib.h"

int main(int argc, char *argv[]) {	
    char temp[20];
    gcvt(23.45, 3, temp);
    printf("%s", temp);
    return 0;
}

(A) 0
(B) 23.5
(C) 23.450000
(D) 23.4

Compiler  Forum
[ Expert : function ] [ Posted by - Admin : Chicago, USA ]


Question: 97

#include "stdio.h"
#include "stdlib.h"

int main(int argc, char *argv[]) {	
	 char buffer[4];
	 itoa(123, buffer, 10);
	 printf("%s", buffer);
	 return 0;
}

(A) 1234
(B) 12340
(C) 123
(D) 0

Compiler  Forum
[ Expert : function ] [ Posted by - Admin : Chicago, USA ]


Question: 98

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {	
	int a = atoi("100");
	printf("%d",a);
	return 0;
}

(A) 0
(B) 1
(C) 100
(D) 3

Compiler  Forum
[ Practitioner : function ] [ Posted by - Admin : Chicago, USA ]


Question: 99

How many times cppbuzz.com is printed?

int main()
{

if(printf("cppbuzz.com"))
printf("cppbuzz.com");

return 0;
}

(A) 1
(B) 2
(C) 0
(D) Compilation Error

Compiler  Forum
[ Expert : conditional ] [ Posted by - Admin : Chicago, USA ]


Question: 100

Is it possible to write C program which it print self?

(A) Yes
(B) No

Compiler  Forum
[ Expert : filehandling ] [ Posted by - Admin : Chicago, USA ]


Question: 101

Is it possible to return two values by any function?

(A) Yes
(B) No

Compiler  Forum
[ Practitioner : function ] [ Posted by - Admin : Chicago, USA ]