Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
29 views

3.3 Short Answer Question

This document contains sample questions and problems related to C++ programming. It includes 10 short answer questions testing concepts like valid identifiers, character formatting, and arithmetic operations. It also includes 5 programming questions to write code that prints formatted text, reads and displays numbers in different orders, calculates sum and average, prints a pyramid pattern, and finds the largest of three numbers given as input. The final section provides a case study problem to develop code to find the largest of three numbers entered by the user.

Uploaded by

semuty92
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

3.3 Short Answer Question

This document contains sample questions and problems related to C++ programming. It includes 10 short answer questions testing concepts like valid identifiers, character formatting, and arithmetic operations. It also includes 5 programming questions to write code that prints formatted text, reads and displays numbers in different orders, calculates sum and average, prints a pyramid pattern, and finds the largest of three numbers given as input. The final section provides a case study problem to develop code to find the largest of three numbers entered by the user.

Uploaded by

semuty92
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

3.

3 SHORT ANSWER QUESTION


1. Which of the following are not valid identifiers in C++?
a) A5
b) 5A
c) if
d) Toll-rate
e) abu
f) c$five
2. How is the newline character formed?
3. Declare a character called letter
4. Define a constant called TRUE which has a value of 1
5. Declare an integer called sum
6. Declare an integer variable called total and initialise it to zero.
7. Define a constant called GST with a value of .125
8. Assign the value of the variable number1 to the variable total
9. Show the value of x after each statement is performed:
a. x = 7 + 3 * 6 / 2 1;
b. x = 2 % 2 + 2 * 2 2 / 2;
c. x = ( 3 * 9 * ( 3 + ( 9 * 6 / (3) ) ) );
d. x = 3 * 4 + 4 / 2 5 * 4
10. Find any errors in the following program:
int main()
{
integer a=1;
character c=A;
printf(% d, %c,a,c);
}

3.4 PROGRAMMING QUESTION


1. Write a program that print the followings:
****************************************
Name: Muhammad Firdaus
Sem: 2
Code: PI009
University: UITM, Puncak Alam
***************************************
2. Write a program that will read three data and print them vertically in forward and reverse order. The
output is as follow:
Input three integers: 20 4.5 30
Your numbers forward:
20
4.5
30
Your numbers reverse:
30
4.5
20
3. Write a program that inputs three integers from user and prints the sum and average of these numbers.
The output should appear as follows:
Input three integers: 10 10
Sum is 20
Average is 10
4. Write a program where the output should appear as follows:
*****
****
***
**
*
5. Write a program to find the area of a square, given two sides.

3.5 CASE STUDY


Analyze the below problem by identifying the input requirement of the problem. Subsequently, build the
algorithm/pseudo code/flow chart before you start your coding.
1. You need to develop a program that can find the largest number among three numbers. The program
should be able to get an input from the user. The program should display as follow:
1st num- 3; 2nd num- 4 3rd num-5;
The largest number is 5;

You might also like