How to start from beginning of the program

前端 未结 6 1727
灰色年华
灰色年华 2021-01-17 02:00

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         


        
6条回答
  •  囚心锁ツ
    2021-01-17 02:20

    Here is how we do :

    #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<<"\nSecond number: ";
        cin>>num2;
    
        cout<< "your sum is: "<> ch;
        if (ch == 'Y' || ch == 'y')
            continue;
        else
            break;
    }
    
    return 0;
    }
    

提交回复
热议问题