Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
LAB EXERCISE 1
DFC 2013 : PROGRAMMING
FUNDAMENTALS
1./2./4.
//Calculate the average of 3 input value
#include<iostream>//standard header files
using namespace std;
void main()//main function : where the execution begins
{
float g1,g2,g3,g4,g5,avg;
cout<<"Please key in the first student score : \n";//output
cin>>g1;//input
cout<<"Please key in the second student score : \n";//output
cin>>g2;//input
cout<<"Please key in the third student score : \n";//output
cin>>g3;//input
cout<<"Please key in the fourth student score : \n";//output
cin>>g4;//input
cout<<"Please key in the fifth student score : \n";//output
cin>>g5;//input
avg=(g1+g2+g3+g4+g5)/5.0;//process for this calculation
cout<<"The average score for the students is "<<avg<<"\a"<<"\n";//output
system("pause");
Namapenuh,
namasamaran
5.a)
IPO Table
Input
g1,g2,g3,g4,g5
Process
Output
Average Score
5.b)
Flow Chart
Start
g1,g2,g3,g4,g5
Calculate average =
(g1+g2+g3+g4+g5)/5.0
Average Score
End
//This program is used to display your family name and your full name.
#include <iostream>//standard header file
using namespace std;//standard header file
void main()//main function : where the excution program begins
{
char NamaSamaran [36];//declaring data type char with identifier
char NamaPenuh [20];//declaring data type char with identifier
cout<<"Please key in your full name : ";//first output
cin>>NamaPenuh;//first input
cout<<"\n Your full name is "<<NamaPenuh<<"\n";//second output with
the user first output
cout<<"Please key in your Nick Name (No Spacing): ";//third output
cin>>NamaSamaran;//second input
cout<<"\n Your nick name is "<<NamaSamaran<<"\n";//fourth output
with the user second output
system("pause");
}
3.a)
IPO Table
Input
Namasamaran,
Namapenuh
Process
Output
3.b)
Namapenuh ,
Namasamaran
Flow Chart
Start
Namasamaran,
namapenuh
Namapenuh,
namasamaran
End
4. When user type his/her name as Abu Bakar the output will
directly show the
nick name.
7. When cin is use to read nick name before gets read full name it will doesnt
show Nick Name.
8.
#include <iostream>//standard header file
#include <cstdio>//standard header file
using namespace std;//standard header file
void main()//main function : where the excution program begins
{
char Umur[10];//declaring data type char with identifier
char NamaPenuh[20];//declaring data type char with identifier
PROGRAM 2E :
cout<<"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@";//ouput
IPO TABLE
INPUT
PROCESS
OUTPUT
FLOW CHART
Start
Calculate employees
monthly payment
End