Posts

C program to convert days to years weeks and days

Image
  #include <stdio.h> int main ( ) { int days , years , weeks ; /* Input total number of days from user */ printf ( "Enter days: " ) ; scanf ( "%d" , & days ) ; /* Conversion */ years = ( days / 365 ) ; // Ignoring leap year weeks = ( days % 365 ) / 7 ; days = days - ( ( years * 365 ) + ( weeks * 7 ) ) ; /* Print all resultant values */ printf ( "YEARS: %d\n" , years ) ; printf ( "WEEKS: %d\n" , weeks ) ; printf ( "DAYS: %d" , days ) ; return 0 ; }

Program to convert temperature from Celsius to Fahrenheit

Image
  # include <stdio.h> int main ( ) { float celsius , fahrenheit ; /* Input temperature in celsius */ printf ( "Enter temperature in Celsius: " ) ; scanf ( "%f" , & celsius ) ; /* celsius to fahrenheit conversion formula */ fahrenheit = ( celsius * 9 / 5 ) + 32 ; printf ( "%.2f Celsius = %.2f Fahrenheit" , celsius , fahrenheit ) ; return 0 ; }