1. A program that prints numbers from one hundred to two in labels one after the other.
for( int=1; i<=100 ; i+=2)
label1.Text += i.ToString() + "\n";
2. Program to calculate the sum of numbers from 1 to 100
int x= 0;
for (int i = 1; i <= 500; i++)
{
x= x+ i;
}
label1.Text = x.ToString();
3. The program that adds all the numbers between the numbers entered by the user in the two text boxes (If the user enters a larger number in the first box, it will act accordingly)
int a = int.Parse(textBox1.Text);
int b = int.Parse(textBox2.Text);
int x=0;
if(a>b)
{
for(int i=b;i<=a;i++)
{
x= x+ i;
}
}
else
{
for (int i = a; i <= b; i++)
{
x= x+ i;
}
}
label2.Text = x.ToString();
4. The program that calculates the factorial of the number entered in the textbox
int a = int.Parse(textBox1.Text);
int z= 1;
for (int i = 1; i <= a; i++)
{
z= z* i;
}
label1.Text = z.ToString();
5. A program that prints numbers from 1 to 100 to the screen at intervals equal to the number entered in the textbox.
int a = int.Parse(textBox1.Text);
for (int i = 1; i <= 100; i = i + a)
label1.Text += i.ToString() + "\n";
6. Program that prints all numbers between two numbers received from the user to the screen
int a = int.Parse(textBox1.Text);
int b = int.Parse(textBox2.Text);
for (int i = a; i <= b; i++)
label1.Text += i.ToString() + "\n";
7. A program that prints the numbers from one to one hundred, divisible by 5, to the screen.
8. A program that prints the numbers from one to one hundred divided by the number entered in the textbox.
9. Program that prints numbers divisible by 5 between the numbers entered in two text boxes.
int a = int.Parse(textBox1.Text);
int b = int.Parse(textBox2.Text);
for (int i = a; i <= b; i++)
{
if (i % 5 == 0) label1.Text += i.ToString() + "\n";
}
10. A program that prints numbers divisible by both 8 and 9 between the numbers entered in two text boxes.
11. Program to calculate how many numbers are divisible by 4 between numbers entered in two text boxes
int a = int.Parse(textBox1.Text);
int b = int.Parse(textBox2.Text);
int c= 0;
for (int i = a; i <= b; i++)
{
if (i % 4 == 0) c++;
}
label1.Text = c.ToString();
12. Program that finds whether the number entered in the text box is prime or not.
long a = long.Parse(textBox1.Text);
long d=0;
for (long i = 2; i < a; i++)
{
if (a % i == 0) d++;
}
if (d> 0) label1.Text = "Prime number";
else label1.Text = "Not prime";
13. Program that calculates combinations of numbers entered in two text boxes
14. Program that calculates permutations with numbers entered in two text boxes