using System;
namespace counting
{
class Program
{
static void Main(string[] args)
{
int i, j;
for (i = 1; i <= 5; i++)
{
for (j =1; j <= i; j++)
{
Console.Write(""+(j));
}
Console.WriteLine("");
}
Console.ReadKey();
}
}
}
Output:
1
12
123
1234
12345
//giving range
using System;
namespace count_increment
{
class Program
{
static void Main(string[] args)
{
int n;
Console.WriteLine("Enter no for range");
n = int.Parse(Console.ReadLine());
int i, j;
for (i = 1; i <=n; i++)
{
for (j = 1; j <= i; j++)
{
Console.Write(""+j);
}
Console.WriteLine("");
}
Console.ReadKey();
}
}
}
Output:
Enter no for range
6
1
12
123
1234
12345
123456
Enter no for range
6
1
12
123
1234
12345
123456
if i want to add range?? then?
ReplyDeleteCode:
ReplyDeleteusing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Basic_Practicals
{
class Program
{ //Printing 1 12 123 in triangle
static void Main(string[] args)
{
int i, j,n = 0;
Console.Write("Enter No for the range :");
n = int.Parse(Console.ReadLine()); // Get number of Line from User
Console.WriteLine("");
for (i = 1; i < n; i++) // Loop to go on next line
{
for (j = 1; j <= i; j++) // Loop to print number
{
Console.Write("" + j);
}
Console.WriteLine("");
}
Console.ReadLine();
}
}
}
Output:
Enter No for the range :4
1
12
123
thank you it is very helpful
ReplyDelete#include
ReplyDelete#include
void main()
{
int j,k;
clrscr();
for(j=1;j=4;j++)
{
for(k=1;k<=j;k++)
{
printf("%d",j);
}
printf("\n");
}
getch();
}
output
ReplyDelete1
22
333
4444
1
ReplyDelete1 2
1 2 3
1 2 3 4
12345
0
ReplyDelete101
21012
3210123
432101234
54321012345
For this I want program.
How about not using console
ReplyDelete