Answer to Question #198926 in C for Karthik

Question #198926

Take 3 values find out average of three values check with result is less than 500 and result is greater than 500


1
Expert's answer
2021-05-26T07:23:56-0400
#include <stdio.h>

int main()
{
    int a, b, c;
    float average;
    
    printf("Enter 3 integers: ");
    if(scanf("%d %d %d", &a, &b, &c) != 3)
    {
        printf("Bad input\n");
        return 1;
    }

    average = (float)(a + b + c) / 3;
    
    printf("Average: %f\n", average);

    if(average < 500)
    {
        printf("Average is less than 500\n");
    }
    else
    if(average > 500)
    {
        printf("Average is greater than 500\n");
    }
    
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS