100% prog to call a user defined function from another user defined function

/* prog to demonstrate calling a user defined function from within another user defined function */

#include <stdio.h>
void price(float);//function prototyping 
void area(float p,float q) // defining 1st function area()
{
  float area_in_sqm;
  area_in_sqm=p*q;
  printf("\n area in sq.m=%f",area_in_sqm);
  price(area_in_sqm);
}
void price(float a) // defining 2nd function  price()
{
    float cpsqm; // cost per square meter
    printf("\n\n enter cost of flooring per square  in Rs.: ");
    scanf("%f",&cpsqm);
    printf("\n\n total cost in Rs.=%f",a*cpsqm); //a is area in sq. meter
}
void main()
{
  float l,b;
  printf("\n enter length and breadth in SI units i.e., meter:");
  scanf("%f%f",&l,&b); //the dimensions need not be integers but can be float as well
  area(l,b);
}

ఔట్పుట్ తెరమీద
enter length and breadth in SI units i.e., meter:4 2
area in sq.m=8.000000

 enter cost of flooring per square  in Rs.: 5
 total cost in Rs.=40.000000

కామెంట్‌లు

ఈ బ్లాగ్ నుండి ప్రసిద్ధ పోస్ట్‌లు

100% C prog to write content into a file and then read it back onto the console

Spic macay

శ్రీరస్తు.. రామలింగ 18-1-24 (సూరసాని వారి ఆహ్వానము)