create a calculator through c++ coding to calculate rectangle operations easily and great results in no time. no errors. easy to understand. less coding more fun. according to cbse syllabus.
Write a C++ Program to
calculate the rectangle operations
Rectangle Operations
Calculator in C++ Programming Language
(Area, Perimeter,
Length of Diagonals)
Code Sample 1 (for Dev C++ & CodeBlocks)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | #include<iostream> #include<math.h> #include<process.h> using namespace std; int main() { char response, choice; int l,b,a,p,d; Again: //go to statement cout<<"Enterr the rectangle function you want to work with:-"<<endl; cout<<"1. Area (Input 1)"<<endl; cout<<"2. Perimeter (Input 2)"<<endl; cout<<"3. Diagonals (Input 3)"<<endl; cout<<"4. Exit (Input 4)"<<endl; cin>>choice; if (choice=='1'||choice=='2'||choice=='3') { cout<<"Enter the length and the breadth respectively:-"<<endl; cout<<"(Put an enter between them)"<<endl; cin>>l>>b; } switch(choice) { case'1': a=l*b; cout<<"The area of the rectangle is:-"<<a<<"."; break; case'2': p=2*(l+b); cout<<"The perimeter of the rectangle is:-"<<p<<"."; break; case'3': d=sqrt(pow(l,2)+pow(b,2)); cout<<"The length of the diagonals is:-"<<d<<"."; break; case'4': cout<<"Exiting on your request..."; exit(0); default: cout<<"Wrong or Invalid choice."; cout<<"Try Again..."; cout<<"Exiting..."; exit(0); } cout<<endl<<"Want some more functions to work with."; cout<<endl<<"Enter your choice(Y/N):-\t"; cin>>response; if(response=='Y'||response=='y') goto Again; else { cout<<endl<<"Thank You"; exit(0); } return(0); } |
Code Sample 2 (for Turbo C++)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | #include<iostream> #include<math.h> #include<process.h> void main() { char response, choice; int l,b,a,p,d; Again: //go to statement cout<<"Enterr the rectangle function you want to work with:-"<<endl; cout<<"1. Area (Input 1)"<<endl; cout<<"2. Perimeter (Input 2)"<<endl; cout<<"3. Diagonals (Input 3)"<<endl; cout<<"4. Exit (Input 4)"<<endl; cin>>choice; if (choice=='1'||choice=='2'||choice=='3') { cout<<"Enter the length and the breadth respectively:-"<<endl; cout<<"(Put an enter between them)"<<endl; cin>>l>>b; } switch(choice) { case'1': a=l*b; cout<<"The area of the rectangle is:-"<<a<<"."; break; case'2': p=2*(l+b); cout<<"The perimeter of the rectangle is:-"<<p<<"."; break; case'3': d=sqrt(pow(l,2)+pow(b,2)); cout<<"The length of the diagonals is:-"<<d<<"."; break; case'4': cout<<"Exiting on your request..."; exit(0); default: cout<<"Wrong or Invalid choice."; cout<<"Try Again..."; cout<<"Exiting..."; exit(0); } cout<<endl<<"Want some more functions to work with."; cout<<endl<<"Enter your choice(Y/N):-\t"; cin>>response; if(response=='Y'||response=='y') goto Again; else { cout<<endl<<"Thank You"; exit(0); } getch(); } |
Sample Output:
Programs on conditional statements, loops, control structures and string
manipulations under C++ Programming language are covered here.
___________________________________________________________________
Know more about stuff
related to this practical experiment (Important for Boards):-
- Difference between Dev C++ and Turbo C++.
- C++ Program to find the Product of the Matrices | C++ Program | Class XI
- C++ Program to find the Sum of the Series, 1 – x/2! + x^2/3! – x^3/4! + x^4/5! .... | C++ Program | Class XI
- C++ Program to find sum of each row and each column of a Matrix | C++ Program | Class XI
- Qualitative analysis for the identification of the functional group in the organic sample Acetic Acid (Example 1)
- How to find out the mass of salt required to achieve the required concentration of a solution
- C++ Program to calculate the factorial of a given number | C++ Program | Class XI
- C++ Program to check whether a number is an Armstrong number or not | C++ Program | Class XI | CBSE
Reference:-
- Arora, Sumita. Computer Science with C++ for Class - 12
- Arora, Sumita. Computer Science with C++ for Class - 11
- C programming Interview questions and answers [http://www.cquestions.com/]
- The Crazy Programmer [https://www.thecrazyprogrammer.com/]
Comment down about what
you think went wrong with your code, is this correctly working for you? What
else do you need for your coding lust?
For latest syllabus, both
theory and practical papers for class XII, check out the CBSE’s official
site http://cbseacademic.in/ for more info.
For more awesome coding
and programs related to this language log onto http://www.thecrazyprogrammer.com or https://www.w3schools.in/.
___________________________________________________________________
Related Questions-
Loop Based program code
Loops for while
Array manipulations
Header files
Dev c++
Conditional statements
Turbo C++
CodeBlocks
CBSE class 12 computer
science practicals
CBSE class XII computer
science practicals
Benzoic Acid
___________________________________________________________________
- [message]
- ##check##NOTE:
- E&OE, means errors and omissions are expected and accepted, in other words, if there is any error in the following article, the same has to be corrected by the user or the beneficiary accordingly.This article contains works derived from other reputed works of huge publication houses and notes that were made by me in my school life.These articles are just to help people who need these articles desperately and urgently. Any queries, complaints, and corrections will be enthusiastically entertained.
COMMENTS