हिंदी

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 - Computer Science (Theory)

Advertisements
Advertisements

प्रश्न

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)

दीर्घउत्तर
Advertisements

उत्तर

Algorithm to find the sum of ASCII values of lowercase letters in a linked list

  1. Begin from the head node of the linked list.
  2. Set a variable sum to 0.
  3. Repeat the following steps until the current node becomes null:
    1. Check whether the character stored in the current node lies between 'a' and 'z'.
    2. If it is a lowercase letter, add its ASCII value to sum.
    3. Move the pointer to the next node in the list.
  4. Once the traversal is complete, display the value of sum.
shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
2024-2025 (March) Official Board
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×