0% found this document useful (0 votes)
3 views5 pages

Static Void

The document contains multiple C# programs that perform various calculations based on user input. The first program sums the digits of numbers and finds the maximum digit, the second identifies three-digit numbers with unique digits, the third counts and sums even numbers, and the fourth calculates the average of even numbers. Each program includes loops and conditional statements to achieve its functionality.

Uploaded by

Yara 22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views5 pages

Static Void

The document contains multiple C# programs that perform various calculations based on user input. The first program sums the digits of numbers and finds the maximum digit, the second identifies three-digit numbers with unique digits, the third counts and sums even numbers, and the fourth calculates the average of even numbers. Each program includes loops and conditional statements to achieve its functionality.

Uploaded by

Yara 22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

static void Main()

:157 ‫ صفحة‬14 ‫حل سؤال‬


{
int x, a, b,y;
for (int i = 1; i <=50; i++)
{
Console.Write("x{0}= ",i);
x=int.Parse(Console.ReadLine());

a = x % 10;
b = x / 10;

Console.WriteLine("sum digits for x{0} = {1} ", i, a + b);


y = Math.Max(a, b);
Console.WriteLine("the max between "+a+" and "+b+" is : {0} ",y);
Console.WriteLine();

}
}
}
}
static void Main(string[] args)
:157 ‫ صفحة‬15 ‫حل سؤال‬
{

int a, b,c;

for (int i = 100; i <= 999; i++)


{
a = i % 10;
b = (i % 100) / 10;
c = i / 100;

if ((a!=b)&&(b!=c)&&(a!=c))
Console.WriteLine(" i with no similar digits = {0} ",i);
}

}
}
}
static void Main(string[] args)
:160 ‫ صفحة‬19 ‫حل سؤال‬
{
int x,y,z,c1=0,c2=0;

for (int i = 1; i <=10; i++)


{
Console.Write(" x{0} = ", i);
x = int.Parse(Console.ReadLine());

y = x % 10;
z = x / 10;

Console.WriteLine("sum for pair {0} = {1} ",i,(y+z) );


Console.WriteLine();
if (y == z)
c1++;

if ((y % 2 == 1) && (z % 2 == 1))


c2++;
}
Console.WriteLine("equal pair digits in this range are : {0} ",c1);
Console.WriteLine("uneven pair digits in this range are : {0} ",c2);
}
}
}
internal class Program
:160 ‫ صفحة‬20 ‫حل سؤال‬
{
static void Main(string[] args)
{
double x,sum=0,c1=0;

for (int i = 1; i <=5; i++)


{
Console.Write(" x{0} = ", i);
x = int.Parse(Console.ReadLine());

if (x % 2 == 0)
sum+=x;

if (x%2==0)
c1++;

}
Console.WriteLine("sum for even nrs : {0} ",sum);
Console.WriteLine("count for even nrs : {0} ",c1);
Console.WriteLine("avg for even nrs : "+(sum/c1));
}
}
}

You might also like