1/30/2011

BCT1113 Test 1 (sample)

1. Respond with the correct answer by marking either True "T" or False "F" for each question.

a) High-level languages include Basic, FORTRAN, COBOL, Pascal, C, C++, C#, and Java

b) Compiler: translates a program written in a high-level language machine language

c) Preprocessor directives begin with # and are processed by a the preprocessor

d) Use the compiler to: Check that the program obeys the rules

e) Linker: Combines object program with other programs provided by the SDK to create executable code

f) Programming is a process of problem solving

g) Algorithm: Step-by-step problem-solving process

h) Two popular approaches to programming design: - 1) Structured 2) Object-oriented

i) The structured design approach is also called Modular Design


2. Print the output of the following C++ statement. If nothing prints, then answer "nothing". Assume x=3 and y=2.

Example) cout<<x; 2


a) cout<<y;

b) / * cout<<y; */

c) // cout<<x+y;

d) cout<<x<<y;

e) cout<<x<<endl<<y;

f) cout<<x+y;

g) cout<<"x+y="<<x+y;

h) cin>>x%y;

i) cout<<++x;

j) cout<<y++;


3. Print the output of the following C++ statement. If nothing prints, then answer "nothing".


a) if(1<3)

cout<<"Yes";

else

cout<<"No";


b) char race='M';

if ((race=='m') ||( race =='M')) then

cout<<"Malay";

else

cout<<"Others";


c) char race='M';

int age = 21;

if ((race=='m') &&( age <=20)) then

cout<<"MARA LOAN";

else

cout<<"PTPTN LOAN";


4. What is the output of the following C++ code segment:-


char race;

int age;

cin>>race>>age;

if(race='m')

if(age<=20)

cout<<"MARA LOAN";

else

cout<<"PTPTN LOAN";

else

cout<<"OTHER LOAN";


a) When the user inputs "C" for race and 21 for age

b) When the user inputs "C" for race and 18 for age

c) When the user inputs "m" for race and 21 for age

d) When the user inputs "m" for race and 18 for age


5. Prepare an algorithm (pseudo code or flowchart) and write a C++ program for each of the following problem.


a) Write a program to find perimeter and area of a rectangle. The perimeter and area of the rectangle are given by the following formulas:

perimeter = 2 * (length + width)

area = length * width


b) Write a program to read user id and password .if the password is "abubakar" and password is 6855 then print out "Your password is accepted". Otherwise print "Not Accepted".

No comments:

Cara download Installer windows 10 dalam format ISO

1. Jika anda bercadang untuk download windows 10 melalui website rasmi windows - pilihan untuk download dalam format ISO tidak di berikan.  ...