1) Choose a correct statement.
int a = 12 + 3 * 5 / 4 - 10

A) 12, 3, 5, 4 and 10 are Operators.
+, -, * and / are Operands.
= is an increment operator.

B) 12, 3, 5, 4 and 10 are Operands.
+, -, * and / are Operators.
= is decrement operator.

C) 12, 3, 5, 4 and 10 are Operands.
+, -, * and / are Operators.
= is an assignment operator.

D) 12, 3, 5, 4 and 10 are Operands.
+, -, * and / are Logical Operators.
= is an assignment operator.

2) Choose a right statement.
float a = 5/2;
float b = 5/2.0;
float c = 5.0/2;
float d = 5.0/2.0;

A) a=2.5, b=2.5, c=2.5, d=2.5

B) a=2, b=2.5, c=2.5, d=2.5

C) a=2.0, b=2.5, c=2.5, d=2.5

D) a=2.0, b=2.0, c=2.0, d=2.0

Explanation:

In division, to get the actual real value, you should specify at least one real number.

Variable a holds only 2. But variables b,c and d contain real numbers as either numerator or denominator is a real number.

3) If both numerator and denominator of a division operation in C language are integers, then we get.?

A) Expected algebraic real value

B) Unexpected integer value

Explanation:

int a = 5/2 stores only 2.

4) Choose a right statement.
int var = 3.5;

A) a = 3.5

Explanation:

a stores only integer value. So, 3.5 is truncated to 3.

5) Choose a right statement.
int main()
{
int var = 3.5;;
printf("%f", var);
return 0;
}

A) 3.500000

Explanation:

As the variable type is an integer, you have to use %d as a format specifier. If you specify wrong format specifier, you will not get expected output.

6) What is the output of the program.?
int main()
{
int a = 25%10;
printf("%d", a);
return 0;
}

A) 2.5

Explanation:

Modulo division operator returns the reminder of division of 25 by 10. 10x2 + **5** = 25. So reminder is 5.

7) Can you use C Modulo Division operator % with float and int?

A) Only int variables = Okay

B) Only float variables = Okay

C) int or float combination = Okay

D) Numerator int variable, Denominator any variable = Okay

Explanation:

Modulo Division operator % in C language can be used only with integer variables or constants.

8) What is the output of the C program with Modulo Division operator with - or Negative numbers.?
int main()
{
int a = -25%-10;
int b = -25%10;
int c = 25%-10;
printf("%d %d %d", a, b, c);
return 0;
}

A) 5 -5 -5

Explanation:

Sign of a modulo division operation is same as the sign of Numerator. So sign of 25 is taken always.

9) What is the output of the program.?
int main()
{
float a = 45;
printf("%f", a);
return 0;
}

A) 45

Explanation:

Integer value 45 is promoted to float i.e 45.0 and printed with all 6 decimal numbers.

10) What is the priority of operators *, / and % in C language.?

A) * > / > %

C) Both % = / , * are same

D) All three operators *, / and % are same.

Explanation:

Operators Multiplication *, Division / and Modulo Division % are all having the same Priority.

11) In C language, which Operator group has more priority between (*, / and %) and (+, -) groups.?

A) Both groups share equal priority.

Explanation:

+ and - has same priority. *, / and % has equal priority. But (+, -) has less priority than (*, / and %).

12) Operator % in C Language is called.?

A) Percentage Operator

Explanation:

Operator % is called Modulus or Modular or Modulo Division operator in C. It gives the reminder of the division.

int a = 11%4;

Now a holds only 3 which is the reminder.

13) Associativity of C Operators *, /, %, +, - and = is.?

A) Operators *, / and % have Left to Right Associativity. Operators + and - have Left to Right Associativity. Operator = has Right to Left Associativitiy.

B) Operators *, / and % have Right to Left Associativity. Operators + and - have Left to Right Associativity. Operator = has Right to Left Associativitiy.

C) Operators *, / and % have Right to Left Associativity. Operators + and - have Right to Left Associativity. Operator = has Right to Left Associativitiy.

D) Operators *, / and % have Right to Left Associativity. Operators + and - have Right to Left Associativity. Operator = has Left to Right Associativitiy.

Explanation:

Operators *, / and % have Left to Right Associativity. Operators + and - have Left to Right Associativity. Operator = has Right to Left Associativitiy.

14) Output of an arithmetic expression with integers and real numbers is ___ by default.?

A) Integer

C) Depends on the numbers used in the expression.

Explanation:

Any arithmetic operation with both integers and real numbers yield output as Real number only.

5 + 10.56 = 15.560000 which is a real number.

5 + 10.0 = 15.000000 is also a real number.

15) Choose a right statement.
int a = 10 + 4.867;

A) a = 10

Explanation:

a is an int variable. So 10+4.867 = 14.867 is truncated to 14 and assigned to a.

16) Choose a right statement.
int a = 3.5 + 4.5;

A) a = 0

Explanation:

3.5 + 4.5 = 8.0 is a real number. So it is converted to downgraded to int value. So a = 8.

17) Choose a right statement.
float var = 3.5 + 4.5;

A) var = 8.0

Explanation:

A float variable can hold a real number.

18) Choose right statement.
int main()
{
float c = 3.5 + 4.5;
printf("%f", c);
return 0;
}

A) 8.0

Explanation:

Float can print precision up to 6 digits. So 6 zeros will be shown if there are no digits after decimal point.

19) Choose a right statement.
int main()
{
float c = 3.5 + 4.5;
printf("%d", (int)c);
return 0;
}

A) 8.0

Explanation:

You are printing a float variable by type casting to int. So integer is printed.

int c = 3.5 + 4.5 also holds and prints 8.

20) Choose a right statement.
int a = 5/2;
int b = 5.0/2;
int c = 5 / 2.0;
int d = 5.0/2.0;

A) a = 2, b = 2, c = 2, d= 2

B) a = 2, b = 2.0, c = 2, d= 2.0

C) a = 2, b = 2.5, c = 2.5, d= 2.5

D) a = 2.5, b = 2.5, c = 2.5, d= 2.5

Explanation:

Irrespective of numbers after decimal point, an int variable holds only integer value i.e 2.