C program to convert temperature from Celius to fahrenhiet and vice versa

This is the program that have been made with the basic knowlegde of C.So obviously don't requires any advanced knowledge of C.

//WAP TO CONVERT TEMPERATURE FROM CELCIUS TO FAHRENHIET AND VICE VERSA.
#include <stdio.h>
#include<stdlib.h>
#include <conio.h>
flag=1;
void c2f(float);
void f2c(float);                              //FUNCTION declaration
void worker(void);
int main()
{
    worker();                                  //CALLING WORKER FUNCTION
    return 0;
}
void worker(void)
{
    int i;
    float tem;
    printf("\n\t\t\t\tCONVERSION MENU\n\n");
    printf(" 1.CELSIUS TO FAHRENHIET");
    printf("\t\t2.FAHRENHIET TO CELSIUS");               //CONVERSION MENU
    printf("\t\t3.EXIT");
    printf("\n\n\t\t\t   ENTER '1' OR '2' or '3':" );     //TAKING PERMISSION
    while(flag)
    {
    scanf("%d",&i);
if(i==1)                                        //
    {
        printf("\nEnter the TEMPERATURE in CELSIUS:");
        scanf(" %f",&tem);
    }
    else if(i==2)

        {
        printf("\nEnter the TEMPERATURE in FAHRENHIET:");
        scanf(" %f",&tem);
    }

     if(i==1)
            c2f(tem);
     else if(i==2)

     {

        f2c(tem);
    }
    if(i!=1&&i!=2&&i!=3)
    {
        printf("\n\t\t\t\tINVALID ENTRY");
        printf("\n\t\t\t  PLEASE ENTER A VALID ENTRY");
        printf("\n\t\t \t  ENTER '1' OR '2' or '3':" );
    }
    else
        flag=0;
}
}
void c2f(float c)
{
    char y;
    printf("\nTEMPERATURE in FAHRENHIET: %.2f",(float)9/5*c+32.0);
    getch();
    system("cls");
    printf("DO YOU WANT TO CONVERT AGAIN(ENTER Y/N): ");
    scanf("%c%c",&y,&y);
    system("cls");
    if(y=='y'||y=='Y')
        {
          worker();
        }
    else if(y=='N'||y=='n')
        flag=0;
    worker();

}
void f2c(float f)
{
    char y;
    printf("\nTEMPERATURE in CELCIUS: %.2f",(float)(f-32.0)*5/9);
   getch();
   system("cls");
   printf("DO YOU WANT TO CONVERT AGAIN(ENTER Y/N): ");
    scanf("%c%c",&y,&y);
    system("cls");
    if(y=='y'||y=='Y')
        worker();
    else if(y=='N'||y=='n')
        flag=0;
    worker();
}




Comments