See what questions your friends are asking today.

Write a C program to accept a string from user and display its ascii value and then display sum of all ascii value of strings?

View Slide Show

Close
Answer:

//C program to accept a string from user and
//display its ascii value and
//then display sum of all ascii value of strings

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

int main() {

char String[100];
int Sum,Index;
Sum=0; //Sum is initially zero

printf("Enter the string:\n");
gets(String); //Accept String from User

for(Index=0;Index<strlen(String);Index++)
{
Sum+=(String[Index]); //Adds (the ASCII values of) the String characters.
}

printf("The sum is %d\n",Sum); //Printing it as %d gives the equivalent ASCII value.

return 0;
}

More on: C Programming

Lazy copying is a hybrid of the standard shallow-copy and deep-copy mechanisms. Objects that are copy constructed or assigned from... more »
Matrix multiplication using pointers 1. Why use it? Hi, so I've been looking for this answer myself and because it was not created... more »

Top Questions

Answer"near" and "far" pointers are actually non-standard qualifiers that you'll find...
Answer A near pointer is a 16 bit pointer to an object contained in the current segment,...
The function returns the total number of items successfully read, EOF when the input...

Contributors

«
Hootershooter74
Trust: 176
  • Computers And The Net Supervisor
»

Top Contributors This Week

  • Trust Points: 2720
  • Member Since: 6/07
  • Trust Points: 2925
  • Member Since: 9/07
  • Trust Points: 2945
  • Member Since: 10/10
  • Trust Points: 7738
  • Member Since: 11/08
  • Trust Points: 708
  • Member Since: 1/11