Wednesday, May 13, 2015

Write a program to read the number until -1 is in encountered, count the sum & negative, positive & zero.

Write a program to read the number until -1 is in encountered, count the sum & negative, positive & zero.


Int main ()
{
Int, n, p=0, ne=0, z=0;
Printf(“/n enter any number -1 to exit );
Scanf (“% d”, & n);
Do
   {
                Printf(“enter any no”);
                Scanf(“ % d” , & n);
                If (n < 0)
                Ne ++;
                Else if (n>0)
                P ++;
                Else
                Z ++;
                Printf(“ entry any no”);
                }
Print (“ no. of negative number =% d, no. of positive No= % d, no. of zero number = % d,ne , p , z);
                 While (n! = -1);
}
Return(0);
                }

No comments:

Post a Comment