Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 15

COMPUTER PROGRAMMING

Assignment by: Sharjeel Baig

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:

Sum of two numbers is greater than 50


FLOW CHART:
PSEUDO CODE:
 
 Start
 Input num 1, num 2, sum
 cout<<"Input number1 :"<<endl;
 cin>>num 1;
 cout<<"Input number2 :"<<endl;
 cin>>num 2;
 cout<<"Input number1 :"<< num 1 + num 2 <<endl;
 if (num1 + num2> 50)
{ cout<<"The sum is Greater than 50"<<endl; }
else
{ cout<<"the sum is less than 50"<<endl; }
 END

CODE:
#include <iostream>

using namespace std;

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:

Length, width and height.

PROCESSING:

 Step 1: Start
 Step 2: Length, width and height.

 Step 3: calculate the volume of rectangular box by volume = Length x width x


height.
 Step 4: Print volume of rectangular box.
 Step 5: Stop.

OUTPUT:

Volume of rectangular box.


FLOW CHART:
PSEUDO CODE:
 Start
 Input length, width and height
 cout<<"Enter value of length "<<endl;
 cin>>length;
 cout<<"Enter value of width "<<endl;
 cin>>width;cout<<"Enter value of height "<<endl;
 cin>>height;
 cout<<"the volume of rectangular box is "<<length * width * height<<endl;

 END

CODE:
#include <iostream>

using namespace std;

int main()
{
int w;
int h;
int l;
cout << "Enter width of a Rectangular box \n";
cin >> w;

cout << "Enter height of a rectangular box \n";


cin >> h;

cout << "Enter length of a rectangular box \n";


cin >> l;

int V = w * h * l;

cout << "Volume of a rectangular box: " << V;


return 0;
}

Task 3: Find the value of A such that A = (4x – 3y) / 2z

ALGORITHM:
INPUT:

Value of x, y and z.

PROCESSING:

 Step 1: Start
 Step 2: input x, y, z.

 Step 3: calculate the value of A by A = (4x – 3y) / 2z


 Step 4: Print value of A.
 Step 5: Stop.

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>

using namespace std;

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;

cout << "A = " << A;


return 0;
}

Task 4: Write a program to display your personal information. (Name, age, address, father's name,
college name, NIC, phone number etc.)

#include <iostream>

using namespace std;

int main()

cout << "Name:Muhammad Sharjeel Baig\n";

cout << "Age: 18\n";

cout << "Gulistan-e-johar Karachi Pakistan \n";

cout << "Father's name: Muhammad Mujeeb Baig \n";

cout << "collage name: Government collage hyderabad\n";

cout << "Nic: 413034-205109-3\n";

cout << "Phone Number: +92-3432595361";


return 0;

}
Task 5:Write a program to display your semester courses along with teacher name and credit hour.

#include <iostream>

namespace std;

int main () {

cout << "----------------------------------------------------------------------------------------------------------" << endl;

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;

cout << "| English I \t \t \t \t | Engr.Bushra fazal \t \t \t | 3 + 0 \t \t |" << endl;

cout << "----------------------------------------------------------------------------------------------------------" << endl;

return 0;}
Task 6 : Write a program that prints a mosque, similar to the following

#include <iostream>

using namespace std;

int main()

cout<<" ^ ^ ^ "<<endl;

cout<<" /|\\ /|\\ /|\\ "<<endl;

cout<<" ((&)) ((^)) ((&)) "<<endl;

cout<<" |.| .((^)). |.| "<<endl;

cout<<" |.| ((((|)))) |.| "<<endl;

cout<<" |.| (((((|))))) |.| "<<endl;

cout<<" |.| ((((((|)))))) |.| "<<endl;

cout<<" |.| (((((|))))) |.| "<<endl;

cout<<" |.| ((((|)))) |.| "<<endl;


cout<<"
{\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"}"<<endl;

cout<<" \"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"
"<<endl;

cout<<" | _ | "<<endl;

cout<<" | {#} | "<<endl;

cout<<" | {#####} | "<<endl;

cout<<" | _____ {#######} _____ | "<<endl;

cout<<" | |#####| {#######} |#####| | "<<endl;

cout<<" | |#####| {#######} |#####| | "<<endl;

cout<<" | ===== {#######} ===== | "<<endl;

cout<<" | {#######} | "<<endl;

cout<<" | {#######} | "<<endl;

cout<<" | {#######} | "<<endl;

cout<<" ........................................................."<<endl;

return 0;
}

You might also like