C Programming – HackerRank Solution | C IS CASE SENSITIVE |

(HackerRank) Write a Modular C Programming code to solve C IS CASE SENSITIVE, ASCII value of each character present in a string.Write a UDF to read a string

Rajesh was working on c programs. He was curious about knowing the feature of c programming which says : C programming language is case sensitive.

Astonished to know the case-sensitive feature of C language, Rajesh thought to print the ASCII value of each character of a string.

MODULAR TASK:

  1. Write a UDF to read a string.
  2. Write a UDF to display every character of string along with its ASCII value.

Input Format

Input a string

Output Format

ASCII value of each character present in a string.

Sample Input 0

value.

Sample Output 0

ASCII values:
v = 118
a = 97
l = 108
u = 117
e = 101
. = 46

Sample Input 1

Popular,

Sample Output 1

ASCII values:
P = 80
o = 111
p = 112
u = 117
l = 108
a = 97
r = 114
, = 44

Refer : C Programming HackerRank all solutions for Loops | Arrays | strings | Data Structures | Linked lists | Stacks | Queues | Binary Trees

 

CODE:

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int main() {
    char word[20];
    int i=0;
    scanf("%s",word);
    printf("ASCII values:\n");
    while(word[i]!='\0')
    {
        printf("%c = %d\n",word[i],word[i]);
        i++;
    }

    
    return 0;
}

OUTPUT

Congratulations, you passed the sample test case.

Click the Submit Code button to run your code against all the test cases.

Input (stdin)

value.
Your Output (stdout)

ASCII values:
v = 118
a = 97
l = 108
u = 117
e = 101
. = 46
Expected Output

ASCII values:
v = 118
a = 97
l = 108
u = 117
e = 101
. = 46

 

Please find some more codes of Loops, Condition Statements, 1D Arrays, 2D Arrays, Strings, Pointers, Data Structures, Files, Linked lists, Stacks, Queues, Binary Trees, MISC, Solved model question papers & Hacker Rank all solutions on the below page:

Top 100+ C Programming codes – KLE Technological University

Leave a Comment

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

Welcome to FactsPrime

Sorry, We have detected that you have activated Ad-Blocker. Please Consider supporting us by disabling your Ad Blocker, It helps us in maintaining this website. To View the content, Please disable adblocker and refresh the page.

Thank You !!!