C program that accepts a character between a to j and prints next 4 characters.

Q38. Write a C program that accepts a character between a to j and prints next 4 characters.

Ans.

#include<stdio.h>

#include<conio.h>   //for clrscr()

void main()

{

char ch;

clrscr();

printf(“\n Enter a character between A and J: “);

scanf(“%c”,&ch);

printf(“\n Next four characters are: “);

printf(“\n %c”,(char)(ch+1));

printf(“\n %c”,(char)(ch+2));

printf(“\n %c”,(char)(ch+3));

printf(“\n %c”,(char)(ch+4));

}

 

Output

Enter a character between A and J: D

Next four characters are:

E

F

G

H

Leave a Reply

Your email address will not be published. Required fields are marked *

140 Views
%d bloggers like this: