Passing Argument To The Function Simple Program C++ - HelpMeOutAlways

Wednesday, October 17, 2018

Passing Argument To The Function Simple Program C++

//Source Code

 #include<iostream>
#include<string>
using namespace std;
class fanct{
    public:
        void repchar(string ch, int n){
            for(int j=0; j<n;j++){
                cout<<ch;
                cout<<endl;
            }
        }
};
int main(){
    fanct call;
    call.repchar("Johny Singh",10);
    return 0;
}

 

 

Output

Description:

In this program we are just passing argument to the function. we are just taking two types of data type one String and other Integer type data. we have a loop which will print the string data type until what we have pass the value of integer in the main function by passing argument through function calling.

No comments:

@way2themes