- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Find the ASCII value of the uppercase character ‘A’ using implicit conversion in C language?
Implicit type conversion is done by the compiler by converting smaller data type into a larger data type.
For example, ASCII value of A=65.
In this program, we are giving character ‘A’ as input, now write a code to convert A to 65 which is its ASCII value.
Example
Following is the example to find ASCII value of uppercase character ‘A’ using implicit conversion −
#include<stdio.h> int main(){ char character = 'A'; int number = 0, value; value = character + number; //implicit conversion printf("The ASCII value of A is: %d
",value); return 0; }
Output
The ASCII value of ‘A’ is 65. Using typecasting in C, the compiler automatically converts the character of char data type into the integer data type and the expression(value = character + number) becomes equal to 65 + 0 = 65
Therefore, the output would be 65.
The ASCII value of A is: 65
Example
Let us consider example by taking another character and see what is the ASCII value of that character.
#include<stdio.h> int main(){ char character = 'P'; int number = 0, value; value = character + number; //implicit conversion printf("The ASCII value of P is: %d
",value); return 0; }
Output
The ASCII value of ‘P’ is 80. Using typecasting in C, the compiler automatically converts the character of char data type into the integer data type and the expression (value = character + number) becomes equal to 80 + 0 = 80
Therefore, the output would be 80.
The ASCII value of P is: 80