0% found this document useful (0 votes)
18 views

Programming Assigment

Q1. This program takes in a number of gallons from the user and converts it to cubic feet using a conversion factor of 7.481. Q2. This program outputs sales figures for 1990, 1991, 1992, and 1993. Q3. This program takes a 3 digit number as input, uses modulo and division to extract each digit, and outputs the individual digits.

Uploaded by

Muzammil Brohi
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)
18 views

Programming Assigment

Q1. This program takes in a number of gallons from the user and converts it to cubic feet using a conversion factor of 7.481. Q2. This program outputs sales figures for 1990, 1991, 1992, and 1993. Q3. This program takes a 3 digit number as input, uses modulo and division to extract each digit, and outputs the individual digits.

Uploaded by

Muzammil Brohi
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/ 3

Q1.

#include<iostream>
using namespace std;
int main() {
double a = 7.481, b, c;
cout << "Enter your Gallons = ";
cin >> b;
c = b / a;
cout << "Gallons Equal to Cub Feet =" << c;

}
Q2.
#include<iostream>
using namespace std;
int main() {
cout << "\t1990 135 " << endl;
cout << "\t1991 7290 " << endl;
cout << "\t1992 11300 " << endl;
cout << "\t1993 16200 ";
}

Q3

#include<iostream>
using namespace std;
int main() {
int temp = 123, a, b, c;
a = temp % 10; // Quotient
cout << "Show the Quotient of 123 and Save A = " << a << endl;
temp = temp / 10; //Reminder
cout << "Show the Reminder of 123 and Save Temp = " << temp << endl;
b = temp % 10; // Quotion
cout << "Show the Quotient of 12 and Save in B = " << b << endl;
c = temp / 10; // Reminder
cout << "Show the Reminder of 12 and Save c = " << c << endl;
cout << a << b << c;

}
Q4

#include <iostream>
using namespace std;
int main()
{
cout << "\tTwinkle, twinkle, little star,\n\tHow I wonder what you are!\n\tUp above the world
so High,\n\tLike a diamond in the sky ";
}

Q5
#include <iostream>
using namespace std;

int main()
{
double p = 1.487, f = 0.172, d = 0.584, y = 0.00955, dollar, pound, franc, deutschemark, yen;
cout << "Enter Your Dollars=";
cin >> dollar;
pound = dollar / p;
cout << "Dollar Convert To Pound = " << pound << endl;
franc = dollar / f;
cout << "Dollar Convert To Franc = " << franc << endl;
deutschemark = dollar / d;
cout << "Dollar Convert To Deutschemark = " << deutschemark << endl;
yen = dollar / y;
cout << "Dollar Convert To Yen = " << yen << endl;
return 0;
}

Q6
#include <iostream>
using namespace std;

int main() {
float celsius, fahrenheit;
cout << "Enter in Celsius = ";
cin >> celsius;
fahrenheit = (celsius * 9 / 5) + 32; // Correct the formula
cout << "Value Of Fahrenheit = " << fahrenheit;
return 0;
}

Q7
#include <iostream>
using namespace std;

int main() {
int a, b, c, d, e, f, g, h;
cout << "Enter the value of a: ";
cin >> a;
cout << "Enter the value of b: ";
cin >> b;
cout << "Enter the value of c: ";
cin >> c;

// a^2 - b^2 = (a - b)(a + b)


d = (a - b) * (a + b);

// (a + b)^2 = a^2 + 2ab + b^2


e = a * a + 2 * a * b + b * b;

// (a - b)^2 = a^2 - 2ab + b^2


f = a * a - 2 * a * b + b * b;

// (a + b + c)^2 = a^2 + b^2 + c^2 + 2ab + 2bc + 2ca


g = a * a + b * b + c * c + 2 * a * b + 2 * b * c + 2 * a * c;

// (a + b)^3 = a^3 + 3a^2b + 3ab^2 + b^3


h = a * a * a + 3 * a * a * b + 3 * a * b * b + b * b * b;

cout << "Value of d = " << d << endl;


cout << "Value of e = " << e << endl;
cout << "Value of f = " << f << endl;
cout << "Value of g = " << g << endl;
cout << "Value of h = " << h;

return 0;’
}
s

You might also like