Write a program to find the number and sum of all integers between 100 and 200 which are divisible by 9. Only a single for loop is required for this exercise.
using namespace std;
// Write a program to find the number and sum of all integers between 100 and 200 which are divisible by 9.
// Only a single for loop is required for this exercise.
int main()
{
int n,Sum=0;
cout<<"\n\tNumbers are : ";
for(n=100;n<=200;n++)
{
if(n%9==0)
{
cout<<n<<", ";
Sum = Sum + n;
}
}
cout<<"\n\tAnd the Sum = "<<Sum;
return(0);
}
Comments
Leave a comment