Arithmetic Operators In C MCQs: Arithmetic Operators MCQs

Arithmetic Operators In C MCQs. Multiple Choice Questions on the topic of Arithmetic Operators In C Programming Language.

 

Arithmetic Operators In C MCQs

 

What will be the output of the following C code ??

#include <stdio.h>
int main()
{
int a = 10, b = 5, c = 5;
int d;
d = a == (b + c);
printf(“%d”, d);
}

a) Syntax error
b) 1
c) 10
d) 5

View Answer

b) 1

 

What will be the output of the following C code ??

#include <stdio.h>
void main()
{
int y = 3;
int x = 5 % 2 * 3 / 2;
printf(“Value of x is %d”, x);
}

a) Value of x is 1
b) Value of x is 2
c) Value of x is 3
d) Compile time error

View Answer

a) Value of x is 1

 

What will be the output of the following C code ??

#include <stdio.h>
int main()
{
int a = 10;
double b = 5.6;
int c;
c = a + b;
printf(“%d”, c);
}

a) 15
b) 16
c) 15.6
d) 10

View Answer

a) 15

 

What will be the output of the following C code ??

#include <stdio.h>
void main()
{
int x = 5.3 % 2;
printf(“Value of x is %d”, x);
}

a) Value of x is 2.3
b) Value of x is 1
c) Value of x is 0.3
d) Compile time error

View Answer

d) Compile time error

 

Arithmetic Operators In C MCQs

 

Which among the following are the fundamental arithmetic operators, i.e, performing the desired operation can be done using that operator only ??

a) +, –
b) +, -, %
c) +, -, *, /
d) +, -, *, /, %

View Answer

a) +, –

 

What will be the final value of x in the following C code ??

#include <stdio.h>
void main()
{
int x = 5 * 9 / 3 + 9;
}

a) 3.75
b) Depends on compiler
c) 24
d) 3

View Answer

c) 24

 

Which of the following data type will throw an error on modulus operation(%) ??

a) char
b) short
c) int
d) float

View Answer

d) float

 

What will be the output of the following C code ??

#include <stdio.h>
int main()
{
int i = -5;
i = i / 3;
printf(“%d\n”, i);
return 0;
}

a) Implementation defined
b) -1
c) -3
d) Compile time error

View Answer

b) -1

 

Arithmetic Operators In C MCQs

 

Which of the following is not an arithmetic operation ??

a) a * = 10;
b) a / = 10;
c) a ! = 10;
d) a % = 10;

View Answer

c) a ! = 10;

 

What will be the output of the following C code ??

#include <stdio.h>
int main()
{
int i = 5;
i = i / 3;
printf(“%d\n”, i);
return 0;
}

a) Implementation defined
b) 1
c) 3
d) Compile time error

View Answer

b) 1

 

What is the precedence of arithmetic operators (from highest to lowest) ??

a) %, *, /, +, –
b) %, +, /, *, –
c) +, -, %, *, /
d) %, +, -, *, /

View Answer

a) %, *, /, +, –

 

Arithmetic Operators In C MCQs

 

What will be the output of the following C code ??

#include <stdio.h>
int main()
{
int i = 3;
int l = i / -2;
int k = i % -2;
printf(“%d %d\n”, l, k);
return 0;
}

a) Compile time error
b) -1 1
c) 1 -1
d) Implementation defined

View Answer

b) -1 1

 

What will be the output of the following C code ??

#include <stdio.h>
void main()
{
int a = 3;
int b = ++a + a++ + –a;
printf(“Value of b is %d”, b);
}

a) Value of x is 12
b) Value of x is 13
c) Value of x is 10
d) Undefined behaviour

View Answer

d) Undefined behaviour

 

What will be the output of the following C code ??

#include <stdio.h>
int main()
{
int i = -3;
int k = i % 2;
printf(“%d\n”, k);
}

a) Compile time error
b) -1
c) 1
d) Implementation defined

View Answer

b) -1

 

More Posts

Leave a Comment

Your email address will not be published. Required fields are marked *

error: Content is protected !!