Vous êtes sur la page 1sur 26

CppBuzz.

com Search topic


Home C C++ Java Python Perl PHP SQL JavaScript Linux Online Test Forum

Learn Essential Digital Tools


Use free digital tools to achieve personal and professional goals

Applied Digital Skills OPEN

Home » C » C Objective Questions for Experts

C Objective Questions for Experts : 52

Question: 1

Can we declare
function inside
t t f C

(A) Yes
(B) No
(C) Depends on Compiler
(D) Yes but run time error

Show Ans

Compiler Forum
Expert structure[Posted by: Admin | Chicago, USA]

Question: 2

What is storage
class for variable A
in below code?

void main()
{
int A;
A = 10;
printf("%d", A);
}

(A) extern
(B) auto
(C) register
(D) static

Show Ans
Compiler Forum
Expert storgeclass[Posted by: Admin | Chicago, USA]

Question: 3

What is the output


of below program?

void main()
{
for(; ;)
for(; ;)

printf("Hello..");
}

(A) Compilation Error


(B) Runtime Error
(C) Hello is printed one time
(D) Hello is printed infinite times

Show Ans

Compiler Forum
Expert loops[Posted by: Admin | Chicago, USA]

Question: 4

What is output of
below program?

void main()
{
for(; ;);
for(; ;);
printf("Hello");

(A) Compilation Error


(B) Runtime Error
(C) Nothing is printed
(D) Hello is printed infinite times

Show Ans

Compiler Forum
Expert loops[Posted by: Admin | Chicago, USA]
Question: 5

What is the output


of below program?
void main()
{
int i;

for(i = 0,i<5,i++)
{
printf("Hello");
}
}

(A) Hello is printed 5 times


(B) Compilation Error
(C) Runtime Error
(D) Hello is printed 4 times

Show Ans

Compiler Forum
Expert loops[Posted by: Admin | Chicago, USA]

Applied Digital Skills

Learn Essential Digital Tools


Use free digital tools to achieve personal
and professional goals

Learn more

Question: 6

What is output of
below program?

void main()
{
int i;
for(i=0; i<5;
++i++)
{
printf("Hello");
}
}
(A) Hello is printed 5 times
(B) Compilation Error
(C) Hello is printed 2 times
(D) Hello is printed 3 times

Show Ans

Compiler Forum
Expert loops[Posted by: Admin | Chicago, USA]

Question: 7

What is output of
below program?
void main()
{
int i,j;
for(i =
0,j=0;i<5;i++)
{
printf("%d%d--
",i,j);
}

(A) 0--01--12--23--34--
(B) 00--10--20--30--40--
(C) Compilation Error
(D) 00--01--02--03--04--

Show Ans

Compiler Forum
Expert loops[Posted by: Admin | Chicago, USA]

Question: 8

How many times


CppBuzz.com is
printed on console?
void main()
{
int a = 0;
while(a==0)
{

printf("CppBuzz.com"
)

(A) 0 times
(B) Infinite times (Untill Stack is overflow)
(C) 1 time
(D) Nothing is printed
Show Ans

Compiler Forum
Expert loops[Posted by: Admin | Chicago, USA]

Question: 9

How many times


CppBuzz.com is
printed?
void main()
{
int a = 0;
while(a++ < 5-++a)
printf("CppBuzz.com"
)

(A) 5 times
(B) 4 times
(C) 2 times
(D) 1 time

Show Ans

Compiler Forum
Expert loops[Posted by: Admin | Chicago, USA]

Question: 10

int main()
{
int x;
x=10,20,30;
printf("%d",x);
return 0;
}

(A) 10
(B) 20
(C) 30
(D) Compilation Error

Show Ans

Compiler Forum
Expert operators[Posted by: Admin | Chicago, USA]
Question: 11

int main()
{
int a = 5;
int b = 10;
int c = a+b;
printf("%i",c);
}

(A) 0
(B) 15
(C) Undefined i
(D) Any other Compiler Error

Show Ans

Compiler Forum
EXpert datatype[Posted by: Admin | Chicago, USA]

Question: 12

int main()
{
int _ = 10;
int __ = 20;
int ___ = _
+ __;

printf("__%d",___);
return 0;
}
(A) Compilation Error
(B) Runtime Error
(C) __0
(D) __30

Show Ans

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

Question: 13

int x = 10;

int main()
{
int x = 0;
printf("%d",x);
return 0;
}

(A) 10
(B) 0
(C) Compilation Error
(D) Undefined

Show Ans

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

Question: 14

What is sizeof() in
C?

(A) Operator
(B) Function
(C) Macro
(D) None of these

Show Ans

Compiler Forum
Expert operators[Posted by: Admin | Chicago, USA]
Question: 15

Is it possible to
write C program
hi h it i t lf?

(A) Yes
(B) No

Show Ans

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

Question: 16

How many times


cppbuzz.com is
printed?

int main()
{

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

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

Show Ans
Compiler Forum
Expert conditional[Posted by: Admin | Chicago, USA]

Question: 17

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

int main(int argc,


char *argv[]) {
char
buffer[4];
itoa(123,
buffer, 10);

i tf("% "

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

Show Ans

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

Question: 18

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

int main(int argc,


char *argv[]) {
char temp[20];
gcvt(23.45, 3,
temp);
printf("%s",
temp);
t 0

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

Show Ans

Compiler Forum
Expert function[Posted by: Admin | Chicago, USA]
Question: 19

#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
) ;

t 0

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

Show Ans

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

Question: 20

#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) %

Show Ans
Compiler Forum
Expert function[Posted by: Admin | Chicago, USA]

Question: 21

Which compilation
unit is responsible
f ddi h d

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

Show Ans

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

Question: 22

What is the
extension of output
fil d d b

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

Show Ans
Compiler Forum
Expert preprocessor[Posted by: Admin | Chicago, USA]

Question: 23

__FILE__ is
predefined macro and
t i th t

(A) Yes
(B) No

Show Ans

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

Question: 24

Which of the
following ways are
correct to include
h d fil i C

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

Show Ans

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

Question: 25

Which one of the


following is invalid
i C

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

Show Ans

Compiler Forum
Expert macros[Posted by: Admin | Chicago, USA]
Question: 26

Which gcc option is


used to generate
bl d f C

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

Show Ans

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

Question: 27

Which macro is used


to insert assembly
d i C

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

Show Ans

Compiler Forum
Expert gcc[Posted by: Admin | Chicago, USA]
Question: 28

Which macro is used


to insert assembly
d i C

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

Show Ans

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

Question: 29

Which command is to
compile C code
ith t li ki

(A) gcc -o cppbuzz.c


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

Show Ans

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

Question: 30

Which gcc flag is


used to genarate
d b i f ti

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

Show Ans

Compiler Forum
Expert gcc[Posted by: Admin | Chicago, USA]
Applied Digital Skills

Learn Essential Digital Tools


Use free digital tools to achieve personal
and professional goals

Learn more

Question: 31

Which gcc flag is


used to generate
i d b

(A) gcc -g0


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

Show Ans

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

Question: 32

Which gcc flag is


used to enable all
C il i ?

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

Show Ans

Compiler Forum
Expert gcc[Posted by: Admin | Chicago, USA]
Question: 33

//Program is
compiled on Dev-C++
(32 bit) compiler
#include<stdio.h>
#include<string.h>

int main()
{
char arr[] =
"CppBuzz.com";
printf("%d-
%d" [0]

(A) D-Q
(B) D-A
(C) 67-112
(D) 68-113

Show Ans

Compiler Forum
Expert arrays[Posted by: Admin | Chicago, USA]

Question: 34

What should be the


output of this
program?
#include<stdio.h>

int main()
{
FILE *fp;
char c[1024];
fp =
fopen("test.txt",
"r"); // "Kernighan
and Ritchie"
c[0] = getc(fp);
fseek(fp, 0,
SEEK_END);
f k(f 7L

(A) Kernig
(B) ernigh
(C) Kernigh
(D) Ritch

Show Ans

Compiler Forum
Expert filehandling[Posted by: Admin | Chicago, USA]
Question: 35

Which of the
following Linux
d i d t

(A) findsize a.out


(B) size a.out
(C) calc a.out
(D) ls -ltr a.out

Show Ans

Compiler Forum
Expert compilation[Posted by: Admin | Chicago, USA]

Applied Digital Skills

Learn Essential Digital Tools


Use free digital tools to achieve personal
and professional goals

Learn more

Question: 36

#include <iostream>
using namespace std;
int main ()
{
int x, y;
x = 2;
y = ++x *
++x;
cout << x <<
y;
x = 2;
y = x++ *
++x;
cout << x <<
y;
t 0

(A) 412412
(B) 41649
(C) 49416
(D) 41649

Show Ans

Compiler Forum
Expert operators[Posted by: Admin | Chicago, USA]

Question: 37

What is important
difference between
t t & i ?

(A) There is no difference


(B) Union takes less memory
(C) Union is faster
(D) Structure is faster

Show Ans

Compiler Forum
Expert structure[Posted by: Admin | Chicago, USA]

Question: 38

Can we compare two


structures using any
b ilt i t ?

(A) Yes
(B) No

Show Ans

Compiler Forum
Expert structure[Posted by: Admin | Chicago, USA]

Question: 39

Which predefined
function is used to
it h l

(A) write()
(B) fwrite()
(C) swrite()
(D) None of the above
Show Ans

Compiler Forum
Expert structure[Posted by: Admin | Chicago, USA]

Question: 40

How to minimize the


padding issues with
t t ?

(A) Order members from largest to smallest


(B) Order memebers from smallest to largest
(C) By using only char data type
(D) By using referencial pointer

Show Ans

Compiler Forum
Expert operators[Posted by: Admin | Chicago, USA]

Great Savings on
Supplements

YesWellness Learn more

Question: 41

The input to the


Assembler in the
il ti

(A) Assembly Code


(B) .i file produced by Preprocessor
(C) Object Code
(D) Source Code

Show Ans
Compiler Forum
Expert assembler[Posted by: Admin | Chicago, USA]

Question: 42

What does .txt


section contains?

(A) Executable Instructions


(B) Un-initialized Global Variables
(C) Un-initialized Static Variables
(D) Initialized Static & Global Variables

Show Ans

Compiler Forum
Expert compilation[Posted by: Admin | Chicago, USA]

Question: 43

Find the output of


below code. Is it
a++ or ++b in
statement a+++b.

#include <stdio.h>

int main()
{
int a=5, b=2;
printf("%d",
a+++b);

(A) Compilation Error


(B) 8
(C) 7
(D) 0

Show Ans

Compiler Forum
Expert operators[Posted by: Admin | Chicago, USA]

Question: 44
int main()
{
int a = 1;
short int b = 2;
float c = 3;
if(sizeof((a == 2)
? c : b) ==
sizeof(float))
{

printf("float");
}
else
if(sizeof((a == 2) ?
c : b) ==
sizeof(short int))
{

(A) float
(B) short int
(C) nothing
(D) compilation error

Show Ans

Compiler Forum
Expert operators[Posted by: Varun Kumar Reddy | Bangalore]

Question: 45

#include<stdio.h>
int main(void)
{
char str1[] =
"Hello. How are
you?";
char str2[21];
int pos;

for(pos=0;
pos<21; pos++);
{
str2[pos] =
str1[pos];
}

printf("str1: %s,
t 2 % " t 1

(A) str1: Hello. How are you?, str2: Hello. How are you?
(B) str1: Hello. How are you?, str2: Hello. How are you?nullnull
(C) str1: Hello. How are you?, str2: Hello. How are you?garbagevalue
(D) str1: Hello. How are you?, str2: garbagevalue

Show Ans

Compiler Forum
Expert arrays[Posted by: Admin | Chicago, USA]
Great Savings on
Supplements

YesWellness Learn more

Question: 46

#include<stdio.h>

int main()
{
int a = 0,
b=1,c=2,d;

d = ++a || b++ &&


c++ && a++;

printf("%d %d %d
%d", a,b,c,d);

t 0

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

Show Ans

Compiler Forum
Expert operators[Posted by: Admin | Chicago, USA]

Question: 47
Find output of below
C program

#include <stdio.h>

int main()
{
char *_ptr;
*_ptr =
malloc(10);
*_ptr = 999;

printf("%d",*_ptr);
t 0

(A) 999
(B) 10
(C) 0
(D) Segmentation fault

Show Ans

Compiler Forum
Expert malloc_free[Posted by: Admin | Chicago, USA]

Question: 48

#include <stdio.h>

int main()
{
char *_ptr =
malloc(100);
strcpy(_ptr,
"cppbuzz");
memset(_ptr,
NULL, sizeof(_ptr));
if(*_ptr == NULL)
printf("NULL");
else

printf("%s",_ptr);
t 0

(A) NULL
(B) cppbuzz
(C) Nothing is printed
(D) Typecasting Error

Show Ans

Compiler Forum
Expert malloc_free[Posted by: Admin | Chicago, USA]
Question: 49

#include <stdio.h>

int main()
{
char *_ptr =
malloc(100);
if(_ptr!=NULL)
free(_ptr);

free(_ptr);
return 0;
}

(A) Program runs smoothly


(B) Compilation Error
(C) Runtime Error- Program crashes

Show Ans

Compiler Forum
Expert malloc_free[Posted by: Admin | Chicago, USA]

Question: 50

#include <stdio.h>

int main()
{
char * _ptr =
NULL;
_ptr = malloc(0);
if(_ptr==NULL)
printf("_ptr is
NULL");
else printf("
_ptr not NULL ");
printf(" %p ",
_ptr);
*_ptr = '@';
i tf(" % "

(A) _ptr is NULL 0x21f3010 @


(B) _ptr not NULL 0x21f3010 @
(C) Runtime Error: Segmentation Fault
(D) _ptr not NULL 0x21f3010

Show Ans

Compiler Forum
Expert malloc_free[Posted by: Admin | Chicago, USA]
Track
like
it’s
2019.
LEARN MORE

Question: 51

#include <stdio.h>

typedef enum{
Male, Female
}SEX;

void main()
{
SEX var = Male;
SEX var1 = Female;
printf("%s
%s",var, var1);
}

(A) Male Female


(B) 0 1
(C) Runtime error (Segmentation fault)
(D) Compilation Error: Can't cast

Show Ans

Compiler Forum
Expert enum[Posted by: Admin | Chicago, USA]

Question: 52
#include <stdio.h>

typedef enum{
Male, Female=-1
}SEX;

void main()
{
SEX var = Male;
SEX var1 = Female;
printf("%d
%d",var, var1);
}

(A) Compilation Error


(B) Garbage Value 0
(C) -1 -1
(D) 0 -1

Show Ans

Compiler Forum
Expert enum[Posted by: Admin | Chicago, USA]

Compile C++ code here Upload your Questions

Browse C++ Categories

Loops Conditional Functions Operators Structure Enum FileHandling Data Types Inheritance Pointers
Classes & Objects Vtable Type Casting New & Delete Namespaces Reference Variables Virtual Functions
Abstract Class STL Singleton Class Exceptions C++ 11 C++ 14 C++ 17 gcc/g++ others

Switch to C Questions

Vous aimerez peut-être aussi