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

Wednesday, October 17, 2018

Passing Variables To The Function Simple C++ Program

Source Code

#include<iostream>

using namespace std;

void repchar(char,int);

int main(){

char chin;

int nin;

cout<<"Enter a charachter:"<<endl;

cin>>chin;

cout<<"Enter Number Of Times To Repeat It:"<<endl;

cin>>nin;

repchar(chin,nin);

    return 0;

}

void repchar(char ch, int n){

    for(int j=0;j<n;j++)

    {

        cout<<ch;

        cout<<endl;

    }

}

Output

c++ simple program

Description

In this program, we are just getting input from the user and and passing the values by variable names which we have just declared and defined in the function.


No comments:

@way2themes