Labsheet / Assingment / Case Study / PBT: Jabatan Teknologi Maklumat Dan Komunikasi
Labsheet / Assingment / Case Study / PBT: Jabatan Teknologi Maklumat Dan Komunikasi
PREPARED BY:
N NAME MATRIC NO
O
1 NIK AFIQ AIMAN BIN NIK MAHMAD KAMAL 12DNS17F1024
PREPARED FOR:
Write a program to perform addition of two numbers using pointer. Your program must have this
following :
#include <iostream>
using namespace std;
void main()
{
int x, y, sum=0;
int *p, *q;
p = &x;
q = &y;
sum = x + y ;
system("pause");
}
Question 3 (CLO3, C3)
Write the programme based on the following situations. Every situation linked with another :
i. Name
iii. Age
iv. Courses
ii. Person B
i. Azhan Ariff
ii. 12DNS17F2001
iii. 18
iv. DNS
#include <iostream>
using namespace std;
struct Student
{
char name[20];
char matrix_num[20];
int age;
char courses[10];
};
void main()
{
cout<< "Person B" <<endl;
cout<< "Enter name : "<<endl;
cin>>person_B.name;
cout<< "Enter matrix number : "<<endl;
cin>>person_B.matrix_num;
cout<< "Enter age : "<<endl;
cin>>person_B.age;
cout<< "Enter courses : "<<endl;
cin>>person_B.courses;
cout<<endl;
system("pause");
}