Code Snippets C/C++ Code Snippets

C++ program to print ASCII value of a character.

By: IncludeHelp, On 11 OCT 2016

In this program we will learn how to print ASCII value of a character?

In this program there is a character type variable x which has "A", we can print the ASCII value of "A" by converting the type of value x.

C++ program (Code Snippet) - Get ASCII of a Character

Let’s consider the following example:

/*C++ program to print ASCII value of a character*/

#include<iostream>

using namespace std;

int main(){
	char x;
	x='A';
	
	cout<<"ASCII value of "<<x<<" is "<<(int)x<<endl;
	
	return 0;
}

Output

    ASCII value of A is 65




Copyright © 2024 www.includehelp.com. All rights reserved.