I am a very beginner in c++. i am just learning abc of this language.. i created this small program that would add:
#include
using namesp
The following code will do that:
#include
using namespace std;
float add(float a, float b){
return a+b;
}
int main(){
float num1;
float num2;
while( true ){
cout<<"add...enter digits \n";
cout<<"first digit: ";
cin>>num1;
cout<<"\n Second number: ";
cin>>num2;
cout<< "your sum is: "<
above code will run forever. If you want to give user a choice, then apply a loop break condition.
char repeat = 'y';
while( repeat == 'y'){
// do as previous
//.....
//finally give user a choice
cout<< "Do you want to repeat?(y/n):";
cin>> repeat;
}
system("pause");
}