Can't figure out what to use

declare one character variable and read them from user, then Display its next and previous character.
I don't know what to use to make it show the next charchter
1
2
3
4
5
6
7
8
  char cha;

	cout<<"Please enter any charchater from the alphabet" << endl;
	cin>> cha;



	cout<<"The next char for" << cha << "is" <<    << endl;
closed account (48T7M4Gy)
Perhaps use another cin >> ...; statement
You mean like this?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>

using namespace std;

int main()
{
    char cha;

	cout<<"Please enter any charchater from the alphabet" << endl;
	cin>> cha;
	char next = cha+1;
    char previous = cha-1;


	cout<<"The next char for " << cha << " is " << next << " And the previous character is " << previous  << endl;
}
closed account (48T7M4Gy)
declare one character variable and read them from user, then Display its next and previous character


Yeah, I slightly misunderstood the question - story of my life. Your interpretation is correct.

However, it looks like you solved the problem. Well done.
Last edited on
@Arslan7041

Thank you so much, it makes sense now :)
Topic archived. No new replies allowed.