Question

C Programming only. (NO C++)

Copy & paste all source code with your answer.

Also take screenshot of it compiled.

11. Write a program with the following software architecture int main) void ReadX/ OuT */ Ant *x) void IncrementX4Times(/t IO */ int *x) void Printx(/*IN */ int x) such that (1) the function ReadX) is called by the function main0 to input the value for main0 variable x from the program user as shown in the screenshot below; (2) IncrementX4Times0 is called by main) to add 1 (increment) the value the main0 variables x four different ways (using the operators + and-; using the operator +-; using the operator preincrement++; and using postincrement ++); and (3) PrintXO is called by main) to print the values of the main0 variable x as shown in the screenshot below. ENCOURSESCS1311CodeREVIEwAssignment4Problem11.exe x-5 Press any key to continue · · -

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

\color{blue}\underline{Solution.cpp:}

#include <stdio.h>

void ReadX(int* x)
{
printf("x? ");
scanf("%d", x);
}

void IncrementX4Times(int* x)
{
//Assigning value of x to variable y
int y = *x;
y = y + 1;
y += 1;
++y;
y++;
//Assigning updated y to x
*x = y;
}

void PrintX(int x)
{
printf("x = %d\n", x);
}

int main()
{
int x;
ReadX(&x);
PrintX(x);
IncrementX4Times(&x);
PrintX(x);
return 0;
}

\color{red}\underline{Output:}

Process exited after 0.6401 seconds with returnvalue 0 Press any key to continue - - -

Add a comment
Know the answer?
Add Answer to:
C Programming only. (NO C++) Copy & paste all source code with your answer. Also take...
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 this assignment, you must complete the 5 functons below. Each function's body must consist of...

    In this assignment, you must complete the 5 functons below. Each function's body must consist of just a single C statement. Furthermore, the statement must not be a control statement, such as if, switch, or any kind of loop. For each problem, you are also restricted to the operators and constants as specified. */ /* 1. Write a function which zeros a variable x. A pointer to x is passed as a parameter. YOU MAY USE NO CONSTANTS in this...

  • 1) Copy and paste the code below into your IDE, and then answer the question. if...

    1) Copy and paste the code below into your IDE, and then answer the question. if (false) { System.out.println("Hello"); } What happens and why? A) Hello is not displayed because the if statement is false B) "Hello" is displayed even if the if statement is false because the semicolon is cutting it off from its body C) Program does not run due to a compiler error ie semicolon D) "Hello" is displayed since the expression in the if statement registers...

  • QUESTION 18 According to class materials, the program is allowed to overload operators only if at...

    QUESTION 18 According to class materials, the program is allowed to overload operators only if at least one incoming parameter received by the operator has a class type. 1. (a) True 2. (b) False QUESTION 19 According to the course materials, a function can take value parameters and reference parameters. A value parameter is a separate variable from the one in main() or another calling function only if the function value parameter has a different name than the one in...

  • Lab 6.6 – Using Value and Reference Parameters Below is a copy of the source code....

    Lab 6.6 – Using Value and Reference Parameters Below is a copy of the source code. 1 // Lab 6 swapNums.cpp -- Using Value and Reference Parameters 2 // This program uses a function to swap the values in two variables . 3 // PUT YOUR NAME HERE. 4 #include <iostream> 5 using namespace std; 6 7 // Function prototype 8 void swapNums(int, int); 9 10 /***** main *****/ 11 int main() 12 { 13 int num1 = 5, 14...

  • need this in c programming and you can edit the code below. also give me screenshot...

    need this in c programming and you can edit the code below. also give me screenshot of the output #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #define LINE_SIZE 1024 void my_error(char *s) { fprintf(stderr, "Error: %s\n", s); perror("errno"); exit(-1); } // This funciton prints lines (in a file) that contain string s. // assume all lines has at most (LINE_SIZE - 2) ASCII characters. // // Functions that may be called in this function: // fopen(), fclose(), fgets(), fputs(),...

  • C Language Programming. Using the program below - When executing on the command line only this...

    C Language Programming. Using the program below - When executing on the command line only this program name, the program will accept keyboard input and display such until the user does control+break to exit the program. The new code should within only this case situation “if (argc == 1){ /* no args; copy standard input */” Replace line #20 “filecopy(stdin, stdout);” with new code. Open read a text file “7NoInputFileResponse.txt” that contains a message “There were no arguments on the...

  • C++ 4. (5 points) Identify the following items in the programming code shown below: a. Function...

    C++ 4. (5 points) Identify the following items in the programming code shown below: a. Function prototype, function heading, function body, and function definitions. b. Function call statements, formal parameters, and actual parameters. C. Value parameters and reference parameters. d. Local variables and global variables. 6. Named constants. #include <iostream> //Line 1 using namespace std; //Line 2 const double NUM = 3.5; //Line 3 int temp; //Line 4 void func(int, doubles, char); //Line 5 int main() int num; double one;...

  • I need an OUTLINE ONLY (pseudocode/comments). DO NOT DO THE PROGRAMMING ASSIGNMENT. Part I: PA3 Outline...

    I need an OUTLINE ONLY (pseudocode/comments). DO NOT DO THE PROGRAMMING ASSIGNMENT. Part I: PA3 Outline (10 points). Create an outline in comments/psuedocode for the programming assignment below. Place your comments in the appropriate files: main.cpp, functions.h, dealer.cpp, dealer.h, dealer.cpp (as noted below). Place into a file folder named LastnamePA3, the zip the content and hand in a zip file to Canvas. Part II: PA3: Car Dealership (40 points) For Programming Assignment 3 you will be creating a program to...

  • Using C programming Description: You have been tasked to design an application for an engineering...

    Using C programming Description: You have been tasked to design an application for an engineering firm to measure the performance of their vehicle designs. The user, an engineer will enter data into your program when prompted and will perform the required calculation and output the answer. The formula used for this project calculates the distance an object will cover in meters given an initial velocity, a rate of acceleration and a time of acceleration or travel. 1. Your program must...

  • The following code is for Chapter 13 Programming Exercise 21. I'm not sure what all is...

    The following code is for Chapter 13 Programming Exercise 21. I'm not sure what all is wrong with the code written. I get errors about stockSym being private and some others after that.This was written in the Dev C++ software. Can someone help me figure out what is wrong with the code with notes of what was wrong to correct it? #include <cstdlib> #include <iostream> #include <iomanip> #include <fstream> #include <cassert> #include <string> using namespace std; template <class stockType> class...

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