0% found this document useful (0 votes)
10 views6 pages

Assignment Lab

The document contains 4 C++ programs written by a student named M. Usman for their assignment at COMSATS University Vehari. The first program calculates the area of a triangle given the lengths of 3 sides. The second program calculates the price per square inch of a pizza given its radius and total price. The third program calculates the average of 4 test scores. The fourth program calculates a tax percentage if the amount is between 300-500, otherwise it checks if there is enough balance.

Uploaded by

Usman Dogar
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)
10 views6 pages

Assignment Lab

The document contains 4 C++ programs written by a student named M. Usman for their assignment at COMSATS University Vehari. The first program calculates the area of a triangle given the lengths of 3 sides. The second program calculates the price per square inch of a pizza given its radius and total price. The third program calculates the average of 4 test scores. The fourth program calculates a tax percentage if the amount is between 300-500, otherwise it checks if there is enough balance.

Uploaded by

Usman Dogar
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/ 6

COMSATS UNIVERSITY VEHARI

ASSIGNMENT
NAME : M.USMAN

SUBJ TEACHER : Mam Ayesha

ROLL NUMBER : 003


PROGRAMS
#include<iostream>

#include<math.h>

using namespace std;

int main()

//let a ,b ,c is the length of the triangles

int a,b,c;

float area,s;

cout<<"enter the length 1 of the triangle= ";

cin>>a;

cout<<"enter the length 2 of the triangle= ";

cin>>b;

cout<<"enter the length 3 of the triangle=";

cin>>c;

//s will be declared as the 1/2.

s=(1.0/2.0)*(a+b+c);

area= sqrt(s*((s-a) * (s-b) * (s-c)));

cout<<area;

}
Programe 2ND

#include<iostream>

#include<math.h>

using namespace std;

int main()

int price; //USd

int radius; //inches

float sqr;

cout<<"Enter pizza radius in inches: ";

cin>>radius;

cout<<"Enter price of pizza (USD): ";

cin>>price;

sqr = 3.14 * radius * radius;

cout<<"Price of pizza per square in is: "<<price/sqr;

return 0;

}
Programe 3rd

#include <iostream>

using namespace std;

int main()

int test1,test2,test3,test4;

float avg;

cout<<"enter the test score 1 =";

cin>>test1;

cout<<"enter the test score 2 =";

cin>>test2;

cout<<"enter the test score 3 =";

cin>>test3;

cout<<"enter the test score 4 =";

cin>>test4;

avg=test1+test2+test3+test4/4;

cout<<"the average of the test score are ="<<avg;

}
Programe 4th

#include <iostream>

using namespace std;

int main()

int amount ;

float percnt;

cout<<"enter the amount ";

cin>>amount;

percnt=(4)/amount*100;

if(amount>300 && amount<500){

cout<<percnt<<" is detected from your account as tex";

else if(amount<=300){

cout<<amount<<" is withdraw from your bank account";

else

cout<<"you dont have enough balance in your account";


}

You might also like