C Program - Write a function, which accepts a character and integer n as parameter and displays the next n characters


Program

#include <stdio.h>
int display(char);
int main()
{
char ch,c;
printf("Enter character:");
scanf("%c", &ch);
display(ch);
}
int display(char ch)
{
int n,i;
printf("how many next char:");
scanf("%d",&n);
printf("\nYou entered:\t%c\n", ch);
printf("Next character :");
for(i=0;i<n;i++)
{
ch=ch+1;
   printf("\t%c", ch);
}
return 0;
}

Output:

Enter character:r
how many next char:5

You entered:    r
Next character :        s       t       u       v       w

Post a Comment

0 Comments