Thursday 2 August 2018

Ascii Name

QUESTION DESCRIPTION


Write a program which reads your name from the keyboard and outputs a list of ASCII codes, which represent your name

TEST CASE 1

INPUT

SRMUNIVERSITY

OUTPUT

The ASCII values of the string are:
83 82 77 85 78 86 69 82 83 73 84 89

EXPLANATION :

This is a simple question expecting you to convert the characters to their respective ASCII representation. That can be easily done by parsing each character to their respective integer representation.


ALGORITHM :

This is a simple algorithm:

Steps :
  • Create a char array to receive the string as input
  • Take the string as input
  • Print the first mandatory line "The ASCII values of the string are:
  • Use a for loop till you find the '\0' character (Why \0)
  • For each character in the string:
    •  Convert it to its integer version and print it with a Space " ".
  • When the '\0' character is found Exit the code.

Remember the spacing in the output and the end of line


SOLUTION :  (Please use this as reference only)


Link to Code : Ascii Name
(Please Try To Refrain From Copying The Code)

No comments:

Post a Comment