in

Currency Conversion Using C Programming 

currency conversion using c programming
Share this

In this tutorial we are going to look at a simple currency Conversion project using C programming. This article will include the project source code, output and explanation. Below is the source code of the project currency conversion using C programming.

Source Code

/* currency conversion program*/

#include <stdio.h>

#include <math.h>

#include <conio.h>

#include <stdlib.h>

#define dollar 361.00;

#define euros 398.36;

#define ponds 456.66;

#define yens 3.33;

#define francs 362.20;

#define rupees 5.08;

#define rands 24.40;

main()

{

//This is a simple currency converter program that converts the listed currencies below to Naira equivalent

printf(“\n\t\t      ________________________________________\n\n”);

 

printf(“***************************WELCOME TO CURRENCY CONVERTER****************************\n\n”);

printf(“\n\t\t***************************ABOUT***************************\n\n”);

printf(“This is a simple currency converter program that converts the listed currencies below to Naira equivalent\n\n”);

printf(“\n\t\t      ________________________________________\n\n”);

float a,b,c,d,e,f,g,h,usd,euro,pond,yen,franc,rupee,rand,naira;

int x;// switch variable

printf(“\n\t\t***************************MENU***************************\n\n”);

printf(“\n\t\t\n\t\t > 1:Convert US Dollars to Nigeria naira\n\n”);

printf(“\n\t\t\n\t\t > 2:Convert Euros to Nigeria naira\n\n”);

printf(“\n\t\t\n\t\t > 3:Convert Ponds to Nigeria naira\n\n”);

printf(“\n\t\t\n\t\t > 4:Convert Japanese Yen to Nigeria naira\n\n”);

printf(“\n\t\t\n\t\t > 5:Convert Swiss franc to Nigeria naira\n\n”);

printf(“\n\t\t\n\t\t > 6:Convert Indian rupee to Nigeria naira\n\n”);

printf(“\n\t\t\n\t\t > 7:Convert South African rand to Nigeria naira\n\n”);

printf(“\n\t\t\n\t\t > 8.Exit\n”);

printf(“\n\t\t     ________________________________________\n\n”);

printf(“\n\t\t\n\t\t > HOW MAY I HELP YOU?\nEnter your choice:”);

scanf(“%d”,&x);

switch(x)

{

case 1:

printf(“Enter  amount in usd:\n”);

scanf(“%f”,&h);

naira=h*dollar;

printf(“The amount in Nigeria naira is %.2f”,naira);

printf(“\n\n\t********PROGRAM DEVELOPED BY TECHUBWAY********\n\n\n”);

break;

case 2:

printf(“Enter  amount in euro:\n”);

scanf(“%f”,&h);

naira=h*euros;

printf(“The amount in Nigeria naira is %.2f”,naira);

printf(“\n\n\t********PROGRAM DEVELOPED BY TECHUBWAY ********\n\n\n”);

break;

case 3:

printf(“Enter  amount in pond:\n”);

scanf(“%f”,&h);

naira=h*ponds;

 

printf(“The amount in Nigeria naira is %.2f”,naira);

printf(“\n\n\t********PROGRAM DEVELOPED BY TECHUBWAY ********\n\n\n”);

break;

 

case 4:

printf(“Enter  amount in yen:\n”);

scanf(“%f”,&h);

naira=h*yens;

 

printf(“The amount in Nigeria naira is %.2f”,naira);

printf(“\n\n\t********PROGRAM DEVELOPED BY TECHUBWAY ********\n\n\n”);

break;

 

case 5:

printf(“Enter  amount in franc:\n”);

scanf(“%f”,&h);

naira=h*francs;

 

printf(“The amount in Nigeria naira is %.2f”,naira);

printf(“\n\n\t********PROGRAM DEVELOPED BY TECHUBWAY ********\n\n\n”);

break;

 

case 6:

printf(“Enter  amount in rupee:\n”);

scanf(“%f”,&h);

naira=h*rupees;

 

printf(“The amount in Nigeria naira is %.2f”,naira);

printf(“\n\n\t********PROGRAM DEVELOPED BY TECHUBWAY ********\n\n\n”);

break;

 

case 7:

printf(“Enter  amount in rand:\n”);

scanf(“%f”,&h);

naira=h*rands;

 

printf(“The amount in Nigeria naira is %.2f”,naira);

printf(“\n\n\t********PROGRAM DEVELOPED BY TECHUBWAY ********\n\n\n”);

break;

 

case 8:

printf(“Thank You for using the currency converter\n”);

printf(“\n\n\t********PROGRAM DEVELOPED BY TECHUBWAY ********\n\n\n”);

break;

default:

printf(“You have made an Invalid choice”);

 

}

getch();

}

OUTPUT

currency conversion using c programming
currency conversion using c programming
currency conversion using c programming
currency conversion using c programming

EXPLANATION

In this currency conversion project that converts the above listed currencies to Nigerian Naira equivalent. First we started by listing the header files and after that we defined Naira rate of the currencies listed above. This will assign a constant value to the currency to avoid repeating it over and over again. Next we display a welcome note followed by assigning a float data type to the listed currencies. After that we create a menu that will allow users to choose the currency they want to convert and other options like to exit the program. Using switch statement, users can enter the value of currency they want to convert to Naira. Also after that we use break to avoid the program from running another case immediately.  So that’s it, currency conversion using C programming. Hope this article was helpful and don’t forget to comment below.

 

Share this

Comments

Leave a Reply

Loading…

0

Comments

0 comments

Infinix S5

Infinix S5 The First Infinix Punch Hole Camera Phone

WhatsApp New Unlock Feature

WhatsApp New Fingerprint Unlock Feature