Skip to main content

C program to calculate area of a circle using function.

C program to calculate area of a circle.


In this example we will learn to calculate the area of a circle. Here in this program we will use 3.14 as the value of pi. 

  • The formula to calculate the area of a circle is:

                                            area= π r²


Flowchart To Calculate the Area of a Circle:

Flowchart To Calculate the Area of a Circle:


PROGRAM:

#include<conio.h>
#include<stdio.h>
int main()
{
    float radius,area;
    printf("Enter the radius of the circle : ");
    scanf("%f",&radius);
    area=3.14*radius*radius;    
    printf("Area of the circle is : %.2f",area);
    return 0;
}


OUTPUT:




C program to calculate area of a circle using function.

        Here, we will learn how to calculate the area of a circle using function.


Program:

#include<conio.h>
#include<stdio.h>
float circle(float);
int main()
{
    float radius,area;
    printf("Enter the radius of the circle : ");
    scanf("%f",&radius);
    circle(radius);
    return 0;
}
float circle(float r)
{
    float area;
    area=3.14*r*r;    
    printf("Area of the circle is : %.2f\",area);
}



Output:

    
            
NOTE:                        
        You Can post your code in our comment section. Your comment will be approved if your code is different from the code posted above. Thank You.

MOTTO: You Learn, I Learn Together We Learn


Comments

Popular posts from this blog

C Program to Print first N Even Natural Number/in Reverse Order

  C Program to Print first N Even Natural Number.     In this example, we will find and print the first N even natural. Here we have used for loop to solve this program.      What are Natural Numbers? Natural Numbers are all positive numbers starting from 1 to infinity.      For Example:  1,2,3,4,5,6,.............................,n are all natural numbers. What are Even Numbers? Even numbers are those numbers whose remainder is 0 when divided by 2.     For Example: 2,4,6,8,10,.....,n are all even numbers.   PROGRAM: #include <stdio.h> #include <conio.h> void   main () {      int   i , x ;      printf ( "Enter the value of N : " );      scanf ( " %d " ,& x );      for ( i = 1 ; i <= x ; i ++)     {          printf ( " %d " , 2 * i );     }      getch (); } OUTPUT: C Program to Print First N Even Natural Number in Reverse Order. PROGRAM 123 #include <conio.h> #include <stdio.h> int   main () {      int   i , x ;      printf

C Program to Generate and Print Fibonacci series upto a given inputted number

 C Program to Generate and Print Fibonacci series upto a given inputted number     In this example, we will generate and print fibonacci series upto a the upper limit entered by the user. To solve this problem we should have a proper concept on Fibonacci series and while loop.  What is a Fibonacci Series? Fibonacci series is the sum of the two preceding numbers, starting from 0 and 1.     For Example: 0,1,1,2,3,5,8,13,....,etc  PROGRAM #include <stdio.h> #include <conio.h> void   main () {      int   n , x1 , x2 , x3 = 0 ;      printf ( "Enter the limit upto which fibonacci series to be generated : " );      scanf ( " %d " ,& n );      x1 = 0 ;      x2 = 1 ;      printf ( " %d \t %d " , x1 , x2 );      x3 = x1 + x2 ;      while ( x3 <= n )     {          printf ( " \t %d " , x3 );          x1 = x2 ;          x2 = x3 ;          x3 = x1 + x2 ;     }      getch (); } OUTPUT: Enter the limit upto which fibonacci series to be g