• Embed Doc
  • Readcast
  • Collections
  • CommentGo Back
Download
 
Problem: Shapes of Diamond and Box.
//Including Libraries#include <conio.h>#include <stdlib.h>#include <iostream.h>// Begining of Programvoid main(){clrscr();// Declaration of Variablesint choice,length;cout<<"\n\n1-BOX\n\n2-DIAMOND\n\n3-EXIT";cout<<"\n\nEnter Choice Number: ";cin>>choice;if (choice==1){cout<<"\n\nEnter The Length of The Box: ";cin>>length;cout<<"\n\n";for (int i=1;i<=length;i++){cout<<"*";}cout<<"\n";for (int j=1;j<=length-2;j++){cout<<"*";for (int k=1;k<=length-2;k++){cout<<" ";}cout<<"*\n";}for (int l=1;l<=length;l++){cout<<"*";}
 
}else if (choice==2){int a,b,c=1;cout<<"\nEnter The length of Diamond: ";cin>>a;b=a-1;clrscr();for (int i=1;i<=b;i++){cout<<" ";}cout<<"*\n";for(int j=1;j<=a-1;j++){for(i=1;i<=b-1;i++){cout<<" ";}b--;cout<<"*";for(int k=1;k<=c;k++){cout<<" ";}c=c+2;cout<<"*\n";} // Lower Side of Diamondb=a-1;if (a==4){c=a-1;}elsec=a+(a-5);
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
You must be to leave a comment.
Submit
Characters: ...