C Program
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;
- a, b, c: To store the three input numbers.
- s: To store the sum of the numbers.
- 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);
- input to the user and stores it in variable a.
- %d specifies that the inputs is an integer.
- & 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
Related Post :-
No comments:
Post a Comment