answersLogoWhite

0


Best Answer

Although character data types such as char are intrinsically numeric, whenever you print a char you automatically print the symbol associated with the character code (the char's value), never the code. In order to print the code you must cast the character to a numeric data type, such as int.

char c = 'A'; // ASCII value 65 decimal (0x41)

std::cout << static_cast<int>(c); // puts the value 65 on std::cout

User Avatar

Wiki User

9y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

10y ago

#include<iostream>

int main()

{

for(int i=0; i<256; ++i)

std::cout<<i<<" = "<<(char) i<<std::endl;

return(0);

}

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the C plus plus code to print all ASCII codes and the equivalent characters?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How to print a symbol in Java using the ASCII value?

In order to print a character using its ASCII value, you need to first assign it to a char value like this: char c = (char) 65; In this example, we are casting the int 65 to a char, which converts it to an 'A', since 65 is the ASCII value for the capital letter 'a'. Next, you can print it out if you want: System.out.println(c); That's pretty much all there is to it!


WAP in java to take alphabet and print ascii value for it?

Remember that chars in Java are just a special version of ints. Cast the char as an int and you get the Unicode value for it. Fortunately, the group of characters including letters and numbers have the same value in both encoding systems. for (char letter = 'a'; letter &lt;= 'z'; ++letter) { System.out.println("ASCII of " + letter + " = " + (int) letter); }


How do you Print all the first characters in the string in python programming?

Let's say your string is a variable called "string" To print out all the characters in order, you would do: for i in string: print(string[i]) If you wanted to print out characters up to a point (n = maximum characters): for i in range(n): print(string[i]) hope this helps!


How do you assign or print special symbols in c plus plus?

UTF-16 strings or characters (std::wstring or wchar_t) are the best method of assigning and printing special symbols. UTF-8 encoding using std::string can be used to minimise memory consumption but still requires conversion to wide-string for printing purposes. However, if the symbols are within the range of extended ASCII character codes (0x00 to 0xff), then an unsigned char or std::string is all you really need.


Why you use printf in c programs not only print?

That is short for "print formatted"; it lets you include format codes to control the output.

Related questions

Can dot matrix printer print graphics yes or no?

Technically yes, it depends on the driver controlling the device and if the device can take in custom symbols instead of ascii codes. An Epson LX-800 for instance can print graphics just fine!


How to print a symbol in Java using the ASCII value?

In order to print a character using its ASCII value, you need to first assign it to a char value like this: char c = (char) 65; In this example, we are casting the int 65 to a char, which converts it to an 'A', since 65 is the ASCII value for the capital letter 'a'. Next, you can print it out if you want: System.out.println(c); That's pretty much all there is to it!


Converting lower to upper case in C programming?

I believe characters have a toUpper() function. For example: char x = 'a'; printf("%c\n", x.toUpper()); // This should print "A" You could also add or subtract using ascii values - remember, a char is pretty much an integer, just displayed differently. For example: printf("Character %c = decimal %d\n", x, x); will display your character and its ascii integer equivalent.


How you can store an image in C plus plus console project?

You can't embed a "real" picture into a console project, like a .JPEG or .PNG format picture. What you can do though, is convert the picture to ASCII characters and print the text to the screen.


WAP in java to take alphabet and print ascii value for it?

Remember that chars in Java are just a special version of ints. Cast the char as an int and you get the Unicode value for it. Fortunately, the group of characters including letters and numbers have the same value in both encoding systems. for (char letter = 'a'; letter &lt;= 'z'; ++letter) { System.out.println("ASCII of " + letter + " = " + (int) letter); }


How do you Print all the first characters in the string in python programming?

Let's say your string is a variable called "string" To print out all the characters in order, you would do: for i in string: print(string[i]) If you wanted to print out characters up to a point (n = maximum characters): for i in range(n): print(string[i]) hope this helps!


Do line break characters print on the page as a thin horizontal line?

false, line break characters do not print.


How do you print wccf codes?

you just go to msn and type wccf codes and choose a player to print


Special characters that appear on screen but do not print?

They are hidden known as the special or hidden characters. It is actually possible to print them, though by default they don't print.


Write a program to print all the ascii values and the corresponding representation?

int main (void) { int i; for (i=32; i&lt;=127; ++i) printf ("%3d: '%c'\n", i, i); }


What are visual codes in media?

visual codes are the things that stand out on print adverts for example, language, colours and imgaes.


How do you assign or print special symbols in c plus plus?

UTF-16 strings or characters (std::wstring or wchar_t) are the best method of assigning and printing special symbols. UTF-8 encoding using std::string can be used to minimise memory consumption but still requires conversion to wide-string for printing purposes. However, if the symbols are within the range of extended ASCII character codes (0x00 to 0xff), then an unsigned char or std::string is all you really need.