You are on page 1of 6

LAB REPORT 1

DFC2073
Programming
Fundamentals
NAME
REGISTRATION NO

CLASS

PROGRAMME DIPLOMA OF DIGITAL TECHNOLOGY


1. LIM BOON PING
LECTURER
1.0 THEORY
1. cout
Format : cout<<item1<<item2;
Examples :
a) Getting out Fixed Number : cout<<99;
b) Getting out Fixed Character : cout<<”Hello”;
c) Getting out variable : cout<<Nombor1;
Header file needed : iostream.h

2. cin
Header file : iostring.h
Syntax : cin>>item1;
Example :

3. Comment

4. Escape Sequence
Syntax :
Example :

5. Declare Variable
Syntax :
Example : a) Declare integer variable : int Nombor1 ;
b) Declare floating point variable : float Nombor2;
c)
2.0 PROGRAM & OUTPUT
You must prepare IPO and Flowchart when stated in the labsheet, not all.
You must write comment for you coding at IMPORTANT line only, not all.

LAB 1 A
2.1.1 IPO
IPO :
Input G1,G2,G3,G4,G5,Avg
Process Avg = (G1+G2+G3+G3+G5)/5
Output Avg

2.1.2 Flowchart
2.1.3 Program Lab1A
( copy and paste from VC++ )
//This program is used to encounter the problem with cin.
#include<cstdio>
#include<iostream>
using namespace std;

void main ()
{

int Age; //Define variable


char Surname[20];
char Name[20];
char Clear[10]; //kdkdkldklasdkldkldkld

cout<<"Please key hhjhhhhhhhhhhhhhhhhhhhhhin your Age : ";


cin>>Age;

gets(Clear); //dkdkldkl;dkldkldkl
cout<<"\nPlease key in your Sur Name : ";
gets(Surname);
cout<<"\nnAge : "<<Age;
cout<<"\nSurname : "<<Surname<<endl;

}
2.1.4 Output Lab1A
Display your name, registration no. and class in every output.

2.1.5 Question & Answer:


Answer all question.

1. What happen when user press 6.

_________________________________________________________________

2.1.6 Discussion :
Lab1A
1. Warning occur after compiling:
Possible loss of data when convert from float to double.
avg=(g1+g2+g3)/3.0;

This warning happen because …..


LAB 1B

2.2 Program Lab1B

2.2.1 Output Lab1B

2.2.2 Question & Answer:

2.2.3 Discussion :

3.0 REFERENCE
Please follow APA format.
Font= Arial, 12.
Spacing 1.5

Marking Scheme :
i. Problem solving, Q&E & Code 25 Marks
ii. Code Readability / Comment 2 Marks
iii. Theory & Discussion 3 Mark

Total : 30 Marks

You might also like