Zadatak 12
Sastaviti algoritam kojim se unosi N brojeva, a zatim stampa njihov zbir.
Algoritam
Zadatak
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n, x, i, zb;
string opseg, broj, zbir;
Console.WriteLine("Unesite opseg:");
opseg = Console.ReadLine();
n = Convert.ToInt32(opseg);
Console.WriteLine("Unesite broj:");
broj = Console.ReadLine();
x = Convert.ToInt32(broj);
i = 1;
zb = x;
while (i < n)
{
Console.WriteLine("Unesite sledeci broj:");
broj = Console.ReadLine();
x = Convert.ToInt32(broj);
zb = zb + x;
i = i + 1;
}
zbir = Convert.ToString(zb);
Console.WriteLine("Zbir je:" + zbir);
Console.ReadKey();
}
}
}