www.
openITis.
com | LINUX For YoU | AUgUsT 2008 83
S.
G.
GaneSh
The Joy of
Programming
1
.
Which operator in C can result in a ‘divide by
zero’ error other than the / (division) operator?
2.
The conditional operator (? :) is equivalent to...
More
www.
openITis.
com | LINUX For YoU | AUgUsT 2008 83
S.
G.
GaneSh
The Joy of
Programming
1
.
Which operator in C can result in a ‘divide by
zero’ error other than the / (division) operator?
2.
The conditional operator (? :) is equivalent to
if-then-else, which is a ternary operator.
Why is there no
if-then binary (?) operator?
3.
Your nephew has scored 453 out of 500 marks in the
SSLC exam, and you write a trivial program to check the
percentage—what does it print?
int main() {
int marks = 453, total = 500;
float percent = (marks/total)*100;
printf(“percentage is = %3.
2f!”, percent);
}
4.
You want a method that multiplies an integer by 9;
will the following work?
int mul_by_nine (int x) {
return (x << 3 + x);
}
5.
What is the output of the following program:
int main(){
printf(“%d \n”, 1 < 2 < 3);
printf(“%d \n”, 3 > 2 > 1);
}
6.
What is wrong with the following program?
#include <assert.
h>
int main(){
int i = 2;
i = -i;
assert (i == -2);
i = +i;
assert (i =
Less