Write a program in C++ to perform following pattern:
1
3 5
7 9 11
13 15 17 19
Program:-
#include<iostream>
using namespace std;
int main()
{
int i,j,num=-1;
for(i=1;i<=4;i++)
{
for(j=1;j<=i;j++)
{
num=num+2;
cout<<num;
cout<<" ";
}
cout<<endl;
}
}
Output:-
No comments:
Post a Comment