Close
Close

Do while looping

   @kshitij5664

C++ program to find sum of squares of numbers entered by the user till user enters a negative number. The program will not find sum of square of a number, if it is divisible by 3. (using do-while loop)


Answers

  •    wtxd1234

    #include <iostream>

    using namespace std;

    int main() {

    double a;

    do{

    cout<<"Number: ";

    cin>>a;

    if((int)a%3==0 || a<0){

    cout<<endl;

    }

    else{

    cout<<"sum of square of number: "<<a*a<<endl;

    }

    }while(a>=0);

    return 0;

    }



Ask Yours
Post Yours
Write your answer