0% found this document useful (0 votes)
5 views5 pages

Task 01

The document contains 8 code snippets that demonstrate basic C++ programs for calculating areas, volumes, conversions between units, triangle properties, loan calculations, shape properties, exponents, and a basic calculator. Each code snippet includes input from the user, calculations, and output of the results.

Uploaded by

fadymamdouh2515
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

Task 01

The document contains 8 code snippets that demonstrate basic C++ programs for calculating areas, volumes, conversions between units, triangle properties, loan calculations, shape properties, exponents, and a basic calculator. Each code snippet includes input from the user, calculations, and output of the results.

Uploaded by

fadymamdouh2515
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Q1

#include <iostream>

using namespace std;

int main()

//01 retangle area

cout << "the retangle area\n";

cout << "------------------------------------\n";

int Width, Length;

cout << "please enter the width of the retangel=";

cin >> Width;

cout << "please enter the length of the retangel=";

cin >> Length;

cout << "the retangel area =" << Width * Length<<"\n";

cout << "------------------------------------\n";

//02 volume of cube

cout << "the volume of the cube\n";

cout << "------------------------------------\n";

int length;

cout << "please enter the length of the cube=";

cin >> length;

cout << "the cube volume =" << length * length* length<<"\n";

cout << "------------------------------------\n";

//03 convert kg to meter to cm


cout << "convert form kilometaer to meter to cm\n";

cout << "------------------------------------\n";

int Kg, meter;

cout << "please enter your kilometer=";

cin >> Kg;

meter = Kg * 1000;

cout << "meter=" << meter<<"\n";

cout << "cm=" << meter * 100 << "\n";

cout << "------------------------------------\n";

//04 third triangle

cout << "the third angle measures\n";

cout << "------------------------------------\n";

int x, y;

cout << "please enter the first angle=";

cin >> x;

cout << "please enter the second angle=";

cin >> y;

cout << "the third angle =" << 180-(x + y) << "\n";

cout << "------------------------------------\n";

//05the lone and interst

cout << "the lone calculator\n";

cout << "------------------------------------\n";

int the_lone, the_interest,interest;

cout << "please enter the lone=";


cin >> the_lone;

cout << "please enter the interest value=";

cin >> the_interest;

cout <<"the interest="<< (the_lone*the_interest /100)<<"\n";

interest = (the_lone * the_interest / 100);

cout << "the total amoant =" << the_lone + interest<<"\n";

cout << "------------------------------------\n";

//06 the regular shape

cout << "the regular shape measure\n";

cout << "------------------------------------\n";

int regular_shape_size, num_of_side;

cout << "please enter the measure of the regular shape=";

cin >> regular_shape_size;

cout << "please enter the number of side=";

cin >> num_of_side;

cout << "the perimeter of the shape=" << regular_shape_size * num_of_side << "\n";

cout << "------------------------------------\n";

//07 the number squared and cubed

cout<<"the number squared and cubed\n";

cout << "------------------------------------\n";

int num;

cout << "please enter the number=";

cin >> num;

cout << "the number squared=" << num * num << "\n";

cout << "the number cubed=" << num * num * num << "\n";

cout << "------------------------------------\n";


//08 calculator

cout << "calculator\n";

cout << "------------------------------------\n";

int num1, num2;

char ope;

cout << "please enter the first number=";

cin >> num1;

cout << "please chose from [+ or -] : ";

cin >> ope;

cout << "please enter the seconed number=";

cin >> num2;

if (ope == '+') {

cout <<"the result="<< num1 + num2 << "\n";

cout <<num1<<ope<<num2<<"="<< num1 + num2 << "\n";

else

cout << "the result=" << num1 - num2<<"\n";

Q2

A-error (not allowed to but function in data name)

B-J

cout << num1 << ope << num2 << "=" << num1 - num2<<"\n";

Q2-
A-Error (can’t but function in data name)

B-J

You might also like