que-write a program to input a number till user want of the end it should display the count of positive,negative & zero.
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
int nc,zc,pc;
char ch='y';
clrscr();
pc=0;
zc=0;
nc=0;
while(ch=='y'||ch=='Y')
{
printf("\nEnter any no.");
scanf("%d",&n);
if(n<0)
nc=nc+1;
if(n==0)
zc=zc+1;
if(n>0)
pc=pc+1;
printf("\nDo you want to continue?");
printf("\nif yes then press 'y'");
scanf("%c",&ch);
}
printf("\nno.of -ve no.=%d",nc);
printf("\nno. of zero=%d",zc);
printf("\nno. of+ve no.=%d",pc);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
int nc,zc,pc;
char ch='y';
clrscr();
pc=0;
zc=0;
nc=0;
while(ch=='y'||ch=='Y')
{
printf("\nEnter any no.");
scanf("%d",&n);
if(n<0)
nc=nc+1;
if(n==0)
zc=zc+1;
if(n>0)
pc=pc+1;
printf("\nDo you want to continue?");
printf("\nif yes then press 'y'");
scanf("%c",&ch);
}
printf("\nno.of -ve no.=%d",nc);
printf("\nno. of zero=%d",zc);
printf("\nno. of+ve no.=%d",pc);
getch();
}
No comments:
Post a Comment