‹ Back to the paper
A linked list is formed from the objects of the class Cell. The class structure of the Cell is…
A linked list is formed from the objects of the class Cell. The class structure of the Cell is given below:
class Cell
{
char m;
Cell right;
}Write an Algorithm OR a Method to print the sum of the ASCII values of the lower case alphabets present in the linked list.
The method declaration is as follows:void lowercase(Cell str)Answer
Answer
AIvoid lowercase(Cell str)
{
int sum = 0;
Cell temp = str;
while (temp != null)
{
if (temp.m >= 'a' && temp.m <= 'z')
sum = sum + (int) temp.m;
temp = temp.right;
}
System.out.println("Sum of ASCII values of lowercase letters = " + sum);
}The method traverses the linked list from the given node str to the end (right==null), adds the ASCII value of every lower-case character found (checked with the range 'a' to 'z') to sum, and finally prints the total.From ISC 2025 Computer Science Paper 1, question 11(i).