C++ program that accepts a character between A to J and prints next 4 characters.

Q19. Write a C++ program that accepts a character between A to J and prints next 4 characters.

Ans.

#include<iostream.h>

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

void main()

{

char ch;

clrscr();

cout<<“\n Enter a character between A and J: “;

cin>>ch;

cout<<“\n Next four characters are: “;

cout<<“\n “<<(char)(ch+1);

cout<<“\n “<<(char)(ch+2);

cout<<“\n “<<(char)(ch+3);

cout<<“\n “<<(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 *

247 Views
%d bloggers like this: