In: Electrical Engineering
makes it in c++
Kyal is in line at the DMV he has number 325, they are currently serving customer 320.
Use a switch statement
to determine which type of loop he needs to use to count to his
turn being called.
f = for loop w = while loop d = do-while loop
Output the appropriate loop type from the switch.
Then use any loop type to get from 320 to 325.
Select the appropriate loop type f= for, w =while, d= do-while [output of appropriate loop type] 320 321 322 323 324 325 It is your turn
the projram starts her..
#include <iostream>
using namespace std;
int main() {
// Declare appropriate variables
int number = 320;
//Output the prompt & recieve input
cout << "Select the apropriate loop type
f= for, w =while, d= do-while" << endl;
//Switch to determine & output the
appropriate loop type
//Loop that goes from 320 to 325 and outputs
each number then "It's your turn"
return 0;
}
#include <iostream>
using namespace std;
string name="its ur turn";
int num=320;
int main()
{
// Declare char variable for taking character and functions
fr(),whle(),dowhile() for display numbers from 320 to 325 using
while,for,do-while loops
char o;
void fr();
void whle();
void dowhile();
cout << "Select the appropriate loop type f=for,w=while,d=do-while"<<endl;
cin >> o;
switch (o)
{
case 'f':
fr();
break;
case 'w':
whle();
break;
case 'd':
dowhile();
break;
default:
cout << "Invalid Choice. Enter f or w or d";
break;
}
return 0;
}
void fr() // function for displaying numbers 320 to 325 using for loop
{
for(int num=320;num<=325;num++)
{
cout << num << endl;
}
cout << name << endl;
return ;
}
void whle() //function for displaying numbers 320 to 325 using while loop
{
while(num<=325)
{
cout << num << endl;
num++;
}
cout << name << "\n";
return;
}
void dowhile() //function for displaying numbers 320 to 325 using do-while loop
{
do{
cout << num << endl;
num++;
}while( num <= 325 );
cout << name << "\n";
}