, Normal Title No S CNIT 105 In Lab04 Due: By the end of your lab session OBJECT
ID: 3881903 • Letter: #
Question
, Normal Title No S CNIT 105 In Lab04 Due: By the end of your lab session OBJECTIVES: Selection Arithmetic in C Instructions Write a C program to do the following tasks. Declare all the variables in the maia) function. Declare the required variables to store three whole numbers, Declare other variables as needed. Prompt the user to enter three whole numbers. Read them into variables, n1, n2, n3 Display the numbers to the screen in a clear format. Determine whether n1 is negative or not. Calculate the average of 3 whole numbers, store it in a variable. o Display the average with 2 digits after the decimal point. Compare n1 to n2, and print whether n1 is smaller, bigger or equal to n2 Screen Capture: CFall 2017105Un LabsIn Lab Solutions)DebugtUn Lab Soutions.exe Enter thre whole numbere: -312 20 Uariable Ualue nun nun2 num3 12 20 nunt is negative. The verage of three nueber nun2 is bigger than nu Submission: 1. Login to Blackboard and choose CNIT 105. Find the submission link for in Lab04 and click on it. 2. Submit the source file In Lab04.c to Blackboard. 3. Don't forget the intro comments glish (US) (A) OExplanation / Answer
#include<stdio.h>
int main() {
double n1,n2,n3;
printf("Enter three whole number: ");
scanf("%lf",&n1);
scanf("%lf",&n2);
scanf("%lf",&n3);
printf(" Variables Values");
printf(" ***********************");
printf(" num1 %.02f", n1);
printf(" num2 %.02f", n2);
printf(" num3 %.02f", n3);
if(n1<0)
{
printf(" num1 is negative.");
}
else
{
printf(" num1 is positive.");
}
double n4=(n1+n2+n3)/3;
printf(" The average of three number is: %0.2lf", n4);
if(n1>n2)
{
printf(" num1 is bigger tha num2.");
}
else
{
printf(" num2 is bigger tha num1.");
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.