Python Program
f=0
print ("Celsius","\t", "Fahrenheit")
print ("--------","\t", "----------")
for c in range(0,101,5):
f=(9*c/5)+32
print(c,"\t\t",f)
Python Program Using User Defined Function
def ctof(c):
f=9*c/5+32
return f
#print c - f table
print('Celcius','Fahrenheit',sep='\t:\t')
for c in range(0,101,10):
print(c,ctof(c),sep='\t:\t')
print('Done')
Click below link to watch Video for Practical Explanation
Pascal Program to Print Celsius Fahrenheit table
program CtoFTable;
var
c:integer;
f:real;
begin
writeln('Celsius',#9, 'Fahrenheit');
writeln('------------',#9,'------------');
for c:=0 to 100 do
begin
f:=(9*c/5)+32;
writeln(c,#9,f:8:2);
inc(PInteger(@c)^ ,4);
end;
readln;
end.
Pascal Program Using User Defined Function
program CtoFTable;
{Global Variable}
var
c:integer;
f:real;
{User define function to convert c to f}
function ctof(c:integer):real;
{Local Variable}
var
ff:real ;
begin
ff:=(9*c/5)+32;
ctof:=ff;
end;
{main Program}
begin
writeln('Celsius',#9#9, 'Fahrenheit');
writeln('------------',#9,'------------');
for c:=0 to 100 do
begin
f:=ctof(c);
writeln(c,#9#9,f:8:2);
inc(PInteger(@c)^ ,4);
end;
readln;
end.
Note :
The formula to convert Fahrenheit to Celsius is
c/5=(f-32)/9
No comments:
Post a Comment