Write a C program to accept a set of n integers and to calculate the wrong sum and the
correct sum using functions.
Answers
Answer:
here this your answer
Explanation:
make a brilliant
To Find:
C program to accept a set of n integers and to calculate the wrong sum and the correct sum using functions.
Solution:
Here a program has been written in C language which has two functions. One function is for the wrong sum and another is for perfect summation. At first two integers are taken as input from the user then two functions taking two attributes for two numbers are taken.
Lastly in the main function, the whole sum of two integers is placed in num3 and num4 integers and is printed in the console.
#include <stdio.h>
int sum(int a, int b){
return a+b;
}
int not_sum(int a, int b)
{
return a+b+1;
}
int main()
{
int num1, num2, num3, num4;
printf("Enter first number: ");
scanf("%d", &num1);
printf("Enter second number: ");
scanf("%d", &num2);
//Calling the function
num3 = sum(num1, num2);
printf("Sum of the entered numbers: %d\n", num3);
num4 = not_sum(num1, num2);
printf("Wrong sum of the entered numbers: %d", num4);
return 0;
}