Practical No. 06: Title: Programs Using Loops and Switches
Practical No. 06: Title: Programs Using Loops and Switches
Practical No. 06: Title: Programs Using Loops and Switches
06
Title: Programs using loops and switches.
Write the program that input test scores of a student and display his grade.
#include <iostream>
int main()
int a;
cout<<"enter number:";
cin>> a;
if (a>=100){
else if (a>=90){
else if (a>=80){
else if (a>=70){
lse if (a>=60){
main()
char c;
cin>> c;
switch(c)
start
yes
Is c=a
vowel
yes
Is c=e
vowel
yes
Is c=i
vowel
yes
Is c=o vowel
yes
Is c=u vowel
no
consonent
End
Practical no. 07
Title: Write programs using different arithmetic operations and loops.
Write a program that inputs a number for the user and displays its table using for
loop.
#include <iostream>
main()
int len,tab,a;
cin>> tab;
cin>> len;
for (a=1;a<=10;a++)
cout<<tab<<"*"<<a<<"="<<tab*a<<endl; }
main()
int c,a;
for(c=1;c<=10;c=c+2){
cout<<c<<endl;
a*=c;}
Write a program that displays first five numbers and their squares using do while
loop.
#include <iostream>
int main()
{ int a;
int j=1;
int c;
do
{ c=j*j;
j++;
}while (j<=5);
return 0; }