Write a c program that will read the value of x and evaluate of the following function y=1 for 0>x; 0 for x=0 ;-1 for x<0
Answers
Answered by
3
Answer:
for example
int x=-1;
if(x>0) y=1;
else if (x=0) y=0;
else if (x<0) y=-1;
print(x);
Answered by
0
Concept:
Depending on whether the test expression is true or false,the if...else ladder allows you to check between various test expressions and statements.
Given:
for
for
for
Find:
Write a C program for the given statement.
Solution:
#include <stdio.h>
int main() {
int x, y;
printf("Enter the value of x: ");
scanf("%d",&x);
if
else if
else if
printf("y = %d",y);
return 0;
}
Output:
Enter the value of x: 7
y = 1
Enter the value of x: -15
y = -1
Enter the value of x: 0
y = 0
Similar questions
English,
2 months ago
Math,
2 months ago
English,
4 months ago
Business Studies,
4 months ago
English,
9 months ago