1-Program to calculate the student assessment, where estimates are given as:
90 ≤ 'A' ≤ 100
80 ≤ 'B' < 90
70 ≤ 'C' < 80
60 ≤ 'D' < 70
'F' < 60
#include <iostream.h>
#include <conio.h>
void main ( )
{
float mark ;
char grade ;
L: cout << "Enter a mark : " ;
cin >> mark ;
if (mark > 100 || mark < 0)
cout << "rong mark .. try again " ;
else if (mark >= 90)
grade = 'A' ;
else if (mark >= 80)
grade = 'B' ;
else if (mark >= 70)
grade = 'C' ;
else if (mark >= 60)
grade = 'D' ;
else
grade = 'F' ;
cout << grade << endl ;
goto L;
getch ();
}
2-Program to print the sum of Forums numbers located between 1 and 100:
#include <iostream.h>
#include <conio.h>
void main ()
{
int i, sum = 0;
for (i = 100; i > 1; i=i-2)
sum += i;
cout << " SUM = " << sum << endl ;
getch ();
}
3-Program, will enter the numbers and print them as long as did not enter the number 0 :
#include <iostream.h>
#include <conio.h>
void main ()
{
int n;
while ( n != 0 )
{
cout << "Enter a number: ";
cin >> n;
cout << "n= " << n << endl ;
}
getch ();
}
0 comments:
Post a Comment