Download presentation

Presentation is loading. Please wait.

Published byGina Mustain Modified over 2 years ago

1
CS 240 Computer Programming 1 Variables 1

2
Question 1 : 2 Which of the following is a correct C++ identifier: SSN1a$total2D_Ds-3_ds

3
Question 2 : 3 Which of the following is correctly formed constant of type integer? ‘8’“9”12,5

4
Question 3 : 4 Declare the following using one statement: int x; int y; int z; char a = ‘i’; char b; char c = ‘E’; int x, y, z ; char a = ‘i’, b, c = ‘E’ ;

5
Question 4 : 5 Write a C++ statement to do the following: a) Declare two variables of type character, each one is in a separate declaration statement. char a ; char b ;

6
Question 4 : 6 Write a C++ statement to do the following: b) Declare two variables of type character and initialize them with the values $and ? respectively in the declaration. NOTE: use one declaration statement. char c = ‘$’, d = ‘?’ ;

7
Question 5: 7 Write the following algebraic expressions as C++ expressions: 2−4 b * 2 – 4 * a * c

8
Question 5: 8 Write the following algebraic expressions as C++ expressions: 2−22 w * l * x * 2 – w * x * 22

9
Question 6: 9 Each of the following assignment statement contains at least one error. Identify them: Delta=x(y+(3x+(z+15))) X=5=y+4

10
Question 7: 10 a. Y= a*x*x*x+7; b. Y=a*x*x*(x+7); c. Y=(a*x) * x*(x+7); d. Y=(a*x)*x*x+7;

11
Question 8: 11 Correct the errors in the following programs: #include ; using namespace std; int main(); { int x; y=2; z= 4; x=y+z; cout<<”x”; //print the integer x } #include using namespace std; int main() { int x, y=2, z=4; x=y+z; cout<

12
Question 8: 12 Correct the errors in the following programs: #include using name space std; int main { char a=”$”; cout >b; cout<**b; cout<
**

13
Question 9: 13 What is the output by each of the following code fragment? int x=1; int main() { int x=3; cout<

14
Question 9: 14 What is the output by each of the following code fragment? int a=1; int b=-3; int c=2; b=a++; c+=--a+b++; cout<

15
Problem 1 15 Question Write a program that asks the user to input 2 numbers A and B, then exchange the values of A and B.

16
Problem 1 16 Answer

17
Problem 1 17 Answer

18
Problem 2 18 Question Write a program that reads in the length and the width of a rectangular yard. Your program should compute the time required (in minutes) to cut the grass at the rate of 2.3 square meters per a second.

19
Problem 2 19 Answer

20
Problem 2 20 Answer

21
Problem 3 21 Question Write a program that asks the user to type the price without tax of one kilogram of tomatoes, the number of kilograms you want to buy and the tax in percent units. The program must calculate the total price including taxes.

22
Problem 3 22 Answer

23
Problem 3 23 Answer

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google