Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 6

Assignment 2: Source Code:

#include<iostream> #include<conio.h> #include<iomanip> using namespace std; int main() { int iRo !iCurrentRo "#; cout<<$%nter num&er o' ro s:$; cin>>iRo ; 'or(int i"#;i<"iRo ;i(() { int )"iCurrentRo ; **'or getting hite spaces 'or();)<"iRo ;)(() cout<<$ $; **'or getting the re+uired 'ormat o' stars int iStarCount"(2,i)-#; 'or(int ."/;.<iStarCount;.(() cout<<$,$; cout<<endl; **incrementing the ro iCurrentRo ((; 0 getch(); return /;

1utput:

2or gi3ing large ro

count! the output

ill not seem li.e a p4ramid

54 code

or.s 'or ro

count / 6 #

Source Code 2:
#include<iostream> #include<conio.h> #include<iomanip> using namespace std; int main() { int iRo !iCurrentRo "#; cout<<$%nter num&er o' ro s:$; cin>>iRo ; 'or(int i"#;i<"iRo ;i(() { int )"iCurrentRo ; **'or getting hite spaces 'or();)<"iRo ;)(() cout<<$ $; **'or getting the re+uired 'ormat o' stars int iStarCount"(2,i)-#; 'or(int ."/;.<iStarCount;.(() { **printing , 'or odd spaces i'(.72 > /) cout<<$,$; **printing hite spaces 'or e3en places else cout<<$ $; 0 cout<<endl; **incrementing the ro iCurrentRo ((;

0 getch(); return /; 0

1utput:

You might also like