What's new

Closed help for upcoming test

Status
Not open for further replies.

glide0227

Enthusiast
Joined
May 19, 2015
Posts
6
Reaction
0
Points
62
Age
31
#include<stdio.h>
#include<conio.h>
main()
{
clrscr();
int x,n,num,sum=0,L,H=0,odd=0,even=0;
printf("Enter number of INTEGERS:");
scanf("%d",&n);
if(n>0)
{
for(x=1;x<=n;x++)
{
printf("Enter INTEGER NO #%d:",x);
scanf("%d",&num);
sum+=num;
if(num%2==0)
even++;
else
odd++;
if(num<L)
L=num;
if(num>H)
H=num;
}
printf("\nNUMBER OF INTEGERS INPUTERD:%d\n",n);
printf("SUM=%d\n",sum);
printf("LOWEST NUMBER=%d\n",L);
printf("HIGHEST NUMBER=%d\n",H);
printf("ODD NUMBERS=%d\n",odd);
printf("EVEN NUMBERS=%d\n",even);
}
else
{
printf("Please enter a number more than zero next time!");
}
getch();
return 0;
}

nagana nmn sya.. pro kpg nag-input ng negative numbers ndi madetect ang highest..

salamat s tutulong
 
kung negative numbers input s program 0 ang result.. ang gusto ko mangyari pti highest kht negative mkukuha
 
Naka initialize kasi ang H mo sa 0. So pag negative ang number di magchange ang value ng H.
Ang gawin mong initial value ng H at L is ung first na integer. So icheck mo if x == 1, if true,
iassign mo ang value ng H at L as num. Else icompare mo.
 
Dear glide0227,

Since 2 years have passed since the last reply in this thread, I am locking it to prevent necroposting. Feel free to start a new thread or contact any forum staff if you want this to be reopened.

Thread closed.
 
Status
Not open for further replies.
Back
Top