Tutorial_2 - cout<<"Their product is"<<(m n<< endl cout<<"Their quotient is"<<(m n<< endl

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
1. What is the output from the following program. Explain if needed. #include <iostream> using namespace std; int main( ) { // cout << "Hello, World.\n"; } 2.   Write four different C++ statements that each subtract 1 from the integer variable x. 3. In each of the following, assume that x has the value 5 and y has the value 2 before the statement executes. What is the value of m and n after the statement executes? the following: a. x *= y++; b. x += --y; 4. How do the following two statements differ? Explain if needed. char ch = 'B'; char ch = 66; 5. Write a program that prints the sum, difference, product, quotient, and remainder of two integers. Initialize the integers with the values 60 and 7. #include <iostream> using namespace std; // Prints sum, difference, product, and quotient of given integers: int main () { int m = 50, n = 10; cout << "The integers are " <<m << n << endl; cout << "Their sum is" << (m + n) << endl; cout << "Their difference is " << (m - n) << endl;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cout << "Their product is " << (m * n) << endl; cout << "Their quotient is " << (m / n) << endl; cout << "Their remainder is " << (m % n) << endl; return 0; } 6. Write a program that prints the ASCII codes for upper case and lower case vowels. E.g A = 65 7. Write a program that converts inches to centimeters. For example, if the user enters 23.7 for a length in inches, the output would be 60.98 cm . (One inch equals 2.54 centimeters.) 8. Identify the error in the following code. And correct it if needed. a. cin << count; b. if x < y min = x else min = y; c. cout << "Enter n: "; cin >> n; if (n < 0) cout << "That is negative. Try again." << endl; cin >> n; else cout << "o.k. n = " << n << endl; 9. Write a single C++ statement that prints "Exceeds " if the variable count exceeds 200. 10. Write a program that finds the minimum of four input integers. Enter four integers 22 33 56 89 The minimum value is 22...
View Full Document

This note was uploaded on 01/15/2012 for the course BIOINFO, B SHES1202 taught by Professor Idonotknow during the Spring '11 term at University of Malaya.

Page1 / 2

Tutorial_2 - cout<<"Their product is"<<(m n<< endl cout<<"Their quotient is"<<(m n<< endl

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online