C program to print ASCII code for given digit and backspace.
Q49. Write a C 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<stdio.h> //for standard input and output
#include<conio.h> //for clrscr()
//Main Function
void main()
{
int num;
clrscr(); //for clear screen
printf(“\n Enter a digit you want to print the ASCII value of: “);
scanf(“%d”,&num);
printf(“\n The ASCII value of given number is: %c”,(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<stdio.h> //for standard input and output
#include<conio.h> //for clrscr()
//Main Function
void main()
{
char num;
clrscr(); //for clear screen
num=’\b’;
printf(“\n The ASCII value of backspace is: %d”,(int)num);
getch(); //To hold the output screen
}
//End of main()
Output:
The ASCII value of backspace is: 8