View Single Post
  #1  
Old 09-03-2011, 12:14 AM
bonfire's Avatar
bonfire bonfire is offline
M.Arsalan Qureshi

 
Join Date: Oct 2008
Location: Garden Town, Multan Cantt
Posts: 616
Program / Discipline: BSTS
Class Roll Number: 09-31
bonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond repute
Default Program to enter a character and output its ASCII code

Program to enter a character and output its ASCII code


#include <iostream.h>
#include <conio.h>

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.

__________________

Reply With Quote