WAP, Write a C or C++ Program to convert the given temperature in Fahrenheit to Celsius using the conversion formula with output, WAP for temperature converter
Program
#include<stdio.h>
#include<conio.h>
void main()
{
float c,f;
clrscr();
printf("Enter the temperature in Fahrenheit");
scanf ("%d", &f)
c= (f-32)*1.8
printf ("The temperature in Celsius is:");
printf ("%f", c);
getch();
}
Changes for C++
If you want to write the same program in c++ apply the following changes to the program.
1.) change the header file from "#include<stdio.h>" to "#include<iostream>.h"
2.) for input & output use "cout<<" & "cin>>" instead of "printf" & "scanf".
3.) don't use "% "symbol and "&" sign in "cin>>" statement.
Click here to check the output
Program
#include<stdio.h>
#include<conio.h>
void main()
{
float c,f;
clrscr();
printf("Enter the temperature in Fahrenheit");
scanf ("%d", &f)
c= (f-32)*1.8
printf ("The temperature in Celsius is:");
printf ("%f", c);
getch();
}
Changes for C++
If you want to write the same program in c++ apply the following changes to the program.
1.) change the header file from "#include<stdio.h>" to "#include<iostream>.h"
2.) for input & output use "cout<<" & "cin>>" instead of "printf" & "scanf".
3.) don't use "% "symbol and "&" sign in "cin>>" statement.
Click here to check the output
No comments:
Post a Comment