

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Assigning multiple characters in an int in C language
The character type data is stored by its ASCII value internally in C or C++. If we want to print a single character as integer, we will get the ASCII value. But when we are trying to print more than one character using a single quote, then it will print some strange output.
Please check the following program to get the idea.
Example
#include <stdio.h> int main() { printf("%d\n", 'A'); printf("%d\n", 'AA'); printf("%d\n", 'ABC'); }
Output
65 16705 4276803
The ASCII of A is 65. So at first it is showing 65 (01000001). Now for AA, it is showing 16705. This is ASCII of 6565 (01000001 01000001) = 16705. For third the value is ABC (01000001 01000010 01000011) = 4276803.
- Related Questions & Answers
- Assigning an integer to float and comparison in C/C++
- Adding characters in values for an existing int column in MySQL?
- String replace multiple characters with an asterisk in JavaScript
- Most Profit Assigning Work in C++
- What are reading and writing characters in C language?
- Convert an int to ASCII character in C/C++
- Assigning arrays in Java.
- Difference between const int*, const int * const, and int const * in C/C++?
- What is an identifier in C language?
- What is an anagram in C language?
- How to convert an int to string in C++?
- Difference between const int*, const int * const, and int const * in C
- How to find the size of an int[] in C/C++?
- What is an inline function in C language?
- Inserting elements in an array using C Language
Advertisements