Programming II written individual assignment 2 mark out of 15%
Last submition date next class
Give answer based on the given instruction
1. Indicate which of the following is the function prototype, the function header, and
the function call:
a. void showNum(double num) _______________________________
b. void showNum(double); ______________________________
c. showNum(45.67); ________________________________
2. What will the output of the following program be if the user enters 10
#include <iostream> cout << "Enter a number: ";
using namespace std; cin >> input;
void func1() if (input < 10)
{ {
cout << "Able was I\n"; func1();
} func2();
void func2() }
{ else
cout << "I saw Elba\n"; {
} func2();
int main() func1();
{ }
int input; }
3. What is the output of the following program?
#include <iostream> cout << “x= “<<x<< " " << “y=” <<y<< endl;
using namespace std; }
void func1(double , int ); void func1(double a, int b)
int main() {
{ cout << “a=” <<a<< " " <<” b=” <<b<< endl;
int x = 10; a =11.9;
double y = 11.5; b = 107;
cout << “x=” <<x<< " " <<” y=” << y<<endl; cout << “a=” <<a<< " " <<” b=” <<b<< endl;
func1(x, y); }
4. Write a function, named fiveTime, that accepts an integer argument. When the function is called, it
should display the product of its argument multiplied times 5.
5. Write a function named factorial of integer return type which accepts integer argument. The function
prompts the user to enter integer & calculate & display the factorial of the number.
6. Write a function named dailytem, which accept the daily temperature of welkite as an integer
argument. The function should prompt the user to enter the daily temperature of welkite and the
function decides whether the daily temperature of the welkite as cold, moderat , hot or unexpected
weather based on the daily temperature range given below.
1oc - 15oc cold
16oc - 21oc moderate
22oc - 40oc hot
<1oc & >40oc unexpected