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);
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
area in sq.m=8.000000
enter cost of flooring per square in Rs.: 5
total cost in Rs.=40.000000
కామెంట్లు
కామెంట్ను పోస్ట్ చేయండి
దయచేసి మీ సలహాలను సూచనలను స్పష్టంగా పేర్కొనగలరు. plz see that ur comments are 'acceptable' in a value based society.