Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

for C# lab * Step 5 - Use a for loop to loop from 1-100. Each time through the loop, output the loop control variable

for C# lab

* Step 5 - Use a for loop to loop from 1-100. Each time through the loop, output the loop control variable and whether or not it is even or odd.

Here is code for checking to see if it's even or odd:

*/

int oddeven = 1;

// The condition (oddeven % 2 == 0) checks for even

// You just need to wrap a for loop around this if statement

if (oddeven % 2 == 0) {

Console.WriteLine($"{oddeven} is even.");

}

else {

Console.WriteLine($"{oddeven} is odd.");

}

/* Step 6 - Use a while loop. Allow a user to input a value.

Convert the input to an integer.

if the input = 0, end the loop. Otherwise, keep asking for input.

A team member gives you the following pseudocode:

- create int variable inputvar

- assign a value -1 to inputvar

- while (inputvar is not equal to 0)

- prompt user for input

- read input using Console.ReadLine()

- Convert it to an input using Convert.ToInt32()

- assign the value to inputvar

- output "You entered " + inputvar

*/

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions