Program to evaluates a function.

Program that will read the value of x and evaluate the following function y=1 for x>0
y=0 for x=0
y=-1 for x<0

#include <stdio.h>
fun (int x)
{ if(x>0) return (1);
else if(x==0) return (0);
else return (-1);
}
main()
{ float x;
int y;
printf("\nEnter the value of X::");
scanf("%f",&x);
y=fun(x);
printf("\ny=%d",y);
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s