Below
is a program enter any integer either positive, negative or zero upto
so many times you want and when you've to stop then enter 01.
The program will count number of positive,negative and zeros among the numbers you've given in your program.
#include "stdio.h"
#include "stdlib.h "
main() {
int p=0,q=0,z=0,*pt;
while(1) {
printf("note : press 01 to exit \n Enter any number : ");
pt=(int*)malloc(1*2);
scanf("%d",pt);
if(*pt==01)
break;
if(*pt > 0)
p++;
if(*pt < 0)
q++;
if(*pt==0)
z++;
}
printf("you have entered \n positive = %d , negative = %d , zeros = %d",p,q,z);
}
No comments:
Post a Comment