Question

USING C# LANGUAGE WE USE SCANF AND PRINTF PLEASE USE THAT IN THE ANSWER WE DONT...

USING C# LANGUAGE WE USE SCANF AND PRINTF PLEASE USE THAT IN THE ANSWER
WE DONT USE CONSOLEWRITE OR READ

  1. Write a program that takes in a number from the user. Then it prints a statement telling the user if the number is even or odd. If the number is odd, it counts down from the number to 0 and prints the countdown on the screen, each number on a new line. If the number is even, it counts down from the number to 0, only even numbers. For example, if the user enters 5, the output will look like this:

    The number you entered is odd.

    5

    4

    3

    2

    1

    0

    If the user enters 6, the output will look like this:

    The number you entered is even.

    6

    4

    2

    0

    Submit your .c file. Also submit a screen shot of the terminal with the output displayed.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <stdio.h>

int main() {
    int n;
    printf("Enter a number: ");
    scanf("%d", &n);
    if (n % 2 == 0)
    {
        printf("The number you entered is even.\n");
        while (n >= 0)
        {
            printf("%d\n", n);
            n -= 2;
        }
    }
    else
    {
        printf("The number you entered is odd.\n");
        while (n >= 0)
        {
            printf("%d\n", n);
            n--;
        }
    }
    return 0;
}
Add a comment
Know the answer?
Add Answer to:
USING C# LANGUAGE WE USE SCANF AND PRINTF PLEASE USE THAT IN THE ANSWER WE DONT...
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
  • In C language using printf and scanf statements: Write a program to display a histogram based...

    In C language using printf and scanf statements: Write a program to display a histogram based on a number entered by the user. A histogram is a graphical representation of a number (in our case, using the asterisk character). On the same line after displaying the histogram, display the number. The entire program will repeat until the user enters zero or a negative number. Before the program ends, display "Bye...". The program will ask the user to enter a non-zero...

  • Please help me with this program. Using C++ (printf & scanf) statements. Thank you. ASSIGNMENT: Write...

    Please help me with this program. Using C++ (printf & scanf) statements. Thank you. ASSIGNMENT: Write a program to ask the user for a number that includes a decimal point. Then display the integer part of the number (the part of the number to the left of the decimal point) and the decimal part of the number (the part of the number to the right of the decimal point, including the decimal point Follow the 3 steps in the Information...

  • This program should be run on Visual Studio. Please use printf and scanf as input and...

    This program should be run on Visual Studio. Please use printf and scanf as input and output. Thank you 6.11 Lab Exercise Ch.6a: Functions: String analyzer Create and debug this program in Visual Studio. Upload your Source.cpp file for testing (1) Prompt the user to enter a string of their choosing. Output the string. (1 pt) Ex: ics Enter a sentence or phrase: The only thing we have to fear is fear itself. You entered: The only thing we have...

  • the coding language is just the basic c language and here is my first attempt at...

    the coding language is just the basic c language and here is my first attempt at this problem my problem is that if the user inputs a number that is equal to a number that has been entered previously the code will never end until the user enters a number that is bigger than any other number previously entered any help will be helpful Write a program to read-in a sequence of integers from the keyboard using scanf(). Your program...

  • can u please solve it in c++ format,,,, general format which is #include<stdio.h> .......printf and scanf...

    can u please solve it in c++ format,,,, general format which is #include<stdio.h> .......printf and scanf format dont worry about the answers i have down Q3, What is the output of the program shown below and explain why. #include #include <stdio.h> <string.h> int main(void) ( char str[ 39764 int N strlen(str) int nunj for (int i-0; i t Nǐ.de+ printf(") num (str[] 'e); I/ digits range in the ASCII code is 48-57 if (nue > e) f 9 printf( Xdin,...

  • Write a program that asks the user to type an even number or 111 to stop....

    Write a program that asks the user to type an even number or 111 to stop. When the user types an even number, display the message “Great Work”, and then ask for input again. When the user types an odd number, display the message “Try again” and ask the user to enter again. When the user enters the sentinel value of 111 the program ends I've attempted this but it went horribly wrong. we are only suppose to use while,...

  • Just do program 6 using c++ which are printf and scanf. Please don’t use cout and...

    Just do program 6 using c++ which are printf and scanf. Please don’t use cout and cin. Program 4: A slot machine has three windows. A random fruit is picked for each window from cherry apple, lemon, and orange. If all three windows match, the user wins 8 times the bet amount. If the first two windows only are cherries, the user wins 3 times the bet amount. If the first window is a cherry and the second window is...

  • In the Source Folder (src) of this project create a new C source file called "gcd.c"....

    In the Source Folder (src) of this project create a new C source file called "gcd.c". Once again, copy the contents of the "main.c" file above into the "gcd.c" source file. Modify this program to NOT ask the user to input the second Positive Integer, if the user has entered a program terminating value for the "first" input Postitive Integer. #include <stdlib.h> #include <stdio.h> int main(int argc, char *argv[]) { //============================== setbuf(stdout, NULL); // turns standard output buffering off int...

  • (Please use C language, not C++) Determine the following information about each value in a list...

    (Please use C language, not C++) Determine the following information about each value in a list of positive integers. a. Is the value a multiple of 7, 11, or 13? b. Is the sum of the digits odd or even? (parameter output returns 0 for even, 1 for odd) c. Is the value a prime number? (parameter output returns 0 nonprime, 1 for prime) Use an output file for results. The goal is to implement both pass by value and...

  • Using C Programming: (use printf, scanf) 18. Tic-Tac-Toc Game Write a program that allows two players...

    Using C Programming: (use printf, scanf) 18. Tic-Tac-Toc Game Write a program that allows two players to play a game of tic-tac-toc. Use a two- dimensional char array with three rows and three columns as the game board. Each element of the array should be initialized with an asterisk (*). The program should run a loop that Displays the contents of the board array Allows player 1 to select a location on the board for an X. The program should...

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