0% found this document useful (0 votes)
34 views21 pages

Programming Compilation Ren and Mudag

The document describes 10 activities involving C++ programs. The programs demonstrate basic concepts like input/output, variables, operators, and conditional statements. Activity 6 shows a login authentication for a scientific calculator program.

Uploaded by

renebert Banac
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)
34 views21 pages

Programming Compilation Ren and Mudag

The document describes 10 activities involving C++ programs. The programs demonstrate basic concepts like input/output, variables, operators, and conditional statements. Activity 6 shows a login authentication for a scientific calculator program.

Uploaded by

renebert Banac
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/ 21

Partial Requirement for

ES-122 subject under


Mr. Abdul-jalil C. Marohom

Mudag, Mohamad M.
Banac, Renebert T.
Table of Contents Page

Activity 1 2
Activity 2 3
Activity 3 5
Activity 4 5
Activity 5 7
Activity 6 8
Activity 7 10
Activity 8.1 12
Activity 8.2 13
Activity 8.3 14
Activity 8.4 15
Activity 9.1 16
Activity 9.2 18
Activity 10 20
1

TOPIC

Contents
Disctiption
Figure
Sample
2

ACTIVITY 1 Create a program that will display your: Name, Age, ID Number,
School Background.

#include <iostream>
Using namespace std;

Int main() {

Cout << “Name: Mohammad Mudag” << endl;


Cout << “Age: 18” << endl;
Cout << “ID Number: 20210635” << endl;
Cout << endl;
Cout << “ School Background” << endl;
Cout << endl;
Cout << “Elementary: Yanbu Elite International School” << endl;
Cout << “Junior Highschool: St. Michael’s College” << endl;
Cout << “Senior Highschool: Philippine Engineering and Agro-Industrial College,
Inc.” << endl;
Cout << “College: Philippine Engineering and Agro-Industrial College, Inc.” << endl;

Cout << “Name: Renebert T. Banac” << endl;


Cout << “Age: 20” << endl;
Cout << “ID: 20220599” << endl;
Cout << endl;
Cout << “ School Background” << endl;
Cout << endl;
Cout << “Elementary: Philippine Engineering and Agro-Industrial College, Inc.” <<
endl;
Cout << “Junior Highschool: Philippine Engineering and Agro-Industrial College,
Inc.” << endl;
Cout << “Senior Highschool: Philippine Engineering and Agro-Industrial College,
Inc.” << endl;
Cout << “College: Philippine Engineering and Agro-Industrial College, Inc.” << endl;

Return 0;
}

ACT 1. Flow of Program

Start Print all Display


End
information Output
3

ACT 1. OUTPUT

ACTIVITY 2 Declare a variable from Act 1, Display all values using Variables.

#include <iostream>
#include <string>
Using namespace std;

Int main() {

String identification1 = “Mohammad Mudag”;


String identification2 = “Renebert T. Banac”;

Cout << “Partner” << endl;


Cout << identification1 << endl;
Cout << identification2 << endl;

Cout << “age” << endl;


Int age1 = 18;
Int age2 = 20;
Cout << age1 << endl;
Cout << age2 << endl;

Cout << “School Id Number” << endl;


Int id1 = 20210635;
Int id2 = 20220599;
Cout << id1 << endl;
Cout << id2 << endl;

String Hschool1 = “St. Michael’s College”; //


String Hschool2 = “Philippine Engineering and Agro-Industrial College, Inc.”;

Cout << “\nSchool Background\n” << endl;

Cout << “High School:” << endl;


4

Cout << Hschool1 << endl;


Cout << Hschool2 << endl;

String Elschool1 = “Yanbu Elite International School”;


String Elschool2 = “Philippine Engineering and Agro-Industrial College, Inc.”;

Cout << “\nElementary School:” << endl;


Cout << Elschool1 << endl;
Cout << Elschool2 << endl;

Return 0;
}

ACT:2 FLOW OF PROGRAM

Identification as
Print Partner Print
Mohammad M. Mudag
Start Identification
& Renebert T.Banac
1, and 2

Print ID1, Define ID1, Print age1 and Define age1 as


AND ID2 AND ID2 age2 18 and age2 as
20

Define Print Define Print Elschool1,


Hschool1, and Hcshool1, and Elschool1, and and Elschool2
Hcshool2 Hcshool2 Elschool2

Print
ACT:2 OUTPUT End Elschool1,and
Elschool2
5

