• + 8 comments

    We can use getchar() as well in place of cin.ignore(). Here is my code :

    int i1;
    double d1;
    string s1;
    
    cin >> i1;
    cin >> d1;
    getchar();//cin.ignore();
    getline(cin,s1);
    
    s.append(s1);
    cout << i+i1 <<endl<<fixed<<setprecision(1)<<d+d1 <<endl <<s;