Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
94 views

C Programming Tutorial 4 - Question

This document provides examples of arithmetic operations and random number generation in C programming. It contains questions about evaluating logical expressions and printing random integers within given ranges. It also asks whether the output of a code snippet printing a variable before and after incrementing can be determined.

Uploaded by

Nurfauza Jali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
94 views

C Programming Tutorial 4 - Question

This document provides examples of arithmetic operations and random number generation in C programming. It contains questions about evaluating logical expressions and printing random integers within given ranges. It also asks whether the output of a code snippet printing a variable before and after incrementing can be determined.

Uploaded by

Nurfauza Jali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

TMF 1414 INTRODUCTION TO PROGRAMMING

Tutorial 4 Arithmetic Operation

1. Assume i = 1, j = 2, k = 3 and m = 2. What does each of the following statements print?

a) printf( "%d", i == 1 );
b) printf( "%d", j == 3 );
c) printf( "%d", i >= 1 && j < 4 );
d) printf( "%d", m < = 99 && k < m );
e) printf( "%d", j >= i || k == m );
f) printf( "%d", k + m < j || 3 - j >= k );
g) printf( "%d", !m );
h) printf( "%d", !( j - m ) );
i) printf( "%d", !( k > m ) );

2. Write statements that assign random integers to the variable n in the following ranges:

a) 1n2
b) 1 n 100
c) 0n9
d) 1000 n 1112

3. For each of the following sets of integers, write a single statement that will print a number at
random from the set.

a) 2, 4, 6, 8, 10.
b) 3, 5, 7, 9, 11.

4. Can the output of the following code be determined?

age = 20;
printf (You are now %d, and will be %d in one year,
age, age++);

5. What is the output for this program?

You might also like