Print Figures

C program to produce the folowing design using *'s

#include<stdio.h> #include<conio.h> void main() { int i,j,n; char ch=’A’; clrscr(); //to clear the screen printf(“How many lines?”); scanf(“%d”,&n); for(i=0;i<n;++i) { for(j=0;j<=i;++j) printf(“%c”,ch+j); printf(“n”); } getch();     //to stop the screen }

C++ program to print the following design

AABABCABCDABCDE Code:#include<iostream.h>#include<conio.h> void main(){ int i,j,n; char ch; cout<<“How many lines(ex 5):”; cin>>n; for(i=0;i<n;++i) { for(j=0;j<i;++j) { ch=65+j; cout<<ch; } cout<<“n”; } getch();}

C++ Program to print following triangle:

         *       *  *      *    *     ***** code: #include<iostream.h>#include<conio.h> void main(){ clrscr(); int i,k,j,n; cout<<“Enter size of triangle in odd number(min-5,ex-5,7,9):”; cin>>n; cout<<“nt”; for(i=1;i<=n;i+=2) { for(j=n;j>i;j-=2) cout<<” “; for(k=1;k<=i;++k) { if(i==n) cout<<“*”; else if(k==1||k==i) cout<<“*”; else cout<<” “; } cout<<“nt”; } getch();}

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<<“nt”; for(i=0;i<n;++i) { for(j=0;j<=i;++j) cout<<“*”; cout<<“nt”; } getch();}

C++ Program to print following triangle:

      *     **   *** ****code: #include<iostream.h>#include<conio.h> void main(){ clrscr(); int i,n,j,k; cout<<“Enter size of triangle(ex-5):”; cin>>n; cout<<“nt”; for(i=0;i<n;++i) { for(j=n;j>i;–j) cout<<” “; for(k=0;k<+i;++k) cout<<“*”; cout<<“nt”; } getch();}