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

Assignment 1 Programming

Uploaded by

kiokocurtis
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Assignment 1 Programming

Uploaded by

kiokocurtis
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Assignment 1

To be collected by class rep on Wed 17th July 2024 and submitted before 11am together with signed class list
of those who will have submitted.

BACHELOR OF SCIENCE IN MECHANICAL ENGINEERING, BED MECHANICAL ENGINEERING


CCS 2103 COMPUTER PROGRAMMING

1. Identify the output of the following C program:


# include <stdio.h>
void main ( )
{
int x, y, z, i =0;
x =1;
y = 10;
while (i < 3)
{
x +=1;
y - =2;
z + =x +y;
i + +;
printf (“\nX=%5d, Y=%5d”, x, y);
}
print f (“\nZ =%d”,z);
} [5 Marks]

2 Write an algorithm and draw a flowchart generate the value of x1 and x2 in the formulae below when
the value of a,b and c are provided [10 marks]

3. Compute the values of the following C expressions assuming that b, s, e, m and k are integer variables,
z and t are float variable as declared below.

int b = 1, s = 3, e = 5, m = 4, k = 10; float z = 2.0, t = 5.5; [5 marks]

i. z=b+k*z/m%e-1
ii. e % s * m > z || k % s * b < t
iii. (b < s) % s+1
iv. ++b && s--
v. m = --b? –e : ++e

You might also like