C program to convert temperature from degree fahrenheit to celsius and kelvin - IProgramX

Q. C Program - Accept temperatures in Fahrenheit (F) and print it in Celsius (C) and Kelvin (K)


Program

#include<stdio.h>
#include<conio.h>
int main()
{
float cel,fer,kel;

printf("Enter Temperature in Fahrenheit :");
scanf("%f",&fer);

cel= (fer-32)/1.8 ;
printf("Celsius = %f \n",cel);

kel = (fer-32)/1.8 + 273.15 ; 
printf("Kelvin  = %f \n",kel);

return (0) ;
}

Output:
Enter Temperature in Fahrenheit :56
Celsius = 13.333333
Kelvin  = 286.483337

Post a Comment

5 Comments

  1. # 6 : Remove Punctuation

    import string

    text = input("Enter a text: ")

    clean_text = ""

    for ch in text:
    if ch not in string.punctuation:
    clean_text += ch

    print("\nOriginal Text:", text)
    print("Text without punctuation:", clean_text)

    ReplyDelete
  2. # 7 : Remove Extra Spaces

    text = input("Enter a sentence with extra spaces: ")

    clean_text = " ".join(text.split())

    print("\nBefore: [" + text + "]")
    print("After : [" + clean_text + "]")

    ReplyDelete
  3. # 8 : Search for a Word

    sentence = input("Enter a sentence: ")
    word = input("Enter the word to search: ")

    words = sentence.lower().split()

    if word.lower() in words:
    print("\nThe word '" + word + "' is FOUND in the sentence.")
    print("Number of times it appears:", words.count(word.lower()))
    else:
    print("\nThe word '" + word + "' is NOT FOUND in the sentence.")

    ReplyDelete
  4. # 9 : Count Sentences

    import re

    paragraph = input("Enter a paragraph: ")

    parts = re.split(r"[.!?]+", paragraph)
    sentences = []

    for part in parts:
    if part.strip() != "":
    sentences.append(part.strip())

    print("\nNumber of sentences:", len(sentences))

    for i, sentence in enumerate(sentences, 1):
    print(str(i) + ". " + sentence)

    ReplyDelete
  5. # 10: Replace a Word

    sentence = input("Enter a sentence: ")
    old_word = input("Enter the word to replace: ")
    new_word = input("Enter the new word: ")

    new_sentence = sentence.replace(old_word, new_word)

    print("\nOriginal Sentence:", sentence)
    print("Updated Sentence :", new_sentence)

    ReplyDelete