Q. write a c program to change Celsius to Fahrenheit and Fahrenheit to Celsius .\
#include<stdio.h>
#include<conio.h>
void main()
{
float n,a,b,f,c;
clrscr();
printf("enter 1 for celsius to fahrennheit\n");
printf("enter 2 for fahrennheit to celsius\n");
scanf("%f",&n);
if (n==1)
{
printf("\nenter the celsius \n");
scanf("%f",&a);
f=a* 9/5+32;
printf("%f",f);
printf("\n Thank you");
}
else if(n==2)
{
printf("\nenter the fahrennheit \n");
scanf("%f",b);
c=(b-32)*5/9;
printf("%f",c);
printf("\n Thank you");
}
else
{
printf("\nyou enter the wrong no");
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
float n,a,b,f,c;
clrscr();
printf("enter 1 for celsius to fahrennheit\n");
printf("enter 2 for fahrennheit to celsius\n");
scanf("%f",&n);
if (n==1)
{
printf("\nenter the celsius \n");
scanf("%f",&a);
f=a* 9/5+32;
printf("%f",f);
printf("\n Thank you");
}
else if(n==2)
{
printf("\nenter the fahrennheit \n");
scanf("%f",b);
c=(b-32)*5/9;
printf("%f",c);
printf("\n Thank you");
}
else
{
printf("\nyou enter the wrong no");
}
getch();
}
thanx it works
ReplyDelete