Showing posts with label following. Show all posts
Showing posts with label following. Show all posts

Tuesday, February 17, 2015

C program to print the following design


C++ program to print the following design:

#include<iostream.h>
#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)
{
cout<<"
";

for(j=1;j<i;j+=2)
cout<<" ";
for(k=n-1;k>i;--k)
cout<<"*";
}
getch(); //to stop the screen
}
Read more »

C program to print following trianlge using character

C program to print following trianlge using character *

#include<stdio.h>
#include<conio.h>

void main()
{
int i,j,k,n;
clrscr(); //to clear the screen
printf("How many lines?");
scanf("%d",&n);

for(i=0;i<n;++i)
{
printf("
");

for(j=0;j<i;++j)
printf(" ");
for(k=n;k>i;--k)
printf("*");
}
getch(); //to stop the screen
}
Read more »

Sunday, February 15, 2015

C Program to print following triangle


 *
**
***
****
*****


code:
#include<iostream.h>
#include<conio.h>


void main()
{
clrscr();
int n,i,j;
cout<<"Ener size of Triangle(ex-4):";
cin>>n;
cout<<"
";



for(i=0;i<n;++i)
{
for(j=0;j<=i;++j)
cout<<"*";
cout<<"
";

}
getch();
}
Read more »