Question

Create a C# program that counts from -3 to 3 in the console using a do...

Create a C# program that counts from -3 to 3 in the console using a do . . . while loop. Using a different kind of loop will result in a score of 0 for this problem.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

input code:

1 using System; 2. class HelloWorld { 3- static void Main() { /*declare the variables*/ int number=-3, sum=0; do /*do the sum

output:

Sum of 3 to 3 is:0 ... Program finished with exit code 0 Press ENTER to exit console. I

code:

using System;
class HelloWorld {
static void Main() {
/*declare the variables*/
int number=-3,sum=0;
do
{
/*do the sum*/
sum=sum+number;
/*increment number*/
number++;
}while(number!=4);
/*print the sum*/
Console.WriteLine("Sum of -3 to 3 is:"+sum);
}
}

Add a comment
Know the answer?
Add Answer to:
Create a C# program that counts from -3 to 3 in the console using a do...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using C++ 1. Create a while loop that counts even numbers from 2 to 10 2....

    Using C++ 1. Create a while loop that counts even numbers from 2 to 10 2. Create a for loop that counts by five (i.e. 0, 5, 10, ...) from 0 to 100 3. Ask for a person's age and give them three tries to give you a correct age (between 0 and 100) 4. Use a for loop to list Celsius and Fahrenheit temperatures. The "C" should be from -20 to 20 and the F should be shown correspondingly...

  • Create a C program Evaluate an expression from console input and print its result. -The format...

    Create a C program Evaluate an expression from console input and print its result. -The format of expressions: Number Symbol Number Symbol ... Symbol Number = Number -Number refers to an integer and Symbol refers to either + , -, *, or / - * and / have higher priority over + and -. E.g., given input “1+2*3+4=”, the result should be “11”; Hint: Use Polish Notation

  • Write a c# console program called “ArrayOfThings” where you create a class called Staff with private...

    Write a c# console program called “ArrayOfThings” where you create a class called Staff with private fields for StaffID and StaffName. Create Properties that can write data and retrieve data from these private fields. Create a Staff array that can hold up to ten Staff objects. Create ten objects using a for loop that automatically creates a new (empty) Staff object at each iteration of the loop and adds that object into the Staff array. Write data into the first...

  • C++ programming language Create a program that 1) counts from 0 to 10, but doeesn't include...

    C++ programming language Create a program that 1) counts from 0 to 10, but doeesn't include 10 2) counts backwards from 100 to 50 (inclusive) by 2's

  • Write a C++ console application that reverses an array of characters, and counts the number of:...

    Write a C++ console application that reverses an array of characters, and counts the number of:           Lower case characters (islower)           Upper case characters (isupper)           Digits (isdigit)           Other (not one of previous) Create four global variables to hold these counts. Create function void count(char input[], char reverse[]) that takes as input two arrays: one that contains characters and another that will contain the reverse of that array. The function will reverse the input array and do the...

  • Create a C++ program to calculate grades as well as descriptive statistics for a set of...

    Create a C++ program to calculate grades as well as descriptive statistics for a set of test scores. The test scores can be entered via a user prompt or through an external file. For each student, you need to provide a student name (string) and a test score (float). The program will do the followings: Assign a grade (A, B, C, D, or F) based on a student’s test score. Display the grade roster as shown below: Name      Test Score    ...

  • Write a C++ program. Using the while loop or the do – while loop write a...

    Write a C++ program. Using the while loop or the do – while loop write a program that does the following: Calculate the average of a series of homework grades (0 - 100) entered one at a time. In this case the lowest score will be dropped and the average computed with the remaining grades. For example suppose you enter the following grades: 78, 85, 81, 90, 88, 93 and 97.The average will be computed from the 6 grades 85,...

  • Write a program that prints the following console output using the while-loop and for-loop D not...

    Write a program that prints the following console output using the while-loop and for-loop D not use if-else, setw) and ciomanip> for this problem. .Before you open a Word file to copy the screen shots, tell Dr. Jo. Save the Word file as your name in your flash drive. .Take a screen-shot the code and paste to the Word file. (5 points). Take a screen-shots of the console output and paste to the Word file. (5 points) Save the Word...

  • Implement a Java program using simple console input & output and logical control structures such that...

    Implement a Java program using simple console input & output and logical control structures such that the program prompts the user to enter 5 integer scores between 0 to 100 as inputs and does the following tasks For each input score, the program determines whether the corresponding score maps to a pass or a fail. If the input score is greater than or equal to 60, then it should print “Pass”, otherwise, it should print “Fail”. After the 5 integer...

  • // Program takes 5 numbers from a user (from console), stores them into an // array,...

    // Program takes 5 numbers from a user (from console), stores them into an // array, and then prints them to the screen (on the same line). // Add code to complete this program. You only need to add code where indicated // by "ADD HERE". #include <iostream> using namespace std; int main() { const int SIZE = 5; // size of array // ADD HERE - create an array of integers that will hold 5 integers. cout << "please...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT