BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan

BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan (http://bzupages.com/)
-   Object Oriented Programming (http://bzupages.com/300-object-oriented-programming/)
-   -   Program to enter a character and output its ASCII code (http://bzupages.com/f300/program-enter-character-output-its-ascii-code-14665/)

bonfire 09-03-2011 12:14 AM

Program to enter a character and output its ASCII code
 
1 Attachment(s)
Program to enter a character and output its ASCII code


#include
#include

void main()
{
clrscr();
char charac;
cout << "Enter the character : " << endl;
cin>>charac;
int num1=charac;
cout << "The ASCII code for " << charac << " is " << num1 << "." << endl;
getch();
}
This program takes in any character charac as a screen input from the user.
It then finds out its ASCII code and outputs it using the 'cout' command.

Sample Input

a
Sample Output
The ASCII code for a is 97.


All times are GMT +5. The time now is 04:02 PM.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.