119k views
2 votes
How can I write an assignment statement that stores the character 'X' in a variable ch?

User Daniel Sp
by
8.8k points

1 Answer

6 votes

Answer:

In C++ we can assign a character to the variable by using the below statement.

ch='X';

Step-by-step explanation:

The complete program for assigning a character to the variable is given as

#include<iostream>

#include <conio.h>

using namespace std;

main()

{

char ch;

ch= 'X';

cout<<"output of variable Ch ="<<ch;

getch();

}

In above program Char is the data type used for character type variables. ch= 'X' stores X in ch. Then output will shown through cout.

User Hasayakey
by
9.1k points

No related questions found

Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.