Computer for SEE and NEB

It is a complete SEE and NEB solution for computer science. It includes Computer Fundamentals, Database (SQL), Programming in C QBASIC, CSS, JavaScript, and PHP for beginners.

Breaking

Post Top Ad

Your Ad Spot

Friday, September 30, 2022

C program to calculate the simple interest using user define function

 C program to calculate the simple interest using user define function



C program to calculate the simple interest using user define function




Introduction:

C is a popular programming language that is widely used for system programming, embedded systems, and other applications. One of the most basic programs that can be written in C is to calculate the simple interest on a given amount. Simple interest is the interest calculated on the principal amount, and it is calculated as a percentage of the principal amount. In this article, we will discuss how to write a C program to calculate simple interest using a user define function.

Coding to C program to calculate the simple interest using user define function.

#include<stdio.h>

float interest(int P,float R, int T)

{

     float SI;

     SI=P*R*T/100.0;

     return SI;

}      

int main()

{

     int p,n,i;

     float r,Za;

          printf("Enter Principal Amount : ");

          scanf("%d",&p);

          printf("Enter Rate of interest : ");

          scanf("%f",&r);

          printf("Enter Time  : ");

          scanf("%d",&n);

          Za=interest(p,r,n);

          printf("\nSimple Interest : %.2f\n",Za);

        return 0;

}


Output:





Conclusion:

In conclusion, C is a versatile programming language that can be used to perform a wide range of tasks. Calculating C program to calculate the simple interest using user define function is one such task, and it can be easily accomplished using a function. The C program to calculate simple interest using a function involves defining a function that takes three arguments - the principal amount, the rate of interest, and the time period. The function calculates the simple interest using the formula, and then returns the result to the main program. The main program prompts the user to enter the required information, calls the function to calculate the simple interest, and then displays the result to the user. With a little practice, anyone can learn to write programs in C, and this program is a great way to get started.

You may also read:

No comments:

Post a Comment

Post Top Ad

Your Ad Spot

Pages