Write a complete C++ program using while loops that prints the squares of the in
ID: 3563979 • Letter: W
Question
Write a complete C++ program using while loops that prints the squares of the integers from the 1 to the number given by user to the console window, separated by spaces.
Outline:
a) Ask a user for a positive number greater than 1
b) If input is invalid - ask again until the user gives you valid input
c) After that program prints to the console the squares of the integers from 1 to the number given by the user (including)
Examples:
#1. Input positive integer greater than 1: 1
Try again: -
Explanation / Answer
your answer is here if you have any issue than plz mail me ask me i'll give you detail explanation thankyou plz rate broo
#include <iostream>
using namespace std;
int main()
{
int no;
cout<<"Enter the input greater than 1 : ";
cin>>no;
while(no<1)
{
cout<<"Enter the again input : ";
cin>>no;
}
for(int i=1;i<=no;i++)
{
cout<<i*i<<" ";
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.