0% found this document useful (0 votes)
36 views7 pages

Assignment No 1

This document contains the code for 4 programming tasks. It includes C++ code to: 1) Perform basic math operations like addition, subtraction, multiplication and division on two input numbers. 2) Calculate the sum and average of 3 input numbers. 3) Calculate BMI based on weight and height input in either pounds/inches or kg/meters. 4) Calculate final velocity, distance, or acceleration using kinematic equations based on input values for initial velocity, acceleration, and time.

Uploaded by

Huzaifa
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)
36 views7 pages

Assignment No 1

This document contains the code for 4 programming tasks. It includes C++ code to: 1) Perform basic math operations like addition, subtraction, multiplication and division on two input numbers. 2) Calculate the sum and average of 3 input numbers. 3) Calculate BMI based on weight and height input in either pounds/inches or kg/meters. 4) Calculate final velocity, distance, or acceleration using kinematic equations based on input values for initial velocity, acceleration, and time.

Uploaded by

Huzaifa
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/ 7

Computer fundamentals and programming

Assignment No:01

Deprtment: BSEE(Section-B)
Registration No: BSEE-12637-2020

Submitted by:

Muhammad Huzaifa zahid

Submitted to:

Sir Muhammad Tufail

Task No:01

Coding:
#include<iostream>
using namespace std;
int main()
{
system("color 70");
float a,b ,z;
int x, y,remainder;
char op;

cout << "enter the operation symbol ";


cin >> op;
switch (op)
{
case '+':
cout << "enter the value of a and b \n";
cin >> a >> b;
z = a + b;
cout << "sum of two number is = " << z;
break;

case '-':
cout << "enter the value of a and b \n";
cin >> a >> b;
z = a - b;
cout << "difference of two numbers = " << z;
break;

case'*':
cout << "enter the value of a and b \n";
cin >> a >> b;
z = a * b;
cout << "multiplication of two numbers = " << z;
break;

case'/':
cout << "enter the value of a and b \n";
cin >> a >> b;
if (b != 0)
{
z = a / b;
cout << "divison of two numbers = " << z;
}
else
{
cout << "error";
}
break;

case'%':

cout << "enter the value of x and y \n";


cin >> x >> y;
remainder = x % y;
cout << "remainder of two numbers = " << remainder;
break;
getchar();
return 0;

}
}

Output:

Task No:02

Coding:

#include<iostream>
using namespace std;
int main()
{
system("color 70");
int x, y, z, sum,average;
cout << "enter the value of x \n";
cin >> x;
cout << "enter the value of y \n";
cin >> y;
cout << "enter the value of z \n";
cin >> z;

sum = x + y + z;
cout << "sum of x,y and z is = " << sum<<endl;
average = (sum / 3);
cout << "average of x,y and z is = " << average;

getchar();
return 0;

Output:

Task No:03

Coding:
#include<iostream>
using namespace std;

int main()
{
system("color 70");
int x, y, BMI;
int unit;
cout << "enter 1 for BMI in pound per square inch" << endl;
cout << "enetr 2 for BMI in kg per square meter " << endl;
cin >> unit;
switch (unit)
{
case 1:
cout << "enter weight in pounds : ";
cin >> x;
cout << "enter height in inches : ";
cin >> y;
BMI = (x * 703) / (y * y);

cout << "BMI is equal to :" << BMI << " pound per square
inch";
break;
case 2:
cout << "enter weight in kg : ";
cin >> x;
cout << "enter height in meter : ";
cin >> y;
BMI = (x * 703) / (y * y);

cout << "BMI is equal to :" << BMI <<" kg per square meter";
break;

Output:

Task No:04

Coding:

#include<iostream>
using namespace std;

int main()
{

system("color 70");
float Vf, Vi, a, S, t;
int unit;
cout << "enter unit 1 for first equation\n enter 2 for second
equation \n enter 3 for third equation \n";
cin >> unit;

switch (unit)

{
case 1:
cout << "find Vf\n";
cout << "enter Vi in meter per second\n ";
cin >> Vi;
cout << "enter a in meter per second square\n ";
cin >> a;
cout << "enter time t in second\n ";
cin >> t;

Vf = Vi + (a * t);
cout << "Vf is" << Vf << "m/s";
break;
case 2:\
cout << "find S\n";
cout << "enter Vi in meter per second\n ";
cin >> Vi;
cout << "enter a in meter per second square\n ";
cin >> a;
cout << "enter time t in second\n ";
cin >> t;

S = (Vi * t) + (1 / 2 * a * t * t);
cout << "S is" << S << "m";
break;
case 3:
cout << "find a\n";
cout << "enter Vi in meter per second\n ";
cin >> Vi;
cout << "enter S in meter\n ";
cin >> S;
cout << "enter Vf\n ";
cin >> Vf;

a = ((Vf * Vf) - (Vi * Vi)) / (2 * S);


cout << "a is" << a << "meter per second square";
break;

getchar();
return 0;

Output:

You might also like