You are on page 1of 2

DEPARTMENT OF INFORMATION TECHNOLOGY & COMMUNICATION

DFC20113 – PROGRAMMING FUNDAMENTALS


LABORATORY TASK 1:
Introduction to C++ Programming

Learning Outcomes
By the end of this lab, student should be able to:
 Describe the structure of C++ programs
 Write, compile and run simple C++ programs
 Identify and correcting errors in the program

Question 1– 5 marks
Write C++ program below. Get the output.

#include <iostream>
void main()
{
cout<<"Welcome ";
cout<<"to Politeknik Kuala Terengganu "<< endl;
cout<<endl<<endl<<"PKT is a ";
cout<<"\n 12 polytechnic in Malaysia"<<endl;
}

Question 2– 5 marks

Write C++ program to generate following output.

**************************************************************************
C++ is a new language was developed by Bjarne Stroustrup
and was called C++. Stroustrup states that
the purpose of C++ is to make writing good programs
easier and more pleasant for the individual programmer.
************************************************************************* 

Question 3 – 10 marks

Identify errors from given program below. Correct them and get the output.

#include<iostream>

void main()
{
char name;
age;

cout<<"My name is:";


cin>>name
cout<<endl
cout<<"My age is :";
cin>>”age”;
old=60 x age
cout<<My name is "<<name<<" and my age is "<<age<<”. I have “<<old<<”
years for 60 years old…”<<endl;
}

Question 4– 10 marks

Write a complete C++ program to generate the output as follows:

a) Please insert three marks: 80 85 60


The marks that you have inserted : 80 85 60
80 + 85 + 60 = 225
b) Enter first letter : x
Enter second letter : y
Enter third letter : z
Your entering letters are : x, y, z

You might also like