Im trying to determine the highest and the lowest number from the series of numbers input by using control structures.
im ok with the highest but im having a problem when it comes to lowest. here is the code.
my lowest ( c ) its value is always -29291
if i declare it as c = 0; its output will always be 0.
hope you cn explain me with this. thanks in advance
#include<stdio.h>
#include<conio.h>
void main()
{
loop:
int c,x,y,z,a=0;
char yesno;
x=0;z=0;
clrscr();
printf("\nEnter Range:");
scanf("%d",&x);
for(y=1; y<=x; y++)
{
printf("\nEnter a Number:");
scanf("%d",&z);
if(z>=a)
{
a=z;
}
if(z<=c)
{
c=z;
}
}
printf("\nHighest is:%d",a);
printf("\nLowest is:%d",c);
printf("\nTry Again?[Y/N]:");
yesno=getche();
if(yesno=='Y' || yesno=='y')
goto loop;
else if(yesno=='N' || yesno=='n')
getch();
}

New Topic/Question
Reply




MultiQuote







|