Q:

Write an application named SumFiveInts that allows the user to enter five integers and displays their sum

0

Write an application named SumFiveInts that allows the user to enter five integers and displays their sum.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;

namespace _1_SumFiveInts
{
    class SumFiveInts
    {
        static void Main(string[] args)
        {
            WriteLine("SumFiveInts");
            int itr = 0;
            const int COUNT = 5;
            int sum = 0;
            while (itr < COUNT)
            {
                Write("Enter number {0}/{1}:", itr + 1, COUNT);
                sum += int.Parse(ReadLine());
                itr++;
            }
            WriteLine("Sum:{0}", sum);

            WriteLine("--End--");
        }
    }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now