Basic C++ Problems
Basic C++ Problems
Basic C++ Problems
Enrollment: 02-132212-044
Write an Algorithm, Pseudo Code and Draw Flow Chart of the following given
problems.
Task 1: Find whether the sum of two numbers is greater than 25.
ALGORITHM:
INPUT:
Num 1, Num2.
PROCESSING:
Step 1: Start
Step 2: Input num1, num2
Step 3: Add num1 and num2 if the sum is greater than 50 go to step 4 else go
to step 2 i.e. take another two numbers.
Step 4: Print true.
Step 5: Stop
OUTPUT:
CODE:
#include <iostream>
int main()
{
int a;
int b;
cout << "Enter a value for variable a \n";
cin >> a;
cout << "Enter another value for variable b \n";
cin >> b;
int c = a+b;
if(c > 25){
cout << "Sum of variable a and b is greater than 25";
} else {
cout << "Sum of a and b is less than 25";
}
return 0;
}
Task 2: Find the volume of the rectangular box. Note: volume = length x width x height
ALGORITHM:
INPUT:
PROCESSING:
Step 1: Start
Step 2: Length, width and height.
OUTPUT:
END
CODE:
#include <iostream>
int main()
{
int w;
int h;
int l;
cout << "Enter width of a Rectangular box \n";
cin >> w;
int V = w * h * l;
ALGORITHM:
INPUT:
Value of x, y and z.
PROCESSING:
Step 1: Start
Step 2: input x, y, z.
OUTPUT:
Value of A.
FLOW CHART:
PSEUDO CODE:
Start
Input x, y, z
cout<<"Enter value of x "<<endl;
cin>>x;
cout<<"Enter value of y "<<endl;
cin>>y;
cout<<"Enter value of z "<<endl;
cin>>z;
cout<<"the value of A is "<< (4x – 3y) / 2z<<endl;
END
CODE:
#include <iostream>
int main()
{
double x;
double y;
double z;
cout << "Enter a value for variable x \n";
cin >> x;
cout << "Enter a value for variable y \n";
cin >> y;
cout << "Enter a value for variable z \n";
cin >> z;
double A = (4*x-3*y)/2*z;
Task 4: Write a program to display your personal information. (Name, age, address, father's name,
college name, NIC, phone number etc.)
#include <iostream>
int main()
}
Task 5:Write a program to display your semester courses along with teacher name and credit hour.
#include <iostream>
namespace std;
int main () {
cout << "| \t Course Name \t \t \t | \t Teacher name \t \t \t | \t Credit Hour \t |" << endl;
cout <<
"====================================================================================
======================" << endl;
cout << "| Computer Programming \t \t | Engr. Adnan ur Rehman \t \t | 3 + 1 \t \t |" << endl;
cout << "| Computing Fundamentals \t \t | Engr. Mahwish Khan \t \t \t | 2 + 1 \t \t |" << endl;
cout << "| Applied Physics \t \t \t | Engr. Rizwan Iqbal \t \t | 3 + 1 \t \t |" << endl;
return 0;}
Task 6 : Write a program that prints a mosque, similar to the following
#include <iostream>
int main()
cout<<" ^ ^ ^ "<<endl;
cout<<" \"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"
"<<endl;
cout<<" | _ | "<<endl;
cout<<" ........................................................."<<endl;
return 0;
}