C++ program to print ASCII code for given digit and backspace.
Q28. Write a program to
- print ASCII code for a given digit.
- print ASCII code for backspace.
(Hint: Store escape sequence for backspace in an integer variable).
Ans(i).
#include<iostream.h>
#include<conio.h> //for clrscr()
//Main Function
void main()
{
int num;
clrscr(); //for clear screen
cout<<“\n Enter a digit you want to print the ASCII value of: “;
cin>>num;
cout<<“\n The ASCII value of given number is: “<<(char)num;
getch(); //To hold the output screen
}
//End of main()
Output:
Enter a digit you want to print the ASCII value of: 97
The ASCII value of given number is: a
Ans(ii).
#include<iostream.h> //for standard input and output
#include<conio.h> //for clrscr()
//Main Function
void main()
{
char num;
clrscr(); //for clear screen
num=’\b’;
cout<<“\n The ASCII value of backspace is: “<<(int)num;
getch(); //To hold the output screen
}
//End of main()
Output:
The ASCII value of backspace is: 8