Write a C function which display the value of n is 1 when m is larger than 0, 0 when
m is 0 and -1 when m is less than 0.
Answers
Answer:
#include <stdio.h>
int main()
{
float temp;
printf("What is the temperature outside?");
scanf("%f",&temp);
if(temp < 65)
printf("My but it's a bit chilly out!n");
if(temp >= 65)
printf("My how pleasant!");
return(0);
}
#include <stdio.h>
int main()
{
float temp;
printf("What is the temperature outside?");
scanf("%f",&temp);
if(temp < 65)
{
printf("My but it's a bit chilly out!n");
}
else
{
printf("My how pleasant!");
}
return(0);
}
This code includes all the braces for readability, and the second if statement from the first code example was replaced with else. What happens is that when the if condition is true, statements belonging to if are executed. But when the condition is false, the statements belonging to else are executed instead.