Shapes - Diamond And Box

  • Uploaded by: Muhammad Rana Farhan
  • 0
  • 0
  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Shapes - Diamond And Box as PDF for free.

More details

  • Words: 190
  • Pages: 3
Problem: Shapes of Diamond and Box. //Including Libraries #include #include <stdlib.h> #include // Begining of Program void main() { clrscr(); // Declaration of Variables int 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 Diamond b=a-1; if (a==4) { c=a-1; } else c=a+(a-5);

int r=1; for (j=1;j<=a-2;j++) { for (i=1;i<=r;i++) { cout<<" "; } cout<<"*"; r++; for (int t=1;t<=c;t++) { cout<<" "; } cout<<"*\n"; c=c-2; }

for ( i=1;i<=a-1;i++) { cout<<" "; } cout<<"*\n";

} else if (choice==3) exit(0); else cout<<"Wrong Entry...Press any key to Terminate the Program..."; getch(); }

Click the link below to see more examples URL: http://ravianeducation.blogspot.com E-Mail: [email protected] Farhan: 03008855006

Related Documents

Shapes
October 2019 38
Shapes
November 2019 43
Shapes
June 2020 24
Shapes
June 2020 10
Diamond
June 2020 15

More Documents from "Muhammad Rana Farhan"

Factorial
June 2020 13
Lecture 10
June 2020 19
Scientific Calculator
June 2020 8
Intermediate Part Ii
June 2020 9
Intermediate Part Ii
June 2020 6