You are on page 1of 4

1///daimond//

#include<iostream>
using namespace std;
int main()
{
cout<<"name"<<" "<<"id "<<endl;
cout<<"firdiwek sisay"<<" 1510"<<endl;
cout<<"display a pattern like a daimond"<<endl;
cout<<".............................."<<endl;

int i, j, rowNum, space;


cout<<"input Number of Rows(half of the daimond): ";
cin>>rowNum;
space = rowNum-1;
for(i=1; i<=rowNum; i++)
{
for(j=1; j<=space; j++)
cout<<" ";
space--;
for(j=1; j<=(2*i-1); j++)
cout<<"*";
cout<<endl;
}
space = 1;
for(i=1; i<=(rowNum-1); i++)
{
for(j=1; j<=space; j++)
cout<<" ";
space++;
for(j=1; j<=(2*(rowNum-i)-1); j++)
cout<<"*";
cout<<endl;
}
cout<<endl;
return 0;
}
//cheak this one as alternative answer;;
#include<iostream>
using namespace std;
int main()
{
int row,i,j,k;
cout<<"Enter the number: ";
cin>>row;

cout<<endl;
//upper part
for(i=1;i<=row;i++)
{
for(j=1;j<=row-i;j++)
cout<<" ";

for(k=1; k<=i*2-1; k++)


cout<<"*";

cout<<endl;
}

//lower part
for(i=1;i<=row;i++)
{
for(j=1;j<=i;j++)
cout<<" ";

for(k=1; k<=(row-i)*2-1; k++)


cout<<"*";

cout<<endl;
}

return 0;
}
2////multiplication table
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
cout<<setw(34)<<"multiplication table";
cout<<"\n";
for(int x=1;x<=12;x++){
cout<<"\n";
for(int y=1;y<=12;y++){
cout<<setw (4)<<x*y;
}

}
return 0;
}

3//////factor
#include<iostream>
using namespace std;
int main()
{
int num, i=1;
cout<<"Enter a Number: ";
cin>>num;
cout<<"\nFactors of "<<num<<" are:\n";
while(i<=num)
{
if(num%i==0)
cout<<i<<" ";
i++;
}

cout<<"\n";
cout<<"end of the program";
return 0;

//4//factorial with appropriate display;;;;

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{int x=1,y;

cout<<"enter the value of y :";


cin>>y;
cout<<endl;
cout<<setw(1)<<"integers"<<"\t"<<"factorials"<<"\n";
for(int n=1;n<=y;n++){
x *=n;
cout<<n<<"\t";
cout<<setw(10)<<x<<"\n";
}
return 0;
}

A signed integer is a 32-bit datum that encodes an


integer in the range [-2147483648 to 2147483647]. An
unsigned integer is a 32-bit datum that encodes a
nonnegative integer in the range [0 to 4294967295].
so, in his case the maximum value of factorial that we
can calculate is 2147483647 for int data type.

Thanks //

You might also like