current position:Home>Use if or switch statements to implement the following equation

Use if or switch statements to implement the following equation

2022-01-27 00:42:58 CSDN Q & A

use if perhaps switch Statement implements the following equation :
╭ y= 0; x<=0
y=< x+2; 0<x<=50
╰ x-2; 50<x<=100




Refer to the answer 1:

#include<stdio.h>
int main()
{
if(x<=0)
y=0;
else if(x>0&&x<=50)
y=x+2;
else if(x>50&&x<<=100)
y=x-2;

}




Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201270042565618.html

Random recommended