II EC-8 (Lab III)
II EC-8 (Lab III)
Roll no : II EC-8
Experiment III
FOR REPETITION STATEMENTS
Page 1 of 7
1. Write a program for calculating the amount of money in the account at the end of each
year for 10 years.
Create a main file as follows:
#include <stdio.h>
#include <math.h>
year++ )
}
return 0;
PROCEDURE:
Page 2 of 7
Page 3 of 7
SWITCH MULTIPLE SELECTION STATEMENTS
Objectives: To learn switch statements
Required Equipment:
➢ Matlab software
PC
2. Write a program for counting the letter grades.
Create a main file as follows:
#include <stdio.h>
main( void )
aCount = 0;
int bCount = 0;
int cCount = 0;
int dCount = 0;
int fCount = 0;
printf( "Enter
the letter
grades.\n" );
printf( "Enter
the EOF
character to
end input.\n" );
while ( (grade
Page 4 of 7
= getchar() ) !=
EOF ) { switch
( grade )
{ case 'A':
case 'a':
++aCount;
break; case
'B': case
'b': +
+bCount;
break; case
'C': case
'c':
++cCount;
break; case
'D': case
'd':
++dCount;
break;
case 'F':
case 'f':
++fCount;
Page 5 of 7
case '\n':
case '\t':
break;
default:
PROCEDURE:
Page 6 of 7
Page 7 of 7