The Program is to be compiled on C Write a single program that computes the valu
ID: 3533755 • Letter: T
Question
The Program is to be compiled on C
Write a single program that computes the value of the following expressions using loop statements. Read the value of n from the user and compute the left hand side using the specified loop. Use the formula on the right on the right hand side to test the result. Use the same value of n for computation of all the results and display the results. Compute the following using a for loop 1 * 2 + 2 *3 ++ n * (n-1) = i(I + 1) = n(n + 1)(n + 2)/3 Compute the following using a while loop 1/1 * 2 + 1/2 * 3 +..1/n * (n + 1) = 1/i(I + 1) = 1 - 1/n + 1 Compute the following using a do - while loop 1/2 + 1/22++ 1/2n = 1/2i = 1 - 1/2n Sample execution of the program is given below Enter n: 7 For Loop Loop Result = 168 Formula = 168 While Loop Loop Result = 0.875000 Formula = 0.875000 Do while Loop Loop Result = 0.992188 Formula = 0.992188Explanation / Answer
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a,b,c;
printf("Input 3 integers: ");
scanf(" %d %d %d", &a, &b, &c);
if( (b+c) == a || (a+b) == c || (a+c) == b ){
printf("Sum of two numbers equals the third number. ");
}
else
printf("Sum of two numbers does not equal the third number. ");
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.