C Programming-Arithmetic Operators

C Programming-Arithmetic Operators

Question 1
What is the output of this C code?
#include 
int main()
{
int i = -3;
int k = i % 2;
printf("%d\n", k);
}
A
Compile time error
B
-1
C
1
D
Implementation defined
Question 2
What is the output of this C code?
#include 
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
Question 3
What is the output of this C code?
#include 
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
Question 4
What is the output of this C code?
 #include 
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
Question 5
What is the value of x in this C code?
#include 
void main()
{
int x = 5 * 9 / 3 + 9;
}
A
3.75
B
Depends on compiler
C
24
D
3
Question 6
What is the output of this C code?
#include 
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
Question 7
What is the output of this C code?
#include 
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
Question 8
What is the output of this C code?
#include 
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
Question 9
The precedence of arithmetic operators is (from highest to lowest)
A
%, *, /, +, -
B
%, +, /, *, -
C
+, -, %, *, /
D
%, +, -, *, /
Question 10
Which of the following is not an arithmetic operation?
A
a *= 10;
B
a /= 10;
C
a != 10;
D
a %= 10;
Question 11
Which of the following data type will throw an error on modulus operation(%)?
A
char
B
short
C
int
D
float
Question 12
Which among the following are the fundamental arithmetic operators, ie, performing the desired operation can be done using that operator only?
A
+, -
B
+, -, %
C
+, -, *, /
D
+, -, *, /, %
Question 13
What is the output of this C code?
#include 
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
Question 14
What is the output of this C code?
#include 
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




Check Your Answers:
 1.  B
 2.  B
 3.  B
 4.  B
 5.  C
 6.  D
 7.  A
 8.  D
 9.  A
10. C
11. D
12. A
13. A
14. B



SHARE

Unknown

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment