0% found this document useful (0 votes)
35 views

Assignment 2 - 008118708

The document contains source code for printing a pyramid pattern of stars. The code uses loops and conditional statements to print the correct number of spaces and stars for each row based on the row number, with the number of rows input by the user. The second source code improves on the first by adding logic to handle even and odd spaces differently for more accurate pyramid formatting.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Assignment 2 - 008118708

The document contains source code for printing a pyramid pattern of stars. The code uses loops and conditional statements to print the correct number of spaces and stars for each row based on the row number, with the number of rows input by the user. The second source code improves on the first by adding logic to handle even and odd spaces differently for more accurate pyramid formatting.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 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