Question

Develop a program that uses four signed, global, short variables A, B, C, D Initialize each...

Develop a program that uses four signed, global, short variables A, B, C, D Initialize each variable A, B, C, D to a different positive one-digit value Somehow print the four values in order A B C D, space separated Print a newline character Reorder the values in the variables from the order A, B, C, D to B, C, D, A

A -> B

B -> C

C -> D

D -> A

Somehow print the four values in order A B C D, space separated

Homework Answers

Answer #1

Hi,

Hope you are doing fine. I have coded the above question in C++. The logic is same irrespective of any language. All the conditions as per the question have been met. The code has been clearly explained using comments that have been highlighted in bold.

Program:

#include <iostream>

using namespace std;

//declaring global signed short int variables and initializing them.
signed short int A=1,B=2,C=3,D=4;

int main()
{
   //printing each variable, seperating them by space
   cout << A <<" "<<B<<" "<<C<<" "<<D;
   //printing a new line character
   cout <<"\n";
   //declaring local variables that will store the values of A,B,C,D
   signed short temp1,temp2,temp3,temp4;
   //storing values of A, B, C, D into temp variables
   temp1=A;
   temp2=B;
   temp3=C;
   temp4=D;
   //changing the values of A, B, C, D using the values in temp variables as per the order mentioned in the question
   A=temp2;
   B=temp3;
   C=temp4;
   D=temp1;
   //printing each variable, seperating them by space
   cout << A <<" "<<B<<" "<<C<<" "<<D;
}

Executable code snippet:

Output:

Know the answer?
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
Similar Questions
Create a program which uses each struct declared in problem 1 and accesses each member of...
Create a program which uses each struct declared in problem 1 and accesses each member of each struct. (a) Create a variable using each struct and initialize it with some mock data of your choosing. (b) Print the members of each struct separated by a newline. (c) Modify each member of each struct to something different. (d) Print all members again. Save your code as prob2.c. This is Problem 1: struct ProductData {     int ID;     char Name[50];     float Price;     int...
You have four identical conducting spheres: A, B, C, and D. In each scenario below, sphere...
You have four identical conducting spheres: A, B, C, and D. In each scenario below, sphere A starts with a charge of Q, while B, C, and D start out with no net charge, and then the spheres are touched to each other and separated in the order described. Any spheres not in contact are held very far away. For each scenario, give the final charge of sphere B as a whole number fraction of Q. For example, if you...
1. Write a program to: Prompt the user to input an integer, a double, a character,...
1. Write a program to: Prompt the user to input an integer, a double, a character, and a string, storing each into separate variables. Then, output those four values on a single line separated by a space. Add a statement to also output in reverse. Add a statement to cast the double to an integer, and output that integer. 2. 2. Choose the statement(s) that generate(s) this output: I wish you were here a. printf("I wish", "you were here"); b....
Program Behavior Each time your program is run, it will prompt the user to enter the...
Program Behavior Each time your program is run, it will prompt the user to enter the name of an input file to analyze. It will then read and analyze the contents of the input file, then print the results. Here is a sample run of the program. User input is shown in red. Let's analyze some text! Enter file name: sample.txt Number of lines: 21 Number of words: 184 Number of long words: 49 Number of sentences: 14 Number of...
-Data Structure in C++ (Review for C++) -using vector and class In this assignment you’re going...
-Data Structure in C++ (Review for C++) -using vector and class In this assignment you’re going to build a simple “register machine”, a kind of minimal computer that only supports storing a fixed number of values (i.e., no randomly-accessible “main memory”). Your machine will consist of an input loop that reads lines of input from the user and then executes them, stopping when the user quits (by executing the stop command). Each line of input consists of a command followed...
For each of the following scenarios, indicate which of the four basic tax planning variables (entity,...
For each of the following scenarios, indicate which of the four basic tax planning variables (entity, character, time period, jurisdiction) impacts after-tax value. Note that more than one variable may apply to any scenario; identify all that are relevant. (For all requirements, You may select more than one answer. Single click the box with the question mark to produce a check mark for a correct answer and double click the box with the question mark to empty the box for...
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...
Your C program will do the following : Must use at least 2 function prototypes &...
Your C program will do the following : Must use at least 2 function prototypes & definitions . You can also use repetitions , control structures . You re not allowed any type of global arrays, or global variables. You are only allowed to use 2 dimensional arrays. 1. In your main program, create a array of size 7 X 7. 2. Create a function that accepts the empty array. The function will initiate the to zero. Then, the function...
Question three has four Parts (A,B,C,D) please select one of the answers below :   A) The...
Question three has four Parts (A,B,C,D) please select one of the answers below :   A) The nurse uses the PLISSIT format in helping clients who have sexual dysfunction. Which action by the nurse best reflects the LI section of this format? Select one: a. In order to avoid causing anxiety, limit the amount of information given to clients regarding adverse sexual side effects of treatments or medications. b. Start information using slang terms to refer to sexual body parts because...
Using the following code perform ALL of the tasks below in C++: ------------------------------------------------------------------------------------------------------------------------------------------- Implementation: Overload input...
Using the following code perform ALL of the tasks below in C++: ------------------------------------------------------------------------------------------------------------------------------------------- Implementation: Overload input operator>> a bigint in the following manner: Read in any number of digits [0-9] until a semi colon ";" is encountered. The number may span over multiple lines. You can assume the input is valid. Overload the operator+ so that it adds two bigint together. Overload the subscript operator[]. It should return the i-th digit, where i is the 10^i position. So the first...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT