Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For each of the following numbers, write c# statements that satisfy the conditio

ID: 662630 • Letter: F

Question

For each of the following numbers, write c# statements that satisfy the conditions.

1. Sum the even integers from 1 to 200. Don't forget to declare any accumlator variables you may need.

2. Display the integers from 1 to 100, displaying 5 integers per line. You may use either a for-loop or while-loop. HINT: modulus operator.

3. Input a series of numbers and output the smallest number and largest number of the series

4. Compute the product of a series of integers where the series can be any number of items long. HINT: sentinel loop

Explanation / Answer

1) Put these statements in your program

sum=0;

for(i=0;i<=200;i=i+2){

sum=sum+i;

}

2) Put these statements in your program

for(i=1;i<=100;i=i+5){

j=i;

while(j<j+5){

Console.Write(j);
j++;

}

Console.WriteLine(" ");

}

3) # entire programe

using System;
using System.Linq;

class Program
{
static void Main(string[] args)
{
List<int> input = new List<int>();

// first read input till there are nonempty items, means they are not null and not ""
// also add read item to list do not need to read it again
string line;
while ((line = Console.ReadLine()) != null && line != "") {
input.Add(int.Parse(line));
}

// there is no need to use ElementAt in C# lists, you can simply access them by
// their index in O(1):
StockItem[] stock = new StockItem[input.Count];
for (int i = 0; i < stock.Length; i++) {
stock[i] = new StockItem(input[i]);
}
int biggestNumber = stock.Max();
Console.WriteLine(biggestNumber);
}

}

4) Entire program

using System;
using System.Linq;

class Program
{
static void Main(string[] args)
{
List<int> input = new List<int>();

// first read input till there are nonempty items, means they are not null and not ""
// also add read item to list do not need to read it again
string line;
while ((line = Console.ReadLine()) != null && line != "") {
input.Add(int.Parse(line));
}

// there is no need to use ElementAt in C# lists, you can simply access them by
// their index in O(1):
StockItem[] stock = new StockItem[input.Count];
for (int i = 0; i < stock.Length; i++) {
stock[i] = new StockItem(input[i]);
}
int product= 1;

for(i=0;stock.Length;i++){

product = product*stock[i]

}

Console.WriteLine(product);
}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote