Define the function hash_code, which returns the hash code of a string.

   (hash_code ("Abc") = ASCII(A) + ASCII(b) + ASCII(c) = 65 + 98+ 99 = 262 )


Difficulty level
This exercise is mostly suitable for students
#include<stdio.h>
#include<conio.h>
#define SIZE 20

int hash_code(char word[SIZE])
{
	int i=0, sum=0;
	while (word[i])
	{
		sum += word[i];
		i++;
	}
	return sum;
}

void main()
{
	char word[SIZE];

	printf("enter a word: ");
	scanf("%s", word);
	printf("Hash code of %s = %d\n", word, hash_code(word));

	getch();
}


Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Binary tree mirrors check