Ceng198
Introduction to Computer Programming
Lab#3
Part I. Introduction to “while” Repetition Statement
Compile and run the following program. Analyze the output.
Part II. Nested Control Structures
Modify the code above so that
it only calculates the grades between 0 and 100.
If the user enters a grade below 0 (except “-1”), or above 100, the program should warn user with a message such as “Illegal grade entered!”.
The program should ask grades from user ‘till the user enters -1.
Part III. Do It Yourself
Write a program that
takes three grades (first midterm, second midterm, final) from user,
and then calculates the total grade of the student according to the following formulation:
Total Grade = First Midterm * 0.25 + Second Midterm * 0.25 + Final * 0.5
after calculating the total grade of the student, convert it to the letter form using following table,
print the letter equivalent of the students grade to the screen.
Use nested-if structure
Grade (0-100) |
Letter Equivalent |
90-100 |
AA |
85-89 |
BA |
75-84 |
BB |
70-74 |
CB |
60-69 |
CC |
55-59 |
DC |
45-54 |
DD |
25-44 |
FD |
0-24 |
FF |
Part IV. Do It Yourself
Modify the previous program as;
Numer of students is 10
Report as
Student 1 got 50 --> DD
.
.
.
Class average is .....
Part V. Do It Yourself
Write a complete C program to do following tasks:
Given that product=2
Find the number of repetitions when the test condition is product <=1000. (you will need to use a while loop control structure)