void main ()
{
int a;
clrscr ();
printf ("Enter the value of A: ");
scanf("%d",&a);
if (a>=0)
{
printf ("Number is Positive");
}
else
{
printf("Number is Negative");
}
getch ();
}
Free C programs with output, C++ (C plus plus), programs c programming language, object oriented programming, c programs codes, c program shortcuts, history of c programming language, c programming compilers
WAP to find out Total Bill with discount according to conditions (Ternary Operators)
void main ()
{
int b,dis,n;
clrscr ();
printf ("Enter Bill: ");
scanf ("%d",&b);
dis=(b<500)?(b*.10):(b>=500 && b<1000)?(b*.15):(b>=1000 && b<=2000)?(b*.20):(b*.25);
n=b-dis;
printf ("Net Bill is %d",n);
getch();
}
WAP to find out Bigger & Equal number from three numbers
(Ternary Operators)
void main ()
{
int a,b,c;
clrscr ();
printf ("Enter the value of A: ");
scanf("%d",&a);
printf ("Enter the value of B: ");
scanf ("%d",&b);
printf ("Enter the value of C: ");
scanf ("%d",&c);
(a>b && a>c)?printf("A is Big"):(b>a && b>c)?printf("B is Big"):(a==b && b==c)?printf("All are Eqaul"):printf("C is Big");
getch ();
}