You are on page 1of 2

Exercise Week4n5

1. State whether the below variables declaration is valid or not? If it’s invalid give a reason.

Define/declare variables Yes/No Reason

i. char _ic_number;

ii. Int RMX;

iii. bool test;

iv. float 1number;

v. unsigned int myaccount;

vi. long saving = 1000;

vii. char mycharacter = ‘?’;

2. State which data type is suitable.

Define/declare variables Data Type

i. 500

ii. 78000

iii. 78.86

iv. A

v. &

vi. False

vii. 1000000000000
3. Write a C++ statement to accomplish each of the following task.

a. Declare/define variable(s) named as test and exam to be type of float.

b. Write C++ statement(s) to print value in variable test and exam.

c. Assign C to collect, where collect is a variable of char data type.

4. For the following C++ program what is the output ?

#include <iostream.h>
void main()
{
float average;
int reminder, score1, score2, score3,score4;
score1=11;
score2=12;
score3=13;
score4=10;
score2=15;

cout<<”score1 = “<<score1<<endl;
cout<<”score2 = “<<score2<<endl;
cout<<”score3 = “<<score3<<endl;
cout<<”score4 = “<<score4<<endl;
}

5. Write a complete C++ program based on the given instruction.

a. Declare/define variable(s) named as num1 and num2 to be type of int.


b. Assign 10 to num1.
c. Assign 15 to num2.
d. Write C++ statement(s) to print value in variable num1 and num2.

Run this program in jGrasp and print the output

6. Write a program to calculate and display an average of four numbers.

You might also like