C++ : Write a program to print line of n character of user given character.


#include<iostream>
#include<conio.h>

using namespace std;

void display(char ch,int n);

int main()
{
int n;
char ch;
cout<<"Enter any character : ";cin>>ch;
cout<<"Enter the number of character '"<<ch<<"' to display : ";cin>>n;
display(ch,n);
getch();
return(0);
}

void display(char ch,int n)
{
for(int i=1;i<=n;i++)
{
cout<<ch;
}
}

No comments:

Post a Comment