Question

In: Computer Science

You will be writing the function definition and the main function with the function call. Be...

You will be writing the function definition and the main function with the function call.

Be sure to write the function definition below the main function.

The function prototype has been provided, you may add the prototype to you answer.

You do not need to add the preprocessor directives like #include<stdio.h>.

Write the function definition for UpdateGrade . The function will take two arguments, a double called originalGrade a pointer to a double called newGradePtr.

This function will have a void return type.

Inside the  UpdateGrade function:

  • Declare, ask, and get the number of points to be added to the original grade
  • Add the bonus points to the original grade
  • Store the result in the "value at" newGradePtr

In the main function

  • Declare the local variables(grade, updatedGrade).
  • Ask and get the original grade and pass the grade (by copy) and pass the "address of" the updatedGrade.
  • Print the updatedGrade onto the screen

#include<stdio.h>

//function prototypes

void UpdateGrade(double originalGrade, double *newGradePtr);

in C programming language

Solutions

Expert Solution

Only Function Definition is given below:

(Explanation is given in the form of comments)

//Function Definition
void UpdateGrade(double originalGrade, double *newGradePtr){
// variable declared ask
double ask;

//taken input from the user to add number of points to be added in original grade
printf("\nEnter the number of points to be added to the original grade:");
scanf("%lf",&ask);

//upgraded the value of the variable whose address is stored in newGradePtr
*newGradePtr = ask + originalGrade;
}

--------------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------

Complete Program (is given below) :

-------------------------------------------------------------------------------------------------------

void UpdateGrade(double originalGrade, double *newGradePtr);

int main(){
//two local variables declared i.e. grade and updatedGrade
double grade, updatedGrade;

// taken input from the user
printf("Enter the original grade:");
scanf("%lf",&grade);

//called the function UpdateGrade and passed the arguments
//first argument is grade
//second argument is updatedGrade and its address is passed
UpdateGrade(grade,&updatedGrade);

//below statement prints the updated grade
printf("\nThe updatedGrade is %lf",updatedGrade);

return 0;
}

//Function Definition
void UpdateGrade(double originalGrade, double *newGradePtr){
// variable declared ask
double ask;

//taken input from the user to add number of points to be added in original grade
printf("\nEnter the number of points to be added to the original grade:");
scanf("%lf",&ask);

//upgraded the value of the variable whose address is stored in newGradePtr
*newGradePtr = ask + originalGrade;
}

-------------------------------------------------------------------------------------------------------------------------

Sample Output:


Related Solutions

In C Write a main function with a function call to a function called GetLetter which...
In C Write a main function with a function call to a function called GetLetter which has two double arguments/parameters. The function returns a character. Declare and initialize the necessary data variables and assign values needed to make it executable and to prevent a loss of information
1) Within the main function, the call to the constructor by defense of a class called...
1) Within the main function, the call to the constructor by defense of a class called MyClass is made by creating the firstClass object as follows. A) MyClass firstClass; B) MyClass firstClass (8); C) MyClass () firstClass; D) MyClass firstClass ();
C++ Recursive Functions: Please call functions in a main function as well. 1. A recursive function...
C++ Recursive Functions: Please call functions in a main function as well. 1. A recursive function that print the reverse of a string. (e.g., void printReverse(string exp)). For example, if exp =”coding”, then the function should print out “gnidoc”. 2. Implement a non-recursion-based binary search function. Convert this function into a recursion-based function. 3. Implement a recursive and non-recursive Fibonacci function.
JavaScript Programming Assignment PLEASE NOTE:  You must create and call a main function, and if instructed include...
JavaScript Programming Assignment PLEASE NOTE:  You must create and call a main function, and if instructed include additional functions called by the main. Make sure to use ES6 style of keywords => instead of the older function and for local scope variables use the keyword let and not a keyword var. Make sure to follow the requirements and recheck before submitting. PROJECT GOAL: Assume that hot dogs come in packages of 10, and hot dog buns come in packages of 8....
JavaScript Programming Assignment PLEASE NOTE:  You must create and call a main function, and if instructed include...
JavaScript Programming Assignment PLEASE NOTE:  You must create and call a main function, and if instructed include additional functions called by the main. Make sure to use ES6 style of keywords => instead of the older function and for local scope variables use the keyword let and not a keyword var. Make sure to follow the requirements and recheck before submitting. PROJECT GOAL: Create a program that simulates tossing a coin. This program should be titled flippingacoin.js and will require you...
GIVE A DEFINITION. PLEASE BE CLEAR OF WHICH YOU ARE DEFINING BY WRITING THE WORD NEXT...
GIVE A DEFINITION. PLEASE BE CLEAR OF WHICH YOU ARE DEFINING BY WRITING THE WORD NEXT TO THE DEFINITION INFERENTIAL STATISTICS OBSERVATIONAL STUDY EXPERIMENTAL STUDY DESCRIPTIVE STATISTICS DISCRETE VARIABLES CLUSTER SAMPLING STATISTIC SAMPLE CONVENIENCE SAMPLING RANDOM SAMPLING STRATIFIED SAMPLING MULTISTAGE SAMPLING QUANTITATIVE DATA QUALITATIVE DATA PARAMETER POPULATION
The following task does not involve writing program code: instead, you will be writing function signatures...
The following task does not involve writing program code: instead, you will be writing function signatures for hypothetical functions (you will be defining functions in subsequent tasks). For this task, you are presented with several 'hypothetical' functions. These aren't built-in Python functions: they are functions that you will have to define (i.e. implement, write) yourself later. however, you only need to write a signature for each hypothetical function listed here: toThePower(): takes two numbers e.g. x and y , and...
Code programs using ReadlineSync for prompts. Note: For all programs, create and call a main function,...
Code programs using ReadlineSync for prompts. Note: For all programs, create and call a main function, and if required additional functions called by the main. Also please use the ES6 style of keywords => instead of the older function and for local scope variables use the keyword let, not var triangle.js Write a program that is required to use nested loops to generate a triangle as shown in the sample run below. The program should begin by prompting the user...
Code programs using ReadlineSync for prompts. Note: For all programs, create and call a main function,...
Code programs using ReadlineSync for prompts. Note: For all programs, create and call a main function, and if required additional functions called by the main. Also please use the ES6 style of keywords => instead of the older function and for local scope variables use the keyword let, not var Name: coinflip.js For this program you will have two functions, one called main and the second called flip. This program is also required the use of a loop construct. Write...
Code programs using ReadlineSync for prompts. Note: For all programs, create and call a main function,...
Code programs using ReadlineSync for prompts. Note: For all programs, create and call a main function, and if required additional functions called by the main. Also please use the ES6 style of keywords => instead of the older function and for local scope variables use the keyword let, not var Name: cookout.js Assume that hot dogs come in packages of 10, and hot dog buns come in packages of 8. Write a program called cookout.js, that calculates the number of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT