Vous êtes sur la page 1sur 3

JAYPEE UNIVERSITY OF ENGINEERING & TECHNOLOGY, GUNA

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

Tutorial Sheet: 5
Course: B.Tech Sem: I
Course Code & Name: 14B11CI111/ Introduction to Computer Programming
Student Name: BATCH: DATE:

1) Evaluate the following expressions

int i=8, j=5;

float x = 0.005, y = - 0.01;

char c = c, d = d;

(i) (3 * i 2 * j ) % ( 2 * d c)

(ii) 2*((i/5)+(4*(j3))%(i+j2))

(iii) (i3*j)%(c+2*d)/(xy)

2) Trace the following code fragment, showing the value of each variable each time it
changes

int x, y, z;

x = y = z = 6;

x *= y += z -= 4;

3) Write the output of the following code

a. #include<stdio.h.>

void main( )

{ int i=10, m=10 ;


printf ( %d , i > m ? i*i , 20 ) ; }

b. main()

{ float x = 123.456;

printf( %f %.3f %.1f \n \n , x, x, x);

printf( %e %.5e %.3e , x, x, x); }

4) Write the output of the code for the given conditions

float a, b, c = 2.5;

c += (a > 0 && a <= 10) ? ++a : a/b ;

printf ( %f , c );

i. a=5,b=2

ii. a = 10 , b = 5

iii. a = 50 , b = 10

5) What is the value of x after following statements are executed?

int m = 5, n = 5, x;

char p = p, q =q;

x = ! ( ( m >=n ) && ( p > q ) ) ;

(A)0 (B) 1 (C) 1 (D) Any non zero value

6) Construct a logical expression to represent each of the following conditions

a. score is greater than or equal to 80 but less than 90

b. answer is either N or n

c. n is even but not 8


d. ch is a capital letter

e. donation is in the range 1000-2000 or guest is 1

7) Which of the following conditions evaluates to true in the C programming language?

For int a = 5, b = -3, c = 0;

i. ( a < b ) || ( c < b )

ii. ( c < a ) && ( c < b )

iii. ( a > b ) && !c

iv. !( a + b > c )

8) Which of the following conditions is equivalent to the condition:

!(( x >= y ) && ( y >= z ))?

i. !( x >= z)

ii. x <= z

iii. ( x < y ) && ( y < z )

iv. ( x < y) || ( y < z )

9) Write a single C statement that

i. Subtracts the sum of x and y from z and then increments y.

ii. Decrements the variable n and then adds it to variable total.

Vous aimerez peut-être aussi