0% found this document useful (0 votes)
14 views2 pages

Solution 4

xeded

Uploaded by

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

Solution 4

xeded

Uploaded by

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

Saeed Ghanem

Assignment 4
I.

int sum = 0;
string input = Console.ReadLine();
int n = Convert.ToInt32(input);
while(n !=0)
{
sum=sum+n;
input = Console.ReadLine();
n = Convert.ToInt32(input);
}
Console.WriteLine(sum);

II.

int sum = 0;
string input = Console.ReadLine();
int n = Convert.ToInt32(input);
while(n !=0)
{
sum=sum+n;
input = Console.ReadLine();
n = Convert.ToInt32(input);
}
Console.WriteLine(sum);
double avg = sum / 2.0;
Console.WriteLine(avg);

III.

int lowest = int.MaxValue;


int highest = int.MinValue;
int sum = 0;
string input = Console.ReadLine();
int n = Convert.ToInt32(input);
while(n !=0)
{
sum=sum+n;
input = Console.ReadLine();
n = Convert.ToInt32(input);
if (n < lowest)
lowest = n;
if (n > highest)
highest = n;
}

Console.WriteLine($"sum={sum}");
double avg = sum / 2.0;
Console.WriteLine($"avg={avg}");
Saeed Ghanem
IV.

int sum = 0;
int count=0;

while (true)
{
if (count >= 10)
break;

if (sum >= 100)


break;
string input = Console.ReadLine();
int n = Convert.ToInt32(input);

if (n == 0)
break;

sum = sum + n;
count++;
}
Console.WriteLine(sum);

int sum = 0;
int count=0;

while (true)
{
if (count >= 10)
break;

if (sum >= 100)


break;
string input = Console.ReadLine();
int n = Convert.ToInt32(input);

if (n == 0)
break;

sum = sum + n;
count++;
}
Console.WriteLine(sum);

You might also like