lab5 - CP202 Lab5 In-Class work: 14 DQaddah 1428 18 DQaddah...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
14 D’Qaddah 1428 – 18 D’Qaddah 1428 1/2 In-Class work: 1. Type the following program carefully. Compile and run. (1 point) Lab5-sum.c 1 2 3 4 5 6 7 8 9 10 11 12 13 #include <stdio.h> int main(void) { int x, sum=0, i=0; while (i<5) { scanf(“%d”, &x); sum = sum + x; i = i + 1; } printf(“%d\n”, sum); } 2. Change Lab5-sum.c as follows. Compile and run. (1 point) 6 while (i<5) Write the error message? What does it mean (in Arabic)? Error message: _____________________________________________________________ Meaning: __________________________________________________________________ 3. Change Lab5-sum.c to calculate the sum and average. Compile and run. (1 point) Lab5-sum.c 1 2 3 4 5 6 7 8 9 10 11 12 13 #include <stdio.h> int main(void) { int x, sum=0, i=0; while (i<5) { scanf(“%d”, &x); sum = sum + x; i = i + 1; } printf(“sum=%d\navegrage=%f\n”, sum, sum/5); } Check the output. What is wrong? (Hint: the literal constant 5 in line 11 is int ). __________________________________________________________________________ CP202 – Lab5
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/15/2011 for the course FCIT 202 taught by Professor Danial during the Spring '07 term at King Abdulaziz University.

Page1 / 2

lab5 - CP202 Lab5 In-Class work: 14 DQaddah 1428 18 DQaddah...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online