# C PROGRAMS
C Quiz
➤ Identifiers & Data Types Quiz
➤ Octal Decimal & Hexadecimal
➤ Increment-Decrement Quiz
➤ Relational-Logical Quiz
➤ Arithmetic -Assignment Quiz
➤ Comma Operator Quiz
➤ Sizeof operator Quiz
➤ printf() Quiz Set-1
➤ printf() Quiz Set-2
➤ printf() Quiz Set-3
➤ printf() Quiz Set-4
➤ If statement Quiz in C
➤ If-else statement Quiz
Quiz on Arithmetic and Assignment Operators in C | Arithmetic operators are used to performing mathematical operations. The arithmetic operators can operate on any built-in data type.
Assignment operators are used to assigning the result of an expression to a variable. Syntax: Identifier = expression;
Here identifier generally represents a variable and expression represents a constant, a variable, or a more complex expression.
If you finding difficulties to solve these questions then first you should learn these:- Operators in C, Bitwise operators in C
C Quiz on Arithmetic and Assignment Operators
Find the output of the programs given Quiz on Arithmetic and Assignment Operators in C?
Q1) Find the output of the given C program.
#include<stdio.h>
int main()
{
int a = 2;
a += a += a += 3;
printf("%d",a);
return 0;
}
a) 9
b) 11
c) 30
d) 20
View Answer
Answer:- d) 20a+=a+=a+=3; it can written as a+=a+=a=a+3; a=2; Or, a+=a+=5; a=5; Or, a+=a=5+5; a=5; Or, a+=10; a=10; Or, a=a+10; a=10; Or, a=20. So, finally a=20.
Q2) Find the output of the given C program.
#include<stdio.h>
int main()
{
float a, b;
int c;
a = 5;
b = 2;
c = a/b;
printf("%d",c);
return 0;
}
a) 2
b) 2.000000
c) 3
d) 2.500000
View Answer
Answer:- a) 2Q3) Find the output of the given C program.
#include<stdio.h>
int main()
{
int num = 10;
num /= num /= 2;
printf("%d",num);
return 0;
}
a) 2.5
b) 2
c) 1
d) 0
View Answer
Answer:- c) 1num/=num/=2; num=10; Or, num/=num=num/2; num=10; Or, num/=5; num=5; Or, num=num/5; num=5; Or, num=5/5=1. Finally num=1.
Q4) Find the output of the given C program.
#include<stdio.h>
int main()
{
int a;
a=20;
a*=30+5;
printf("%d",a);
return 0;
}
a) 600
b) 605
c) 700
d) 20
View Answer
Answer:- c) 700a*=30+5; it can be written as a*=35; Or, a=a*35=20*35=700. Finally a=700.
Q5) Find the output of the given C program.
#include<stdio.h>
int main()
{
char x, y, z;
x = 'A';
y = 'B';
z = x + y;
printf("%d", z);
return 0;
}
a) Garbage Value
b) -125
c) 131
d) Compile-time error
View Answer
Answer:- b) -125Value of z = 65 (for A) + 66 (for B) = 131
The value 131 is in char. Char range is from -128 to 127. 131 is out of range. So, from circle representation of char value will be -125.
Q6) Find the output of the given C program.
#include<stdio.h>
int main()
{
int a=5;
a*=a;
printf("%d",a);
return 0;
}
a) 10
b) 25
c) 5
d) 0
View Answer
Answer:- b) 25a=a*a=5*5 so a=25
Q7) Find the output of the given C program.
#include<stdio.h>
int main()
{
printf("%d, %d, %d, %d",
20/3, -20/3, 20/-3, -20/-3);
return 0;
}
a) -6, 6, -6, 6
b) -6, -6, 6, -6
c) 6, -6, -6, 6
d) 6, 6, 6, -6
View Answer
Answer:- c) 6, -6, -6, 6In the division operator, If exactly any one of the operand is negative then the result is negative. If both operators are positive/negative than the result is positive.
Q8) Find the output of the given C program.
#include<stdio.h>
int main()
{
float a, c;
int b;
a = 5;
b = 2;
c = a % b;
printf("%f", c);
return 0;
}
a) Error
b) 2.500000
c) 2
d) 2.000000
View Answer
Answer:- a) ErrorModulus operator (%) does not operate on floating point.
Q9) Find the output of the given C program.
#include<stdio.h>
int main()
{
int a=5;
a += a+a;
printf("%d",a);
return 0;
}
a) 5
b) 15
c) 25
d) 10
View Answer
Answer:- b) 15a += a+a; it can be written as a += 10; Or, a = a+10 = 5+10 = 15. Finally a=15.
Q10) Find the output of the given C program.
#include<stdio.h>
int main()
{
int x, y, z;
z = x+y;
printf("%d", z);
return 0;
}
a) 32765
b) 0
c) Garbage Value
d) 1
View Answer
Answer:- b) 0Local variables (with the automatic storage duration) are not initialized implicitly if they do not have the static storage duration. The actual output will be 0. See more:-
Q11) Find the output of the given C program.
#include<stdio.h>
int main()
{
int a=2;
a+=3;
printf("%d",a);
return 0;
}
a) 2
b) 0
c) 5
d) 3
View Answer
Answer:- c) 5a+=3 is a=a+3 which gives 2+3=5.
Q12) Find the output of the given C program.
#include<stdio.h>
int main()
{
printf("%d, %d, %d, %d",
20%3, -20%3, 20%-3, -20%-3);
return 0;
}
a) 2, 2, -2, -2
b) 2, 2, 2, -2
c) 2, -2, 2, -2
d) 2, -2, 2, 2
View Answer
Answer:- c) 2, -2, 2, -2For % operator, the sign of the result is always the same as the sign of the numerator.
Q13) Find the output of the given C program.
#include<stdio.h>
int main()
{
float a, b, c;
a = 5;
b = 2;
c = a/b;
printf("%f",c);
return 0;
}
a) Garbage Value
b) 1.500000
c) 2.500000
d) 2.000000
View Answer
Answer:- c) 2.500000Q14) Find the output of the given C program.
#include<stdio.h>
int main()
{
int a, b;
float c;
a = 5;
b = 2;
c = a/b;
printf("%f",c);
return 0;
}
a) 2.500000
b) Garbage Value
c) 1.500000
d) 2.000000
View Answer
Answer:- d) 2.000000Q15) Find the output of the given C program.
#include<stdio.h>
int main()
{
int a;
printf("%d",a=9);
return 0;
}
a) Compile-time error
b) 1
c) 0
d) 9
View Answer
Answer:- d) 9Q16) Find the output of the given C program.
#include<stdio.h>
int main ()
{
int x = 9;
printf("%d",- -x);
return 0;
}
a) None of these
b) Compile-time error
c) -9
d) 9
View Answer
Answer:- d) 9Q17) Find the output of the given C program.
#include<stdio.h>
int main()
{
printf("%f", 5.0 % 2.0);
return 0;
}
a) 2.500000
b) 2
c) Error
d) 2.000000
View Answer
Answer:- c) ErrorModulus operator (%) does not operate on floating point.
If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or do you find anything incorrect? Let us know in the comments. Thank you!