Question

Using the programming language C, read user input of an integer, check and output whether the...

Using the programming language C, read user input of an integer, check and output whether the integer is an odd number or even number.

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

Code:

#include<stdio.h>
int main()
{
   int integer;
   //declared a variable named "integer" to store the input from the user

   printf("Please enter the integer: ");
   //taking input from the user

   scanf("%d",&integer);
   //assigning it to the variable named "integer"

   //using if else statement checking whether integer is even or
   if (integer%2 == 0 )
      printf("The entered number %d is a even number",integer);
   else
      printf("The entered number %d is a odd number",integer);
      //printing the output

   return 0;
}

Explanation:

The above question is to write a "C" program that takes an integer as input from the user

If the number is divisible by 2 it is an even number otherwise its an odd number

So using if else statements we wrote the program to print the output

Output of the program:

main.c 1 #include<stdio.h> 2 int main() 3-{ int integer; //declared a variable named integer to store the input from the us

Add a comment
Know the answer?
Add Answer to:
Using the programming language C, read user input of an integer, check and output whether the...
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
  • 1. Write a program that takes a number as input and check whether the number is...

    1. Write a program that takes a number as input and check whether the number is positive, negative or zero. 2. Write a C++ program that prompts the user to enter a number and checks whether the entered number is even or odd. 3.  Using switch-case statement write a C++ program that prompts the user to enter 1, 2 or 3 and display "Red" if selection is 1, "Yellow" if selection is 2, or "Green" if selection is 3. 4. Write...

  • Using the programming language Java or C++, Write a function that takes an integer as input....

    Using the programming language Java or C++, Write a function that takes an integer as input. Return true if this integer is a palindrome integer; false otherwise;

  • In C language, please use at least one user defined function, and show data validity check...

    In C language, please use at least one user defined function, and show data validity check for != integers 3) Write a program to find whether a given number is a Palindrome number (number that is same when you read from forward or backward). You need to take a long integer number from user as input and verify whether it's a number and positive or not. If the input is not valid (e.g., string or float) or positive, then notify...

  • I need help with this exercise. Thank you for your help Language is C++ 6. Write...

    I need help with this exercise. Thank you for your help Language is C++ 6. Write a program that prompts the user to input a positive integer. It should then output a message indicating whether the number is a prime number. (Note: An even number is prime if it is 2. An odd inte- ger is prime if it is not divisible by any odd integer less than or equal to the square root of the number.)

  • Write code that prompts the user to input a number. The program should then output the...

    Write code that prompts the user to input a number. The program should then output the number and a message saying whether the number i "Positive, "Negative" or "Zero". It should further output whether the number is odd or even (zero is counted as even) For example:

  • Question 4 (3 mark) : Write a Java program to ask the user to input an...

    Question 4 (3 mark) : Write a Java program to ask the user to input an integer number from the keyboard. The output should indicate whether it is positive, zero, or negative, an even number or an odd number. REQUIREMENTS • Your code should ask user to input an integer number, then decide its sign and parity based on this input. • Your code should use if-else statement. Your code must work exactly as the specification and the output should...

  • THE PROGRAMMING LANGUAGE IS C++ Part 1.Create a program that decides whether a given integer is...

    THE PROGRAMMING LANGUAGE IS C++ Part 1.Create a program that decides whether a given integer is prime or not. The program should at the end of its analysis print the number followed by prime or composite. Part 2.Make the program from part 1 print the prime factors of any composite number entered (an additional feature to Part 1). THE PROGRAMMING LANGUAGE IS C++

  • 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 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...

  • Is Prime Number In this program, you will be using C++ programming constructs, such as functions....

    Is Prime Number In this program, you will be using C++ programming constructs, such as functions. main.cpp Write a program that asks the user to enter a positive integer, and outputs a message indicating whether the integer is a prime number. If the user enters a negative integer, output an error message. isPrime Create a function called isPrime that contains one integer parameter, and returns a boolean result. If the integer input is a prime number, then this function returns...

  • Lab-3B Two-Way Branch Write a MIPS program to read a positive integer and to determine and...

    Lab-3B Two-Way Branch Write a MIPS program to read a positive integer and to determine and display whether it is an even number or odd. A positive integer X is odd if its last digit is 1. Otherwise X is odd if X AND 1 is 1, or in other words X is even if X AND 1 is 0. Example Input/Output Give a positive number X= 41 X is an odd number Give a positive number X= 40 X...

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