Showing posts with label print. Show all posts
Showing posts with label print. Show all posts
Saturday, February 14, 2015
C program to print following trianlge using character
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr(); //to clear the screen
int i,j,k,n;
cout<<"How many lines?";
cin>>n;
for(i=0;i<n;++i)
{
cout<<"
";
for(j=0;j<i;++j)
cout<<" ";
for(k=n;k>i;--k)
cout<<"*";
}
getch(); //to stop the screen
}
Friday, February 13, 2015
C program to print the following design
#include<conio.h>
void main()
{
clrscr(); //to clear the screen
int i,j,k,n;
cout<<"How many lines?";
cin>>n;
n*=2;
for(i=0;i<n;i+=2)
{
for(j=n-2;j>i;j-=2)
cout<<" ";
for(k=0;k<=i;++k)
cout<<"*";
cout<<"
";
}
for(i=0;i<n;i+=2)
{
for(j=0;j<i;j+=2)
cout<<" ";
for(k=n-1;k>i;--k)
cout<<"*";
cout<<"
";
}
getch(); //to stop the screen
}
Subscribe to:
Posts (Atom)