Tutorial 6_Q5

Write a function to convert the LKR currency into US dollars. 

#include<stdio.h>
float usvalue(float lkr);
float usvalue(float lkr)
{
float usvalue,oneusdvalueinlkr;
printf("Enter the value of 1 usd in lkr : ");
scanf("%f",&oneusdvalueinlkr);
usvalue = lkr / oneusdvalueinlkr;
return usvalue;
}

int main ()
{
float x;
printf("Enter the value of lkr we need to convert to USD : ");
scanf("%f",&x);
printf("%.2f",usvalue(x));
return 0;


}

0 comments:

Post a Comment