Contact Learn C
Copy

Program 246 : External Storage Class in C

Program 246:  External Storage Class
 
#include<stdio.h>
float pi=3.14159;
void CalcArea(float radius);
void CalcCircumference(float radius);
main()
{
 int choice;
 float radius;
 printf("Enter\n1 to Calculate Area of Circle\n2 to Calculate Circumference\n");
 scanf("%d",&choice);
 printf("Enter radius\n");
 scanf("%f",&radius);
 switch(choice)
 {
  case 1:
  {   
   CalcArea(radius);   
   break;
  }
  case 2:
  {   
   CalcCircumference(radius);   
   break;
  }
  default:
  {
   printf("Enter Valid Choice\n");
   break;
  }
 }
}

void CalcArea(float radius)
{
 float area=pi*radius*radius;
 printf("Area of Circle with %f radius is %f\n",radius,area);
}
void CalcCircumference(float radius)
{
 float circumference=2*pi*radius;
 printf("Circumference of Circle with %f radius is %f\n",radius,circumference);
}

Explanation:
Pre Explanation:- By Default a Global Variable is '0'. And its scope is through out the Program which is why we are able to use 'pi' value even it is not declared under the respective functions as it is declared outside main() function.

//Coming Soon...

Output:

 External Storage Class in C

 External Storage Class using C







 
Donate

Download App and Learn when ever you want

Get it on PlayStore
Get it on Amazon App Store
Get it on Aptoide