Using for loop . Input an integer and identify whether it's EVEN OR ODD ( without using modulo operator )using only . C++ programming

Answers

Answer 1
Answer:

Answer:

Following are the program in c++ language

#include<iostream> // header file

using namespace std; // namespace

int main()  

{

int n1,i; // variable declaration

cout<<"Enter Number: ";

cin>>n1; // input number

for(i=n1;i>1;i=i-2) // check the condition  

{

n1 = n1-2; // decrement the value of number by -2  

}

if(n1==0) // check if it is 0

cout<<"number is EVEN"<<"\n"; // print even

else

cout<<"number is ODD"<<"\n"; // print odd

return 0;

}

Output:

Enter Number: 45

number is ODD

Again run the program

Enter Number:10

number is EVEN

Explanation:

In this program, we input the number by a user in variable n1. After that, we iterate the for loop and initialize the value of a variable" i" in for loop and check the condition.

In each iteration, the variable n1 is decrement by 2 and store it n1.

Finally, check if n1==0 then it print number is EVEN  otherwise it print number is ODD.


Related Questions

What is this car first to awnser is the brianliest
Which is an example of an operating systemaAdobe PhotoshopbInternet ExplorercWindowsdMicrosoft Word
Write a python program that asks the user to enter a student's name and 8 numeric tests scores (out of 100 for each test). The name will be a local variable. The program should display a letter grade for each score, and the average test score, along with the student's name. There are 12 students in the class. Write the following functions in the program: calc_average - this function should accept 8 test scores as arguments and return the average of the scores per student determine_grade - this function should accept a test score average as an argument and return a letter grade for the score based on the following grading scale: 90-100 A 80-89 B 70-79 C 60-69 D Below 60 F
In ____________, a large address block could be divided into several contiguous groups and each group be assigned to smaller networks.
Write a program that reads a string (password) and a number. The program will keep asking the user for a password and number as long as the user does not provide the expected values ("milkyway" and 1847, respectively), and as long as the user has not exhausted the maximum number of attempts . In addition, the program will stop asking for data if the word "quit" is provided as a password value (in this case, the program will not read the number). The program will print the message "Wrong credentials" when an invalid password or number (or both) is provided. If the user eventually provides the correct credentials the message "Access Granted" will be displayed; otherwise the message "Access Denied" will be generated. The following example illustrates the messages to use to read data and to display results. Enter password: milkyway Enter number: 10 Wrong credentials Enter password: tomato Enter number: 1847 Wrong credentials Enter password: milkyway Enter number: 1847 Access Granted

Which of the following people was a member of FFA?O Kenny Chesney
O Tim McGraw
O Alan Jackson
O Billy Currington

Answers

Answer: Tim McGraw

Explanation:

The National FFA Organization is a youth organization that originally aimed to encourage the youth to venture into agriculture by offering agriculture education to youth in high schools and middle schools. In recent years they started offering education in other areas such as business and technology.

The FFA is quite famous and has had and still has a lot of members. It is of no surprise therefore that some of their alumni are now stars. Famous Country musician Tim McGraw is one such alumni and he was a member of the FFA in his hometown of Start, Louisiana.

Other stars who were part of the FFA include; Taylor Swift and Sterling Martin.

Give a non-network example of hierarchical addressing and discuss how it reduces the amount of work needed in physical delivery. Do not use the postal service, or the telephone network..

Answers

HIERARCHICAL EXAMPLE.

Many examples of hierarchical addressing exists which reduces the amount of work needed in locating or in delivering,and one of such examples is the 'sorting of books in a library'.

Looking at a library having books kept randomly on any stack and shelf,it will make it difficult finding any book easily or locating any book of a specific genre.so,to avoid such problems, books are orderly sorted in a library and each book is given or has a unique identification number.

Books that has the same or related subject are kept in the same stack and books of the same genre are also kept together.

In a library,there are many stacks having different rows.

Take for an example; If one need to find a book on computer network,the user can search for the books in stacks of books that are related to Computer Science instead of searching the whole library for the book.

So,the hierarchical addressing saves lots of work and also time required for searching a specific book in the library.

Describe how data is transmitted using half-duplex serial data transmission.

Answers

Half-duplex serial data transmission allows for communication in both directions, but only one direction at a time. In applications such as walkie-talkies and traditional telephone systems.

In half-duplex serial data transmission, data is transmitted in one direction at a time

1. Sender initiates transmission: The sender, also known as the transmitter, starts the data transmission process. It prepares the data to be sent and waits for the appropriate time to start transmitting.

