Exercise 01

Page 1 of 2

1. What is the difference between an integral variable and a floating-point variable? 2. What are the differences between an unsigned short int and a long int? 3. What would be the correct variable type in which to store the following information? a. Your age. b. The area of your backyard. c. The number of stars in the galaxy. d. The average rainfall for the month of January. 4. What happens if I assign a number with a decimal point to an integer rather than to a float? Consider the following line of code: int number = 5.4; 5. What happens if you assign a negative number to an unsigned variable? Consider the following line of code: unsigned int Number = 1; 6. Re-write the C++ codes for each of the following statements. a. n = 100 + (m++); b. n = 100 + (++m); Keep in mind that, the codes should have the same effect as the each statement. [No need to write the complete source code.] 7. a, b, c – are three variables. Write a single statement in C++ which subtract the sum of a and b from c, then increase b by 1. 8. Write a program that prints the block letter ‘G’ in a 7 X 6 grid of star as follows: * * * * * * * * *

* * * * * * * *

* *

9. Write a program that prints the first letter of your last name as a block letter in a 9 X 9 grid of star. 10. Write a program that prints the sum, difference, product, quotient and remainder of two integers. Initialize the integers with the values 50 and 9 within the source code. 11. Write a program that prints the sum, difference, product, quotient and remainder of two integers. The program will ask for the two integers from the user. 12. Write a program that asks the user to type the width and the length of a rectangle and then outputs to the screen the area and the perimeter of that rectangle. 13. Write a program that asks the user to type 2 integers A and B as input and exchange the value of A and B in output. 2007© www.maq.spyw.com

Exercise 01

Page 2 of 2

13. Write a program that asks the user to type the price without tax of one kilogram of apples, the number of kilograms you want to buy and the tax in percent units. The program must write the total price including taxes. 14. Write a program that asks the user to type the geometric coordinate of 2 points, such as A and B (in a plane), and then writes the distance between A and B. [Hints: use ‘cmath’ or ‘math.h’ for square root function] 15. Write a program that converts centimeters to inches. [Hints: 1 cm = .393 inch.] 16. Write a program that convert any temperature from Celsius scale to Fahrenheit scale. [Hints: relation between Celsius and Fahrenheit is 5F = 9C + 32; where F is Fahrenheit and C is Celsius.] 17. Write a program for solving quadratic equations. As an example: find the values of x in the 2nd degree equation of ax2+bx+c=0. Solution of x can be found in the following format. x = -(b/2) ± [{√(b2 – 4ac)}/2]. [Hints: use ‘cmath’ or ‘math.h’ for power and square root function] 18. The acceleration of a sleigh sliding down a hill is a = g sin α , where α is the slope of the hill and the gravity acceleration g = 9.8 ms-2. Write a source code in C++ that calculates the acceleration as a function of the slope in degrees. [Hints: use ‘cmath’ or ‘math.h’ for sine function]

2007© www.maq.spyw.com

1. What is the difference between an integral variable ...

What happens if I assign a number with a decimal point to an integer rather than to a float? Consider the following line of code: int number = 5.4;. 5. What happens if ... Write a program that convert any temperature from Celsius scale to Fahrenheit scale. [Hints: relation between Celsius and Fahrenheit is 5F = 9C + 32; where ...

97KB Sizes 0 Downloads 126 Views

Recommend Documents

what is the difference between organizational culture ...
My thanks to Geert Hofstede and his colleagues and students at Rijksuniversiteit Limburg ..... tion, both perspectives attempt to address the problem of social contexts .... (Cummings, 1965), safety (Zohar, 1980), or service (Bowen & Schneider, 1988)

What is the Difference Between Internet & Digital Marketing - digital ...
What is the Difference Between Internet & Digital Market ... words training institute in hyderabad _ Digital nest.pdf. What is the Difference Between Internet ...

what is the difference between data and information pdf
what is the difference between data and information pdf. what is the difference between data and information pdf. Open. Extract. Open with. Sign In. Main menu.

1.What is
C.R.M.Hurd. D.E.W.Burgess. Ans:A. 73.The concept 'Umland'means: ... Viticulture meant for: A.Lemon cultivation. B.Apple cultivation. C.Orange cultivation.

1. What is Economics - NIOS
So economics is treated as the science of growth and development.In fact, it is true that now a days people talk about ... of natural environment. Hence economics is also treated as science of Sustainable Development. .... (ii) The government should

L4-1 What is an Orchestra.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. L4-1 What is an ...

1. What is an operating system? 2. What are the ... -
Explain the concept of the multi-processor systems or parallel systems? .... In Symmetric multi processing each processor run an identical copy of the OS, and.

Download The 10X Rule: The Only Difference Between ...
Success and Failure Full Online ... degrees of action-no action, retreat, or normal action-if you re after big goals, you don t want to settle for the ordinary. To reach ...

Difference Between homogeneous distributed database and ...
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Difference Between homogeneous distributed database and heterogeneous distributed database.pdf. Difference B