Calculating     Sum     in         a          Function For       this      part     you      will implement            a          simple function,  called addTwoNumbers(),            that      computes the  sum of two given numbers.         Example of Compilation        and      Execution:   This program will compute the sum of two numbers. Enter the first number: 3 Enter the second number: 2 3 + 2 = 5 Notes: Use      this as main: #include int addTwoNumbers(int, int) ; int main () {    int num1, num2, sum;      printf("This program will compute the sum of two numbers.\n\n") ;    printf("Enter the first number: ") ;    scanf("%d", &num1) ;    printf("Enter the second number: ") ;    scanf("%d", &num2) ;      sum = addTwoNumbers(num1, num2) ;      printf("%d + %d = %d\n", num1, num2, sum);      return 0 ; } /* end of main() function */ Below  the main    program,         write the       C          code to implement the addTwoNumbers() function, giving meaningful names to your parameters. To compute the          sum, use and return a local variable called    sum.  Be sure to use the  “+=” operator in your function.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.2: Returning A Single Value
Problem 13E
icon
Related questions
Question

 

Calculating     Sum     in         a          Function

For       this      part     you      will implement            a          simple function,  called addTwoNumbers(),            that      computes the  sum of two given numbers.        

Example of Compilation        and      Execution:

 

This program will compute the sum of two numbers.

Enter the first number: 3

Enter the second number: 2

3 + 2 = 5

Notes:

Use      this as main:

#include <stdio.h>

int addTwoNumbers(int, int) ;

int main () {

   int num1, num2, sum;

 

   printf("This program will compute the sum of two numbers.\n\n") ;

   printf("Enter the first number: ") ;

   scanf("%d", &num1) ;

   printf("Enter the second number: ") ;

   scanf("%d", &num2) ;

 

   sum = addTwoNumbers(num1, num2) ;

 

   printf("%d + %d = %d\n", num1, num2, sum);

 

   return 0 ;

}

/* end of main() function */

Below  the main    program,         write the       C          code to implement the addTwoNumbers() function, giving meaningful names to your parameters.

To compute the          sum, use and return a local variable called    sum.

 Be sure to use the  “+=” operator in your function.

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Declaring and Defining the Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning