0% found this document useful (0 votes)
34 views3 pages

7.1 #Include Using Namespace STD Int Main (

The document contains code to print a triangle pattern of numbers and asterisks. It uses nested while and if/else statements to iterate through values of x, y, z, and a to print the character "*" or the current value of y based on comparisons between y and a. It then decrements a, prints a new line, increments z, and resets y to 1 to print the next line.

Uploaded by

arfanaziz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views3 pages

7.1 #Include Using Namespace STD Int Main (

The document contains code to print a triangle pattern of numbers and asterisks. It uses nested while and if/else statements to iterate through values of x, y, z, and a to print the character "*" or the current value of y based on comparisons between y and a. It then decrements a, prints a new line, increments z, and resets y to 1 to print the next line.

Uploaded by

arfanaziz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

7.

#include <iostream>

using namespace std;

int main()

int x;

int y=1;

int z=1;

int a;

cout<<"Please enter a number: "<<endl;

cin>> x;

a=x;

while (z<=x)

while (y<=x)

if (y>=a)

cout<<"*";

++y;

else

cout<<"";

++y;

}
}

--a;

cout<<endl;

++z;

y=1;

return 0;

7.2

#include <iostream>

using namespace std;

int main()

{ int x,i,y,k;

x=7;

k=x;

for( i=1; i<=x; i++)

for(y=1;y<=x;y++)

if(y<=i)

cout<<y;

else

cout<<"*";

k--;
cout<<endl;

return 0;

You might also like