Hi to everyone,
I'm newbie here and in C# also. I'd like to give you congratulations about this forum!
I'd like also to ask you how to insert values in an Array so i can create a dynamic array...
My problem is to make a program to give my grades and return the sum of them!
Source code is provided:
Any help please???
Thanx in advance...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Courses
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Give me the number of courses you have passed:");
String a = Console.ReadLine();
int b = Convert.ToInt16(a);
int sum = 0;
if ((b <= 0) || (b > 20))
{
Console.WriteLine("You gave me wrong number of courses,try again!!!");
}
else
{
int i = 1;
while (i <= b)
{
Console.WriteLine("Give me the grades of your courses,pressing Enter: " + i);
i++;
}
int[] num = new int[20];
for (int j = 1; j < i; j++)
{
string source = Console.ReadLine();
int pin = num[j];
sum = sum + num[j];
}
Console.WriteLine("The suma is: " + sum);
Console.ReadKey();
}
}
}
}