Tutorial_5 - returns the character itself For example...

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

View Full Document Right Arrow Icon
Show the printout of the following code and understand it: a. #include <iostream> using namespace std; void xFunction(int i) { int num = 1; for (int j = 1; j <= i; j++) { cout << num << " "; num *= 3; } cout << endl; } int main() { int i = 1; while (i <= 5) { xFunction(i); i++; } return 0; } b. #include <iostream> using namespace std; void xFunction(int i) { do { if (i % 2 != 0) cout << i << " "; i--; } while (i >= 1); cout << endl; } int main() { int i = 1; while (i <= 5) { xFunction(i); i++; } cout << "i is " << i; return 0; }
Background image of page 1

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

View Full DocumentRight Arrow Icon
1. Write a function that converts an uppercase letter to lowercase. Use the following function header: char toLowerCase( char ch) If the character is not an uppercase letter, the method simply
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: returns the character itself. For example, toLowerCase('B') returns b and toLowerCase('5') returns 5 . See Exercise 2.7 on how to convert an uppercase letter to lowercase. Write a test program that prompts the user to enter a character, invokes the function, and displays its return value. <Output> Enter a char: A a <End Output> <Output> Enter a char: 3 3 <End Output> 2. Write a function to compute the following series: 1 ... 3 2 2 1 ) ( + + + + = i i i m Write a test program that displays the following table: i m(i) 1 0.5 2 1.1667 ... 19 16.4023 20 17.3546...
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_5 - returns the character itself For example...

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