Monday 8 February 2016

Write a C++ program that uses three user-defined functions (counting main() as one) and produces the following output

Leave a Comment
Questions:

Write a C++ program that uses three user-defined functions (counting main() as one) and produces the following output:

Three blind mice
Three blind mice
See how they run
See how they run

One function, called two times, should produce the first two lines, and the remaining function, also called twice, should produce the remaining output.

Explanation:

In this problem as mentioned in question there are some function which is being created as firstFunc and secondFunc. In these functions there is just single cout statement .  Below mention code is compiled in Visual Studio 2015 and output snap is attached.. If any problem you feel and want explanation feel free to contact.

Code:

/**************************************************|
/*************C++ Programs And Projects************|
***************************************************/


#include<iostream>
using namespace std;

//function prototypes
void firstFunc();
void secondFunc();

//main Functions
void main() {
       firstFunc();
       firstFunc();
       secondFunc();
       secondFunc();
}

//functions definations
void firstFunc() {
       cout << "Three blind mice" << endl;
}
void secondFunc() {
       cout << "See how they run" << endl;
}


Output:


Related Articles:

C++ Books Solution

If You Enjoyed This, Take 5 Seconds To Share It

0 Questions: