C Program to Find Average of 3, 5 Number

C Program to Find Average of 3, 5 Number

C program to find the average of 3 and 5 numbers; In this tutorial, you will learn how to find the average of 3 and 5 numbers in c.

Programs to Find Average of 3, 5 Number in C

Use the following algorithm to write a program to calculate average of n(3,4,5,etc) numbers in c:

  • Algorithm to find the average of three or five numbers
  • C Program to Find Average of 3 Number
  • C Program to Find Average of 5 Number

Algorithm to find the average of three or 5 numbers

  • Step 1: Start
  • Step 2: Read the three or five numbers from the user.
  • Step 3: Declared a variable “Avg”.
  • Step 4: Calculate the average of 3 or 5 numbers using the followig formulas:
    • avg = (a+b+c)/3;
    • avg = (a+b+c+e+f)/3;
  • Step 5:Display “sum ” and “Avg”.
  • Step 6:End.

C Program to Find Average of 3 Number

#include<stdio.h>
 
int main()
 
{
 
  float a,b,c,avg;
 
  printf("Please enter 3 numbers ");
 
  scanf("%f%f%f", &a, &b, &c);
 
  avg=(a+b+c)/3;
 
 
  printf("\nAverage is  %f",avg);
 
  return 0;
 
}

The output of the above c program; as follows:

Please enter 3 numbers 10 20 30
Average is  20.000000

C Program to Find Average of 5 Number

#include<stdio.h>

int main() {

   float a, b, c, d, e, s, avg;

   printf("Please Enter 5 Numbers :");
   scanf("%f%f%f%f%f", &a, &b, &c, &d, &e);

   s = a + b + c + d + e;

   avg = s / 5;

   printf("\nThe Average is :%f", avg);

   return 0;
}

The output of the above c program; as follows:

Please Enter 5 Numbers :10 20 30 40 50
The Average is :30.000000

Recommended C Programs

AuthorAdmin

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

Your email address will not be published. Required fields are marked *