0% found this document useful (0 votes)
11K views

C Program To Convert Character To ASCII and To Find The Sum of Digits of ASCII Value

The document describes a C program that takes a character as input, converts it to its ASCII value, and calculates the sum of the individual digits in the ASCII value. The program prompts the user to enter a character, converts it to ASCII, prints the character and ASCII value, uses a while loop to iterate through the ASCII value digits and add them to a running sum, and finally prints out the total sum. It then provides a link for more programming examples.

Uploaded by

Saiyasodharan
Copyright
© Public Domain
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11K views

C Program To Convert Character To ASCII and To Find The Sum of Digits of ASCII Value

The document describes a C program that takes a character as input, converts it to its ASCII value, and calculates the sum of the individual digits in the ASCII value. The program prompts the user to enter a character, converts it to ASCII, prints the character and ASCII value, uses a while loop to iterate through the ASCII value digits and add them to a running sum, and finally prints out the total sum. It then provides a link for more programming examples.

Uploaded by

Saiyasodharan
Copyright
© Public Domain
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

CONVERSION OF CHARACTER TO ASCII AND SUM OF INDIVIDUAL DIGITS OF THE ASCII VALUE

Program: #include<stdio.h> #include<conio.h> #include<ctype.h> void main() { char ch; int asc; int sum = 0; clrscr(); printf("Enter a character : "); scanf("%c", &ch); asc = toascii(ch); printf("\nThe ASCII value of %c is %d", ch, asc); while (asc > 0) { sum = sum + (asc % 10); asc = asc / 10; } printf("\nThe sum is %d", sum); getch(); } More useful programs @ http://www.gethugames.in/blog/

You might also like