Q:

C Program To Find Area of Circle

belongs to collection: Basic C Programming Examples

0

you have to make this program in the following way:

  • C Program To Find Area of Circle (Simple Way)
  • C Program To Find Area of Circle Using Function
  • C Program To Find Area of Circle Using Pointer
  • C Program To Find Area of Circle Using Mirco or #define

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

C Program To Find Area of Circle (Simple Way)

Algorithm

  • Program Start
  • Declare Variables
  • Input Radius From User
  • Calculate Area of Circle
  • Display Result
  • Program End

Program

#include<stdio.h>
void main()
{
float r,aoc;
printf("Enter the radius : ");
scanf("%f",&r);
aoc=3.14*(r*r);

printf("area of circle is : %f",aoc);

}

Output

Enter the radius : 5
area of circle is : 78.500000

C Program To Find Area of Circle Using Function

Algorithm

  • Program Start
  • Declare Variables
  • Input Radius From User
  • Calling Function To Calculate Area of Circle
  • Calculating Area of Circle
  • Display Result
  • Program End

Program

#include<stdio.h>
void areaofCircle(float r)
{
 float aoc;

 aoc=3.14*(r*r);

 printf("area of circle is : %f",aoc);

}
void main()
{
float r;
printf("Enter the radius : ");
scanf("%f",&r);

areaofCircle(r);
}

Output

Enter the radius : 7
area of circle is : 153.860001

 

C Program To Find Area of Circle Using Pointer

Program

#include<stdio.h>
void areaofCircle(float *r, float *aoc)
{
 	*aoc=((3.14)*(*r)*(*r));

}
void main()
{
float r, aoc;
printf("Enter the radius : ");
scanf("%f",&r);

areaofCircle(&r,&aoc);

printf("area of circle is : %f",aoc);

}

Output

Enter the radius : 3
area of circle is : 28.260000

 

C Program To Find Area of Circle Using Micro or #Define

Program

//C Program To Find Area of Circle Using Micro or #Define

#include<stdio.h>
#define pi 3.14
void areaofCircle(float r)
{
 float aoc;

 aoc=pi*(r*r);

 printf("area of circle is : %f",aoc);

}
void main()
{
float r;
printf("Enter the radius : ");
scanf("%f",&r);

areaofCircle(r);
}

Output

Enter the radius : 10
area of circle is : 314.000000

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Basic C Programming Examples

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C Program To Find Area of Square... >>
<< C Program To Find Largest And Smallest Number Amon...