0% found this document useful (0 votes)
5 views

C++question

The document contains self-check questions for first-year pre-engineering students in a Basic Engineering Computer Programming course. It includes questions on defining global and local variables, explaining C++ keywords, identifying errors in code, selecting appropriate data types, writing C++ code for specific tasks, and correcting syntax errors in provided code. The exam is designed to assess students' understanding of fundamental programming concepts and C++ syntax.

Uploaded by

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

C++question

The document contains self-check questions for first-year pre-engineering students in a Basic Engineering Computer Programming course. It includes questions on defining global and local variables, explaining C++ keywords, identifying errors in code, selecting appropriate data types, writing C++ code for specific tasks, and correcting syntax errors in provided code. The exam is designed to assess students' understanding of fundamental programming concepts and C++ syntax.

Uploaded by

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

ELECTRICAL AND COMPUTER ENGINEERING FACULTY

2012 AC. 2ND. SEMESTER BASIC ENGINEERING COMPUTER PROGRAMMING


QUESTIONS FOR SELFCHECK FOR 1ST. YEAR PRE-ENGINEERING
STUDENTS

Exam type questions Time allowed: 1:00hr


Yes No
Name: __________________________________ ___ID: ________________ Section: _____ ADD
Check
Answer the following Questions accordingly.

1. (define) Global variables are ____________________________________________________


Local variables are_____________________________________________________ (1 point)
2. Describe the uses of the following key words in C++ coding. (0.5 point each)
a. main() //______________________________________
b. cin >> //______________________________________
c. return //______________________________________
d. cout<< //______________________________________
e. const //______________________________________
f. #include //______________________________________
3. Identify statements that can generate error message when complied, and rewrite in correct form. (0.5 point
each)
i. int x= y=13; //_____________________________________________
ii. const int x =13; //_____________________________________________
iii. cin>>int x; //_____________________________________________
iv. #define x=13 //_____________________________________________
v. 3=6+y; //_____________________________________________
4. Choose(circle) the best data type to declare a variable that can store the data shown. (0.5 point each)
a. 9.8 ( float, short, double, char)
b. -2345 (int, signed int, float, double)
c. -2.345e13 (singed int, float, double, long int)
5. Write C++ code to output even numbers from 20
up to 100 using for-loop (1.5 point)
1____________________________________
2____________________________________
3____________________________________
Write here

4____________________________________
5____________________________________
6____________________________________
7____________________________________
8____________________________________
9____________________________________
10___________________________________
1|Page
6. W rite a C++ code guided by the following flow chart. (2 point)

1____________________________________

Write here
start 2____________________________________
3____________________________________
4____________________________________
Get n; N=1
5____________________________________
6____________________________________
N *=n ; n-- 7____________________________________
8____________________________________
n>=0 9____________________________________
10___________________________________
Output N 11___________________________________

end

7. Identify the return for relational expression, the result for the arithmetic and logic expressions where a=2,
b=1, c=3 are initialized variables. (0.5 point each)
a. a*= a - - //_______________
b. b+= c% - - a //_______________
c. (!(a>=b))? a: b //________________
8. Rewrite the source code below correcting the syntax where error is found(2 point)
Write here
1 include<iosteram> 1____________________________________
2 Using namespace std; 2____________________________________
3 int main(); 3____________________________________
4 4____________________________________
5 int n1, sum=0; 5____________________________________
6 cout<<"Enter the first number:" 6____________________________________
7 cin >> n1; 7____________________________________
8 Cout<<"Enter the second number:"; 8____________________________________
9 cin>> n2; 9____________________________________
10 sum = n1 + n2 ; 10___________________________________
11 cout << "Sum = " << sum; 11___________________________________
12 12___________________________________
13 return sum ; 13___________________________________
2 | P 14
a g e} 14
3|Page

You might also like