C PROGRAMMING PROGRAM • BASICS & INPUT/OUTPUT
Find the ASCII Value of a Character
Learn how to find the ascii value of a character using a clear C program.
PROBLEM UNDERSTANDING
Input and expected output
Sample input
A
Sample output
ASCII value of A = 65
COMPLETE C PROGRAM
Complete C implementation
#include <stdio.h>
int main(void)
{
char character;
printf("Enter a character: ");
scanf(" %c", &character);
printf("ASCII value of %c = %d\n", character, character);
return 0;
}CURRENT STEP
SELECTED LINE
EXPECTED OUTPUT FOR THE SAMPLE
ASCII value of A = 65
Step 0 of 0
PROGRAM EXPLANATION
Algorithm and explanation
- Read the required input values.
- Print a character with the integer format specifier to reveal its numeric character code.
- Display the computed result.
Print a character with the integer format specifier to reveal its numeric character code.
EFFICIENCY
Time and space complexity
Time complexity
O(1)
Auxiliary space
O(1)
DEBUGGING CHECKLIST
Common mistakes
Check this
Use the correct format specifier for every variable.
Check this
Initialize variables before using their values.
Check this
Check braces, semicolons and input order carefully.
Try it yourself
Practice: Run the program with the sample input, predict its output, and then test one boundary case of your own.
