1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
damaskus [11]
2 years ago
7

Write a program to input a number and check whether it is even or odd number

Computers and Technology
1 answer:
Mashutka [201]2 years ago
3 0

Answer:#include <stdio.h>

int main() {

   int num;

   printf("Enter an integer: ");

   scanf("%d", &num);

   // true if num is perfectly divisible by 2

   if(num % 2 == 0)

       printf("%d is even.", num);

   else

       printf("%d is odd.", num);

   

   return 0;

}

You might be interested in
Write a program that calculates the average rainfall for three months. The program should ask the user to enter the name of each
Eduardwww [97]

Answer:

import java.util.Scanner;

public class ANot {

   public static void main(String[] args) {

   Scanner input = new Scanner(System.in);

       System.out.println("Enter the month name:");

       String month1 = input.next();

       System.out.println("Enter the amount of rain for "+month1);

       double month1Rain = input.nextDouble();

       System.out.println("Enter the second month: ");

       String month2 = input.next();

       System.out.println("Enter the amount of rain for "+month2);

       double month2Rain = input.nextDouble();

       System.out.println("Enter the Third month: ");

       String month3 = input.next();

       System.out.println("Enter the amount of rain for "+month3);

       double month3Rain = input.nextDouble();

       double averageRainfall = (month1Rain+month2Rain+month3Rain)/3;

       System.out.printf("Average Rainfall is: %,.2f  ", averageRainfall);

   }

}

Explanation:

This is written in Java Programming language

  1. Import  the scanner class to prompt user for the inputs (Months and amount of rainfall for each month)
  2. Find the average of the three rainfall amount by adding up and dividing by 3
  3. Output the average. Pay particular attention to the use of java's printf in order to print the average to 2 decimal places
8 0
3 years ago
This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balance
aksik [14]

Answer:

import java.util.Scanner;

public class TeamRoster {

  public static void main(String[] args) {

     Scanner scan = new Scanner(System.in);

     int[][] players = new int[5][2];

     boolean keepAlive = true;

     char input;

     

     for (int i = 0; i < 5; i++) {

        System.out.println("Enter player " + (i+1) + "'s jersey number: ");

        players[i][0] = scan.nextInt();

        if( players[i][0] >= 0 && players[i][0] < 100 ) {

             System.out.println("Enter player number less than 100");

               System.out.println("Enter player " + (i+1) + "'s rating: ");

               players[i][1] = scan.nextInt();

               if ( players[i][1] >= 1 && players[i][1] <10 ) {

                     System.out.println();

               }    else {

                     System.out.println("Enter player " + (i+1) + "'s rating: ");

                     players[i][1] = scan.nextInt();

               }

     }

     }

     System.out.println();

     outputRoster(players, 0);

     

     while (keepAlive) {

        outputMenu();

        input = scan.next().charAt(0);

        if (input == 'q') {

           keepAlive = false;

           break;

        } else if (input == 'o') {

           outputRoster(players, 0);

        } else if (input == 'u') {

           System.out.println("Enter a jersey number: ");

           int jerseyNum = scan.nextInt();

           System.out.println("Enter a new rating for the player: ");

           int newRating = scan.nextInt();

           for (int l = 0; l < 5; l++) {

              if (players[l][0] == jerseyNum) {

                 players[l][1] = newRating;

              }

           }

        } else if (input == 'a') {

           System.out.println("Enter a rating: ");

           int rating = scan.nextInt();

           outputRoster(players, rating);

        } else if (input == 'r') {

           System.out.println("Enter a jersey number: ");

           int jerseyNum = scan.nextInt();

           boolean exists = true;

           for (int l = 0; l < 5; l++) {

              if (players[l][0] == jerseyNum) {

                 System.out.println("Enter a new jersey number: ");

                 players[l][0] = scan.nextInt();

                 System.out.println("Enter a rating for the new player: ");

                 players[l][1] = scan.nextInt();

              }

           }

           

        }

     }

     

     return;

  }

   

  public static void outputRoster(int[][] players, int min) {

     System.out.println(((min>0) ? ("ABOVE " + min) : ("ROSTER")));

     int item = 1;

     for (int[] player : players) {

        if (player[1] > min) {

           System.out.println("Player " + item + " -- Jersey number: " + player[0] + ", Rating: " + player[1]);

        }

        item++;

     }

     System.out.println();

  }

   

  public static void outputMenu() {

     System.out.println("MENU");

     System.out.println("u - Update player rating");

     System.out.println("a - Output players above a rating");

     System.out.println("r - Replace player");

     System.out.println("o - Output roster");

     System.out.println("q - Quit\n");

     System.out.println("Choose an option: ");  

  }

}

Explanation:

The program is written in Java.

It is a bit straightforward.

The Scanner module is declared and used to collect input from the user.

The program prompts the user for each player jersey then rating.

All five players details are collected.

The program shows the output of all the entries.

5 0
3 years ago
Why are my images blocked on brainly<br><br> i just see gray and on every avatar and image
o-na [289]

Answer:

they are not its just that people haven't changed their profile picture. i haven't yet lol

Explanation:

5 0
2 years ago
Read 2 more answers
There are two main types of hard drive available to a computer. State what they are and describe their use.
Gala2k [10]

Answer:

Hard disk drives (HDD), which use one or more rotating discs and rely on magnetic storage, and solid-state drives (SSD), which have no moving mechanical parts, but use flash memory like the kind found in USB flash drives.

Explanation:

6 0
2 years ago
What is another word for microchips operating systems input methods and everything in between?
lord [1]
The answer is computer. A computer is made up of microchips (CPU and GPU), an operation system (macOS or Windows), input methods (keyboard and mouse), and other parts.
7 0
3 years ago
Other questions:
  • You have found statistics on the Internet that you would like to use in your speech.
    6·1 answer
  • Which part of the cpu stores instructions for high speed access or processing
    14·1 answer
  • Explain what might happen if two stations are accidentally assigned the same hardware address?
    15·1 answer
  • The most fundamental components of storage that users interact with are the:
    11·1 answer
  • Which property is assigned to a file by the operating system?
    13·1 answer
  • In this scenario, hackers launch cyber-attacks that affect several parts of the nationâs financial infrastructure over the cours
    8·1 answer
  • How is the bootstrap program started?
    6·2 answers
  • Design a class named Person and its two subclasses named Student and Employee. Make Faculty and Staff subclasses of Employee. A
    13·1 answer
  • What is the difference between PowerPoint and Outlook?
    5·1 answer
  • 1. You are given a database to create, however, you realize that in the instructions you are told to create relationships betwee
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!