2. Sender sends data: The sender begins sending the data in a sequential manner. It breaks down the data into smaller units called frames or packets.

3. Receiver acknowledges receipt: After receiving each frame, the receiver acknowledges its successful reception to the sender.

4. Sender waits for acknowledgment: Upon sending a frame, the sender waits for the receiver's acknowledgment. If an acknowledgment is received, the sender proceeds to send the next frame.

5. Receiver processes the data: The receiver receives the frames and processes the data within each frame. It checks for errors using techniques like checksums or cyclic redundancy checks (CRC).

6. Roles switch for bidirectional communication: Once the sender finishes transmitting its data, the roles switch and the receiver becomes the sender, initiating its own transmission.

7. Communication continues: The process continues as the receiver sends its data and waits for acknowledgments, while the new sender processes the received data and sends acknowledgments.

Overall, half-duplex serial data transmission allows for communication in both directions, but only one direction at a time. This type of transmission is commonly used in applications such as walkie-talkies and traditional telephone systems.

Learn more about half-duplex serial here;

brainly.com/question/33829144

#SPJ3

Answer:

In half duplex mode, the signal is sent in both directions, but one at a time. In full duplex mode, the signal is sent in both directions at the same time. In simplex mode, only one device can transmit the signal. In half duplex mode, both devices can transmit the signal, but one at a time.

PLEASE HELP!!!For this activity, you will create two designs for the same project. For example, you might choose to create a CD cover for your favorite band’s newest release, or you might want to design a menu for the local deli. No matter what you decide for your subject matter, the two designs must involve different media. One of these media will be an image-editing program, such as Inkscape. You will learn more about the basic tools available in Inkscape later in this lesson. The two designs should incorporate different techniques. For example, you might make one design abstract, while making the other more realistic. Be sure to save both of your designs. Scan or take a picture of the design that wasn’t created in an image-editing program. You will submit this item later in this lesson as your portfolio item. Select the link to access the Techniques Activity Rubric.

Answers

Answer:

I'm not exactly sure on what the question is, but from reading it, I determined that you'll be creating 2 different designs using Inkscape/Photoshop. I'm leaving 2 of my designs in here for you to use on your project. Unknown on what to do about the design that wasn't created in an image-editing program.

_ is the adherence to a personal code of principles.Ethics
Morality
Integrity
Honesty
Section B

Answers

Answer: Ethics

Explanation:

 Ethics is the basic principle for the personal code. The code of the ethics is basically designed for outline the values in the organization with honesty and integrity.

The ethics is basically depend upon the principle of core value of the organization. The code of the ethics basically guide the core value in the organization and breaking the rule of ethics can also cause termination from the organization.

Morality, integrity and honesty are all the sub part of the ethics vale in the organization. Therefore, ethics is the correct option.  

Write a java program that use multiple arrays This is a simple array program which does not use an "external class & demo program" If you wish, you may break it down into methods, but that is not required. a. Set up 4 arrays which hold data about 6 items you want to sell: [make them up] int[ ] itemnum int[ ] quantity double[ ] price double[ ] sales b. Set up loops to load the itemnum, quantity and price arrays c. Set up another loop to calculate values for the sales array. [= price * quantity] d. Set up another loop to print the item number and sales amount for each transaction . e. Set up another loop to calculate the total sales of all 6 items f. print the total sales amount

Answers

Answer:

Explanation:

import java.util.Array;

public class Items{

public static void main (String {} args){

// a. Set up 4 arrays which hold data about 6 items you want to sell

int [] itemnum = new int[](1,2,3,4,5,6);

int [] quantity = new int[](500,200,350,100,270,300);

double [] price = new double [](10000, 50000,30000, 22000, 26000,100200);

double[] sales = new double [6];

//b. Set up loops to load the itemnum, quantity and price arrays

for(int I=0;I<6;I++)

{

System.out.println("Item "+itemnum[I]);

System.out.println("Item "+quantity[I]);

System.out.println("Item "+price[I]);

}

//c. Set up another loop to calculate values for the sales array.

for(int j=0;j<6;j++)

{

sales[j] = quantity[j] * price[j];

}

//d. Set up another loop to print the item number and sales amount for each transaction

for(int k=0;k<6;k++)

{

System.out.println("Item Number "+itemnum[k]);

System.out.println("Sales Amount "sales[k]);

}

//e. Set up another loop to calculate the total sales of all 6 items

double totalsales = 0;

for(int l=0;l<6;l++)

{

totalsales+=sales[l];

}

//f. print the total sales amount

System.out.print("Total Sales: "+totalsales);

}

}