#include<iostream>
using namespace std;
int main()
{
int i,y;
int firstNum,secondNum;
int sum=0,total=0,add=0;
cout<<"Enter the first Number: ";
cin>>firstNum;
cout<<"Enter the second Number which should be greater than the first number: ";
cin>>secondNum;
for(i = firstNum; i <= secondNum; i++){
cout<<i << " squared is "<< (i*i)<< "\n";
int m=i*i;
add+=m;}
while(firstNum<=secondNum){
if(firstNum%2==0){
firstNum=firstNum+1;
cout<<firstNum<<" ";
firstNum=firstNum+2;
}
else{
cout<<firstNum;
firstNum=firstNum+2;
}
sum=firstNum+(firstNum+2);
if(firstNum%2!=0){
cout<<firstNum;
firstNum=firstNum+2;}
else{
firstNum=firstNum+1;
firstNum=firstNum+2;
}
total=firstNum+(firstNum+2);
}
cout<<"\nSum of even: "<<sum;
cout<<"\nSum of odd numbers: "<<total;
cout<<"\nSum of squares of all numbers: "<<add;
}
Comments
Leave a comment