ACITIVITY 3 Series

#include<iostream>
Using namespace std;

Int main()
{
Int x=10;
Float y=12.5;
Float z=(x+y);

Cout<<z*z;

Return 0;
}

ACT 3. FLOW OF PROGRAM

Start Assign value Assign value


10 to x 12.5 to y
Calculate z=x+y End

ACT 3. OUTPUT

ACTIVITY 4: Declare a variable from activity 1, input a value/data into the


variables. Display all values.

#include<iostream>
Using namespace std;

Int main() {
string name, age, id, background;

Cout << “May I know your name?” << endl;


Cout << “My name is “;
Getline(cin, name);
Cout << “What year were you born?” << endl;
Cout << “I was born on “;
Getline(cin, age);
6

Cout << “What is your ID number?” << endl;


Cout << “My ID number is “;
Getline(cin, id);
Cout << “Where did you finish your Senior High School?” << endl;
Cout << “I finished my Senior High School at “;
Getline(cin, background);

Return 0;
}

ACT 4. FLOW OF PROGRAM

May I know My Input


Start your name name is name

Input age I was What year where


born on you born?

What is your My ID Input


Id number number is ID

Input I finished my Where did


Background SHS at you finished
your SHS?

End

ACT 4. OUTPUT
7

ACTIVITY 5 Using if else statement program an age authentication for voting


system. The legal age for voting is 18 years old above, and below 18 years old is not
qualified to vote.

#include <iostream>
Using namespace std;

Int main() {
Int age;
String name;

Cout << “\t\t VOTING SYSTEM\t\t “ << endl;

Cout << “INPUT YOUR NAME: “;


Getline(cin, name);

Cout << “INPUT YOUR AGE DESCRIPTION: “;


Cin >> age;

If (age >= 18) {


Cout << “VOTING REGISTRATION SUCCESS”;
} else {
Cout << “BELOW AGE 18 IS NOT QUALIFIED”;
}

Return 0;
}

ACT 5. FLOW OF PROGRAM

Print voting Input Input


Start
system name name

Check if age
Print voting is greater
Start success than 0r = to
18

ACT 5. OUTPUT
8

ACTIVITY 6 Create a program that will display the SUM, DIF,MULTI,DIV OF 2


variable usin if else statement to choose ritjmetic operation. Use a Login
aunthentication to access the calc
#include <iostream>
#include <string>
Using namespace std;

