0% found this document useful (0 votes)
33 views4 pages

C++ Programs

The document contains code snippets for printing patterns like stars and squares, calculating powers, and generating multiplication tables. The code uses basic C++ constructs like loops, conditional statements, functions and input/output operations to implement these tasks.

Uploaded by

Talha Umar Sial
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)
33 views4 pages

C++ Programs

The document contains code snippets for printing patterns like stars and squares, calculating powers, and generating multiplication tables. The code uses basic C++ constructs like loops, conditional statements, functions and input/output operations to implement these tasks.

Uploaded by

Talha Umar Sial
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/ 4

Page 1 of 4

#include<iostream>
using namespace std;
int main()
{
for(int a=0;a<1;a++)
{cout<<" *";}
cout<<endl;
for(int i=2;i<=3;i++)
{cout<<" ";
for(int j=i;j<3;j++)
{cout<<" ";}
for(int k=0;k<=i-1;k++)
{cout<<"* ";}
if(i==3)
{cout<<"* ";}
cout<<" ";
cout<<endl;
}
for(int i=2;i>=1;i--)
{ cout<<" ";
for(int j=3;j>i;j--)
{cout<<" ";}
for(int k=i;k>=1;k--)
{cout<<" *";}
cout<<endl;
}
system("pause")
}

OUTPUT
Page 2 of 4

#include<iostream>
using namespace std;
int main()
{
int num;
cout << "Enter any Number :";
cin >> num;

for (int i = 1; i <=num ; i++)


{

for (int j = 1; j <=i; j++)


{

cout <<" "<< "*";

}
cout << endl;

}
for (int i = num; i >= 0; i--)
{

for (int j = i; j >=0; j--)


{

cout << " " << "*";

}
cout << endl;

}
system("pause");
return 0;
}
OUTPUT
Page 3 of 4

Square

#include <iostream>
using namespace std;
void main()
{
int a,b,x;
cout<<"enter the first and second number";
cin>>a>>b;
x=pow(a,b);
cout<<x;

system("pause");
}
Page 4 of 4

TABLE OF ANY NUMBER

#include<iostream>
using namespace std;
void main()
{
int number,x;
cout<<"enter the number"<<endl;
cin>>number;
for(x=1;x<=10;x++)
{
cout<<number<<"*"<<x<<"="<<number*x<<endl;

system ("pause");

OUTPUT

You might also like