Advertisement
Dianov

Data Types and Variables - Exercise (04. Sum of Chars)

Aug 7th, 2021
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.46 KB | None | 0 0
  1. using System;
  2.  
  3. namespace SumOfChars
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int numberOfChars = int.Parse(Console.ReadLine());
  10.             int sum = 0;
  11.  
  12.             for (int i = 0; i < numberOfChars; i++)
  13.             {
  14.                 char symbol = char.Parse(Console.ReadLine());
  15.                 sum += (int)symbol;
  16.             }
  17.             Console.WriteLine($"The sum equals: {sum}");
  18.         }
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement