assignment q1
Sat Nov 11 2023 11:37:52 GMT+0000 (Coordinated Universal Time)
Saved by
@yolobotoffender
/* // display menu
DisplayMenu();
//select your choice
int choice;
Select( choice); //
test your choice
switch( choice )
{ case 1: PracticeAdd(); break; case
2:
PracticeSub(); break;
}
//terminate program
system(“pause”); return 0
} */
#include <iostream>
using namespace std;
void sum(float x,float y);
void menu(int choice);
int main(){
int choice;
menu(choice);
return 0;
}
void sum(float x,float y){
float result;
char opt = y,n;
do{
cout<<"enter two numbers to be added: "<<endl;
cin>>x>>y;
cout<<x<<" + "<<y<<" = ";
cin>>result;
if(result == x+y){
cout<<"correct"<<endl;}
else cout<<"wrong"<<endl;
cout<<"do you want to perform test again:\npress 'y' for yes or 'n' for no "<<endl;
cin>>opt; }
while(opt==y);
}
void menu(int choice){
float x,y;
cout<<"press 1 for addition:\npress 2 for subtraction: "<<endl;
cin>>choice;
if(choice==1){
cout<<sum(x,y)<<endl; }
}
content_copyCOPY
Comments