Write a program that iterates through the odd numbers less than 30, and outputs the square of each number.
#include <iostream>
#include<math.h>
using namespace std;
//The start point of the program
int main(){
cout<<"Odd number\tSquare\n";
for(int i=0;i<=30;i++){
if(i%2!=0){
cout<<i<<"\t\t"<<(i*i)<<"\n";
}
}
system("pause");
return 0;
}
Comments
Leave a comment