Q:- Write table of 2 using for loop in C# ???
Ans:- using System;
using System.Collections.Generic;
using System.Text;
namespace codeforevenorodd
{
class Program
{
static void Main(string[] args)
{
for(int i=1;i<11;i++)
{
int num=2*i;
Console.WriteLine(num);
}
Console.ReadLine();
}
}
}
using System;
ReplyDeleteusing System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp63
{
class Program
{
static void Main(string[] args)
{
int a, b, c, d;
Console.Write("enter a value \t");
a = Convert.ToInt32(Console.ReadLine());
Console.Write("enter b value \t");
b = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("\nYour required table is as under.\n\n--------------------------------\n");
for (d = 1; d <= b; d++)
{
c = a * d;
Console.WriteLine("{0} * {1} = {2} \n", a, d, c);
}
Console.ReadLine();
}
}
}
using System;
ReplyDeleteusing System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp63
{
class Program
{
static void Main(string[] args)
{
int a, b, c, d;
Console.Write("enter a value \t");
a = Convert.ToInt32(Console.ReadLine());
Console.Write("enter b value \t");
b = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("\nYour required table is as under.\n\n--------------------------------\n");
for (d = 1; d <= b; d++)
{
c = a * d;
Console.WriteLine("{0} * {1} = {2} \n", a, d, c);
}
Console.ReadLine();
}
}
}