mam pytanie czemu nie mogę zastosować esle if w kodzie. Chodzi o moment, w którym chciałem zastosować else if i visual 2013 podkreśla to na czerwono(2 errors: Invalid expression term 'else', ;expected)
Kod: Zaznacz cały
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
int i, j, a, b, jeden=1, dwa=1;
Console.Write("Podaj wartosc liczby a:");
a = Convert.ToInt32(Console.ReadLine());
Console.Write("Podaj wartosc potegi b:");
b = Convert.ToInt32(Console.ReadLine());
if (a== 2)
for (i=1;i<=b;i++)
jeden *= 2;
Console.WriteLine("{0}^{1}={2}",b, a, jeden);
else if (a == 3)
for (j = 1; j <= b; j++)
dwa *= 3;
Console.WriteLine("{0}^{1}={2}", b, a, dwa);
Console.ReadKey(true);
}
}
}