Monday, June 18, 2012

To accept a character and print it for the desired number of times


/* To accepts a character and prints it for the desired number of times */

#include<stdio.h>

#include<conio.h>

void main()

{

  char ch;

  int times,i;

  clrscr();

  printf("\nEnter any character: ");

  scanf("%c",&ch);

  printf("\nHow many times you want to print it? ");

  scanf("%d",&times);

  i=1;

  printf("\n\n");

  while(i<=times)

  {

    printf("%c",ch);

    i=i+1;

  }

  getch();

}

 

 

OUTPUT

 

Enter any character: $

 

How many times you want to print it? 25

 

$$$$$$$$$$$$$$$$$$$$$$$$$

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.