ad

Thursday, March 6, 2025

C Program find Sum and Average of the Three Number

                                    C Program 

C Program find Sum and Average of the Three Number

 C Program find Sum and Average of the Three Number

Examples :-    


#include<stdio.h>

void main()
{
int a,b,c,s,v;

printf("Enter First Number:");
scanf("%d",&a);
printf("Enter Second Number:");
scanf("%d",&b);
printf("Enter Third Number:");
scanf("%d",&c);
s
=a+b+c;
printf("sum of given Numbers is %d\n",s);
v
=s/3;
printf("Average of given Number is %d",v);

}


Explain Program

Step :1

#include<stdio.h>

  •  use functions like printf() and scanf().

Step :2

void main()

  • Defines the main function

Step :3

int a, b, c, s, v;

  1. a, b, c: To store the three input numbers.
  1. s: To store the sum of the numbers.
  1. v: To store the average of the numbers.

Step :4

printf ("Enter First Number");

  • Displays a message  user to enter the first number.

Step :5

scanf("%d", &a);

  1.  input to the user and stores it in variable a.
  2. %d  specifies that the inputs is an integer.
  3. & a is the address of variable a

Step :6

s = a + b + c;

  • Add the three integer and stores the result in s.

Step :7

printf ("Sum of given Number  %d\n", s);

  • Prints the calculated sum using %d 

Step :8

v =  s / 3;

Divides the sum by 3 to find the average.

Step :9

printf("Average of given Numbers is %d", v);

  • Prints the calculated average.

C Program find Sum and Average of the Three Number

 Program Output 

C Program find Sum and Average of the Three Number


Related Post :-

javascript logical operator

php program to print alphabet pattern l

Css padding property

No comments:

Post a Comment