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
  • Programming in C/C++ Submit your source code files (all .h and .cpp files) NO GLOBAL VARIABLES...

    Programming in C/C++ Submit your source code files (all .h and .cpp files) NO GLOBAL VARIABLES Program: Use operator overloaded functions for a birthday club – Based on Chapter 11 lecture (25 pts) Make a class called Birthday that will have a date of month, day, and year and the name. Need to have overloaded operators to compare values along with regular functions like: Overload operator == that takes a Birthdate, compares against the current date values, and returns a...

  • 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(),...

  • I need help programming this question using C language. This program uses input data entered in...

    I need help programming this question using C language. This program uses input data entered in command line at the same time when the command or .exe file is entered. They are called command-line arguments. Because everything entered in command line is taken as a string, these arguments including the command itself or the .exe file name are stored in an array of char pointers, each pointer points to the first character of a string (i.e., argument). The inputs can...

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

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