Int main() {
String signin, password;
Int numeral1, numeral2;
Char op;

Cout << “\t\t SCIENTIFIC CALCULATOR \t\t” << endl;

Cout << “Sign in: “;


Cin >> signin;

If (signin == “ALBERTEINSTEIN”) {
Cout << “Insert Password: “;
Cin >> password;

If (password == “CHARLESBABBAGE”) {
Cout << “SIGNING IN….”;
} else {
Cout << “WRONG PASSWORD. TRY AGAIN.”;
}
} else {
Cout << “INVALID USERNAME”;
}
Cout << “\n\t\t SCIENTIFIC CALCULATOR \t\t” << endl;
Cout << “INSERT VALUE NUMERAL 1: “;
Cin >> numeral1;
Cout << “+|-|*|/”;
Cin >> op;
Cout << “INSERT VALUE NUMERAL 2: “;
Cin >> numeral2;
If (op == ‘+’) {
Cout << numeral1 + numeral2;
} else if (op == ‘*’) {
Cout << numeral1 * numeral2;
} else {
Cout << “Invalid operator”;
}
Cout << endl;
Return 0;
9

ACT 6. FLOW OF PROGRAM

Check if yes
Scientifi Input
Start c Sign in sign in is
ALBERTE passwor
calculato d
INSTEIN

Check if
Input num1, and Scientifi yes password
Sign in is
num2 c
calculato CHARLES
BABBAG

no
If op is ‘+’ If op is ‘*’
perform perform Wrong
addition & multiplicati password
print result on & print

If op is ‘*’
perform
multiplicati End
on & print

ACT 6. OUTPUT
10

ACTIVITTY 7 Attire Setting

#include<iostream>
Using namespace std;
Int main()
{
String ATTIRE, BATMANORSUPERMAN, LEATHERORCANDY;
Cout<<”Attire (COSTUME or JACKET): “;
Cin>>ATTIRE;
If(ATTIRE == “COSTUME”){
Cout<<”What costume would you like to wear? (BATMAN or SUPERMAN): “;
Cin>>BATMANORSUPERMAN;
If (BATMANORSUPERMAN == “BATMAN”){
Cout<<”BATMAN COSTUME”;
}
Else if (BATMANORSUPERMAN== “SUPERMAN”) {
Cout<<”SUPERMAN COSTUME”;
}
Else {
Cout<<”Please, Try again.”;
}
}
Else if (ATTIRE == “JACKET”){
Cout<<”What type of jacket would you like to wear? (LEATHER or CANDY):
“;
Cin>>LEATHERORCANDY;
If(LEATHERORCANDY == “LEATHER”){
Cout<<”LEATHER JACKET”;
}
Else if (LEATHERORCANDY== “CANDY”) {
Cout<<”CANDY JACKET”;
}
Else {

Cout<<”Please, Try again”;


}
}

Else {
Cout<<”Please, try again”;
11

ACT 7. FLOW OF PROGRAM

Start

Input Attire=
Attire attire Attire Costume

Candy
Leather Type Attire=Jacket Type Display
Jacket

Display End
End Display
Candy
Jacket

ACT 7. OUTPUT
12

ACTIVITY 8.1 LOOPS

#include<iostream>
Using namespace std;

Int main()

{
For(int x=0; x<=100; x++){

Cout<<x<<endl;

Return 0;
}

ACT 8. FLOW OF PROGRAM

Check
Initialize x to 0 if x is < Print the
Start
or =100 value of x

Repeat the Check if the


End loop until x is loop
greater than condition is
100

ACT 8.1 OUTPUT


13

ACTIVITY 8.2
#include<iostream>
Using namespace std;

Int main()
{
For(int x=0; x<=18; x++){
Cout<<”Ren & Mudag”<<x<<endl;
}

Return 0;
}

ACT 8.2 FLOW OF PROGRAM

Check Print Ren &


Start Initialize x to 0 if x is < Mudag followed
or =18 by the value of x

Repeat the Check if the


Start loop until x is loop
greater than 18 condition is

ACT 8.2 OUTPUT


14

ACTIVITY 8.3
#include <iostream>
Using namespace std;

Int main() {
For (int I = 1; I <= 100; I += 2) {
Cout << I << “ “;
}

Cout << endl;


Return 0;
}

ACT 8.3 FLOW OF PROGRAM

Print the
Start Initialize i to 1 Check if i is value of i
< or = to 100 followed y a
space

Repeat the Check if the


End loop until i is loop
greater than condition is
100
15

ACT 8.3 OUTPUT

ACTIVITY 8.4
#include <iostream>
Using namespace std;

Int main() {
For (int I = 2; I <= 100; I += 2) {
Cout << I << “ “;
}

Cout << endl;


Return 0;
}

ACT 8.4 FLOW OF PROGRAM

Print the
Check if i is value of i
Start Initialize i to 2 < or = to 100 followed y a
space

Repeat the Check if the


End loop until i is loop
greater than condition is
100
16

ACT 8.4 0UTPUT

ACTIVITY 9.1 Loop Program of the given output

#include<iostream>
Using namespace std;

Int main()
{
Int e;
Int r;

For(e = 1; e <= 4; e++){


For(r = 1; r <= 5; r++)
{
Cout<<” * “;
}
Cout<<”\n”;
}
Return 0;
}

ACT 9.1 FLOW OF PROGRAM

Check if
Initialize e to 1 e is < or Initialize r to 1
Start
equal to
17

Check if
the inner Print Check if r
condition is ‘’*’’ is< or equal
still true to 5

Check if the
outer loop
condition is
still true
Repeat the
inner loop
until r is
greater than

Check if the
outer loop
End
condition is
still true

ACT 9.1 OUTPUT


18

ACTIVITY 9.2
#include<iostream>
Using namespace std;

Int main()
{
Int e;
Int r;

For(e = 1; e <= 5; e++){


For(r = 5; r >= e; r--)
{
Cout<<” * “;
}
Cout<<”\n”;
}
Return 0;
}

ACT 9.2 FLOW OF PROGRAM

Check if e
is<or= 5
19

Start Initialize e to 1 Initialize r to 5

Check if
Print Check if r is
the inner
‘’*’’ > or = e
loop
condition is

Check if the
outer loop
condition is
still true

Repeat the
inner loop
until r is
greater than

Repeat the
End outer loop
until e is >5
ACT 9.2 OUTPUT

You might also like