Vous êtes sur la page 1sur 2

ASSIGNMENT 1

Problem 1
#include <stdio.h>
int main()
{
char name[100];
printf("HELLO");
printf("\nWHAT'S YOUR NAME?");
scanf("%s",name);
printf("\nWELCOME %s",name);
printf("\nLET'S BE FRIENDS!");
return 0;
}

Problem 2
#include <stdio.h>
int main()
{
float fah,cel;
printf("Enter the temperature in degree Fahrenheit : ");
scanf("%f",&fah);
cel=(5*(fah-32))/9;
printf("\nThe temperature in degree Celsius : %f",cel);
return 0;
}

Problem 6
#include <stdio.h>
int main()
{
int time,hh,mm,ss;
printf("Enter the time in seconds : ");
scanf("%d",&time);
ss=time%60;
hh=time/3600;
mm=(time-(hh*3600))/60;
if(hh>=0&&hh<=9)
{
if(mm>=0&&mm<=9)
{
if(ss>=0&&ss<=9)
printf("The time is 0%d:0%d:0%d",hh,mm,ss);
else
printf("The time is 0%d:0%d:%d",hh,mm,ss);
}
else
{
if(ss>=0&&ss<=9)
printf("The time is 0%d:%d:0%d",hh,mm,ss);
else
printf("The time is 0%d:%d:%d",hh,mm,ss);
}
}
else
{
if(mm>=0&&mm<=9)
{
if(ss>=0&&ss<=9)
printf("The time is %d:0%d:0%d",hh,mm,ss);
else
printf("The time is %d:0%d:%d",hh,mm,ss);
}
else
{
if(ss>=0&&ss<=9)
printf("The time is %d:%d:0%d",hh,mm,ss);
else
printf("The time is %d:%d:%d",hh,mm,ss);
}
}
return 0;
}

Vous aimerez peut-être aussi