Question

In C, write a program to convert a char (0-9) to Dec (ASCII value). Then convert an ASCII Value to char

-------+ | ASCII CODE | + - ---+ +-- | char | Dec | ----+ | O => 48 | | 1 => 49 | 2 => 50 | 3 => 51 | | 4 => 52 | |

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <stdio.h>
int main()
{
char aa;
int ba;
   int i;
   int j;
   char bb;
   printf("+------------+\n");
   printf("| ASCII CODE |\n");
   printf("+------------+\n");
   printf("| char | Dec |\n");
   printf("+------------+\n");
   for(i=0,j=48;i<10;i++,j++)
       printf("| '%c' => %d |\n",i+48,j);
   printf("+------------+\n");
scanf("%d",&aa);
int ab;
ab=aa+'0';
printf("The selected character's ASCII code is %d\n",ab);
printf("+------------+\n");
   printf("| ASCII CODE |\n");
   printf("+------------+\n");
   printf("| Dec | char |\n");
   printf("+------------+\n");
   for(i=0,j=48;i<10;i++,j++)
       printf("| %d => '%c' |\n",j,i+48);
   printf("+------------+\n");
scanf("%d",&ba);
bb=ba-48;
printf("The selected character is '%d'",bb);
return 0;
}

OUTPUT:

I ASCII CODE I char i Deci ------------- ܘܝܙܝܬܢܝ ܩܩܗ ܨܢ ܗܩ - --- =y The selected characters ASCII code is 52 I ASCII CODE I

Add a comment
Know the answer?
Add Answer to:
In C, write a program to convert a char (0-9) to Dec (ASCII value). Then convert...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • c# csci312: character counter - vector design a program that reads in an ascii text file...

    c# csci312: character counter - vector design a program that reads in an ascii text file (provided) ... Your question has been answered Let us know if you got a helpful answer. Rate this answer Question: C# CSCI312: Character Counter - Vector Design a program that reads in an ASCII text file (provide... C# CSCI312: Character Counter - Vector Design a program that reads in an ASCII text file (provided) and creates an output file that contains each unique ASCII...

  • West Battery Corp. has recently been receiving complaints from retailers that its​ 9-volt batteries are not...

    West Battery Corp. has recently been receiving complaints from retailers that its​ 9-volt batteries are not lasting as long as other name brands. James​ West, head of the TQM program at​ West's Austin​ plant, believes there is no problem because his batteries have had an average life of 5050 ​hours, about​ 10% longer than​ competitors' models. To raise the lifetime above this level would require a new level of technology not available to West. ​ Nevertheless, he is concerned enough...

  • In this program, you will be using C++ programming constructs, such as overloaded functions. Write a...

    In this program, you will be using C++ programming constructs, such as overloaded functions. Write a program that requests 3 integers from the user and displays the largest one entered. Your program will then request 3 characters from the user and display the largest character entered. If the user enters a non-alphabetic character, your program will display an error message. You must fill in the body of main() to prompt the user for input, and call the overloaded function showBiggest()...

  • Java: can also use “if else” statements Write a program that can convert an integer between...

    Java: can also use “if else” statements Write a program that can convert an integer between 0 and 15 into hex number (including 0 and 15). The user enters an integer from the console and the program displays the corresponding hex number. If the user enters an integer out of range, the program displays a warning message about the invalid input. Table. Conversion between Decimal and Hexadecimal Decimal Hexadecimal 0 0 1 1 2 2 3 3 4 4 5...

  • I'm working on a java program where I'm supposed to convert 4 bit binary into decimal....

    I'm working on a java program where I'm supposed to convert 4 bit binary into decimal. I went with if statements and tried to use an else to print out an error message if the user enters a number that isn't a binary number but it prints no matter what. (so, it prints that it's a vowel and that it's not a vowel) 1 import java.util.Scanner; 2 3 public class HomeworkTwoQ2 4 { 5 6 public static void main(String[] args)...

  • c/c++ Passing arrays as arguments to functions. The main() is given, write the function 'average' (Study...

    c/c++ Passing arrays as arguments to functions. The main() is given, write the function 'average' (Study the syntax of passing an array as a function parameter) The program prompts the user to first enter the number of tests given in a course, and then prompts him/her to enter the mark for each test. The marks are stored in an array. This takes place in the main() function. It then passes the array to a function named 'average' that calculates and...

  • 1. Write a C++ program called Password that handles encrypting a password. 2. The program must...

    1. Write a C++ program called Password that handles encrypting a password. 2. The program must perform encryption as follows: a. main method i. Ask the user for a password. ii. Sends the password to a boolean function called isValidPassword to check validity. 1. Returns true if password is at least 8 characters long 2. Returns false if it is not at least 8 characters long iii. If isValidPassword functions returns false 1. Print the following error message “The password...

  • #49,53,57 3- lar coordinates to polar coordinates will Polar Coordinates Convert blar coordinates with r> 0...

    #49,53,57 3- lar coordinates to polar coordinates will Polar Coordinates Convert blar coordinates with r> 0 and the ove describe of the the rectangular con 050<27. 37. (-1,1) be app 39. (V8, V8) 41. (3.4) 38. (3V3,-3) 40. (-V6, -V2) 42. (1,-2) 44. (0, -V3) your a (a) Yo (b) YO 43. (-6,0) Rectangular Equations to Polar Equations Convert the equation to polar form. 45. x = y *.47. y = x² 49. x = 4 46. x² + y2...

  • java programming Problem 2 (25 points) Counting Character Frequency. Write a program to analyze a text...

    java programming Problem 2 (25 points) Counting Character Frequency. Write a program to analyze a text file (a novel or a report, or just a sequence of letters or symbols), by reading the file into a byte array, convert to a string, and then scan the string letter by letter to count the frequencies of all unique characters in the text, after that, the letters with frequencies greater than 0 and the frequencies are reported side by side. All members...

  • I need it in JAVA Write a program that randomly populates an array of size 100,...

    I need it in JAVA Write a program that randomly populates an array of size 100, sorts it, and then finds the median. The random numbers must be from 0-99 and all integer values. Also since there is an even set of numbers the median is found by taking the mean of the two middle numbers (In other words the 50th and 51st). You have to code your own sorting method. You may not use a built in java sorter....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT