100% found this document useful (3 votes)
412 views6 pages

01 - OperatorsWithAnswers

The document contains 16 coding questions and their answers. It tests knowledge of C programming concepts like data types, operators, precedence, conditional statements, loops, functions etc. Some key concepts tested include: integer and floating point data types and operations; logical and bitwise operators; operator precedence; conditional statements; printing output. The questions involve analyzing short code snippets and predicting their output to test understanding of how C code executes step-by-step.

Uploaded by

Sanket Naik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
412 views6 pages

01 - OperatorsWithAnswers

The document contains 16 coding questions and their answers. It tests knowledge of C programming concepts like data types, operators, precedence, conditional statements, loops, functions etc. Some key concepts tested include: integer and floating point data types and operations; logical and bitwise operators; operator precedence; conditional statements; printing output. The questions involve analyzing short code snippets and predicting their output to test understanding of how C code executes step-by-step.

Uploaded by

Sanket Naik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1.

#include <stdio.h>
int main( void )
{
int i = 0X7 + 07 + 7;

printf("\n %d + %d + %d =%x",0X7,07,7, i);


printf("\n %d + %d + %d =%o",0X7,07,7, i);

return 0;
}

A. 7 + 7 + 7 = 15
7 + 7 + 7 = 25

B. 7 + 7 + 7 = 21
7 + 7 + 7 = 15

C. 7 + 1 + 7 = 15
7 + 7 + 7 = 21

D. 1 + 1 + 7 = 9
7 + 7 + 7 = 21
Answer: A

2.
#include <stdio.h>
int main( void )
{
printf("%d", (sizeof(10.222)*sizeof(10.222f))/sizeof(void) * sizeof(10.222));
return 0;
}

A. 128
B. 256
C. 512
D. 64
Answer: B

3.
Suppose a,b,c are integer variables with values 5,6,7 respectively.
What is the value of expression: !((b+c)>(a+10))

A. 1
B. 6
C. 15
D. 0
Answer: A

4.
What the below statement will print if a=10. printf("%d %d",a, !a++);
A. 10 11
B. 11 0
C. 11 10
D. 0 11
Answer: B
5.
What will be output of following code ?
#include <stdio.h>
int main( void )
{
int x = 1, y = 0, z = 5;

int a = x && y || z++;


printf("%d", z);

return 0;
}

A. 6
B. 5
C. 0
D. Varies
Answer: A

6.
What will be output of following code ?
#include <stdio.h>
int main( void )
{
int x = 1, y = 0, z = 5;
int a = x && y++ && z++;
printf("y=%d z=%d ", y,z);
return 0;
}

A. y=1 z=7
B. y=1 z=5
C. y=0 z=4
D. y=0 y=0
Answer: B

7.
What will be output of following code ?
#include <stdio.h>
int main( void )
{
int i = 1, j=0;

j = (i++ && (i == 1));


printf("\n i=%d j=%d",i, j);

return 0;
}

A. i=1 j=1
B. i=2 j=0
C. i=1 j=0
D. i=2 j=1
Answer: B
8.
What will be output of following code ?
#include <stdio.h>
int main( void )
{
int i=0, j=1, k=2, m;

m = i++ || j++ || k++;


printf("%d %d %d %d", m, i, j, k);

return 0;
}

A. 1 1 0 2
B. 1 1 0 3
C. 1 1 2 2
D. 0 1 2 3
E. None of these
Answer: C

9.
What will be output on 64 bit compiler ?
#include <stdio.h>
int main( void )
{
printf("\n%d",sizeof((int) &main)+2);

return 0;
}

A. 8
B. 6
C. 4
D. 10
Answer: B

10.
What will be output of following code on 64 bit Compiler ?
#include <stdio.h>
int main( void )
{
int a = 10;

double d = 10.21;
printf("%d", sizeof(a+d));

return 0;
}

A. 4
B. 16
C. 8
D. 12
Answer: C
11.
What will be printed as the result of the operation below.(gcc compiler)
#include <stdio.h>
int main( void )
{
float x;

x= 0.35 == 3.5/10;
printf("%f", x);

return 0;
}

A. 0.000000
B. 1.000000
C. 1.0
D. 0.0
Answer: B

12.
#include<stdio.h>
int main(void)
{
int t,a=5,b=10,c=15;

t=(++a && ++b, ++a), ++a || ++c;


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

return 0;
}

A. 7 8 11 15
B. 6 7 10 14
C. 1 8 10 15
D. 6 18 11 15
Answer : C

13.
What value of c will get printed
#include <stdio.h>
int main(void)
{
int a,b,c;

a=10;
b=20;
c=printf("%d",a)+ ++b;
printf(" %d",c);

return 0;
}
A. 10 23
B. 10 22
C. 10 30
D. Compilation Error
Answer: A
14.
Given the following program fragment
#include <stdio.h>
int main( void )
{
int i, j, k;
i = 3;

j =2*(i++);
k =2*(++i);

printf("\n j=%d k=%d", j, k);

return 0;
}

which one of the given option is correct for above code?


A. j = 6, k = 10
B. i = 5, k = 6
C. j = 6, k = 8
D. i = 4, j = 6
Answer: A

15.
What will be the output ?
#include <stdio.h>
int main( void )
{
if(1++,0--)
{
printf("True");
}
else
{
printf("False");
}
return 0;
}

A. Compile time Error


B. True
C. False
D. Nothing will print
Answer: A
16.
#include <stdio.h>
int main( void )
{
int a;

a = 1, 2, 3;
printf("%d", a);

return 0;
}

A. 3
B. 2
C. 1
D. compile time error
Answer: C

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy