Professional Documents
Culture Documents
E Balagurusamy CH 3 Solution
E Balagurusamy CH 3 Solution
Answer: False.
Answer: False.
Answer True.
Answer: False.
Answer: False.
Answer: False.
Answer: True.
Answer: True.
Answer: True.
Answer: False.
Answer : true.
d. 10 15 && (10<20) || 15>30
Answer: False.
Mohammad Abir Reza [CSE- 5TH BATCH]
Department of Computer Science & Engineering
Comilla IInivers
3.6 Which of the following arithmetic expressions are valid ? If
valid, give the value ofthe expression; otherwise give reason.
(a )25/3 %2
Answer: 0
(b) +9/4+5
Answer: 7
(c)7.5%3
Answer: Not valid.
Invalid operands to binary % (have "loat and 'int' type)
(d) 14%3+ 7%2
STEVE JOBS
Answer: 3 ESIGNER UF NEW WORLD
(e)-14%3
Answer: -2
(15.25+5.0
Answer 10.250000
g5/3) 3 +5%3
Answer 5
(h) 21%(int)4.5
Answer: 1
(a) ((x-(y/5)+z)%8)+25
(b) ((x*y)°p)+q
(c)(mn) +(xly)
(d) x/(3y)
3.9 Find errors,if any, in the following assignment statements
and rectify them.
a. x=y=z = 0.5,2.0,-5.75;
Answer: Error.
d. p =xly:
Answer Error.(no space between * and )
e. s=/5;
Answer: Error.(semicolon)
Mohammad Abir Reza [cSE- 5TH BATCH]
Department of Computer Science & Engineering
Comilla Uníversity
ANSI C REVIEW QUESTION SOLUTION
Answer: false.
b. acb && a>c
Answer: True.
C. a=c|| b>a
Answer: True.
Answer: True.
charX,
int y
x=100;
y=125;
printf("%cn".x);
printf("%cn".y):
printf("%din",x);
Output
d
intx =100;
printf("%d/n",10+ ++x}
Output: 110/n112/n
z=10:
int x=5, y=10,
x= y==z;
printf("%d"x):
Output:
program ?
the following
the output of
3.14 What is
STEVE JOBS
NEW IWORID
main() OESIGHER OF
tr5100.Y=200;
3.15 What is the output of the following program ?
main()
unsigned x=1;
signed y=-1;
if(x>y)
printf("x>y'):
else
printf('x=y");
Output: x<=y
Yes Iexpected this output. STEVE JOBS
In this program to evaluate if expression the signed char y=-1 is
converted to unsig ned int type. So the "if' condition becomes false
and 'else' part in executed. So the output is x<=y.
int x=10;
if(x=20)
printf("true");
Mohammad Abir Reza [cSE-5H BATCH]
Department of Computer Science & Engineering
Comilla University
***
ANSI C
REVIEw QUESTION SOLUT
else
printf("fulse");
Output: true
Computer evaluates the expression first and then
whether the value of the depending on
non zero) or
expression (relation or condition) is 'true' (or
false'(zero), it transfers the control to a particular
statement. In this case the
expression x=20 evaluates to 20(non
zero).So the expression is true and the statement after it is
So the is TRUE
executed.
output
printf("'ok")
(b) if(x=<5)
printf(jump"):
Answer: Error
CA: if(x<=5)
printf(jump"):
float y=4.25;
X= y% X;
Answer:There is an error in the segment. The modulo division operator
% cannot be used on floating point data. Because real operator can't use
%
for(m=0;m<3;++m)
printf("%din".(m%2) ? m:.m+2);
Output: 2
Output:40
40