/*Problem: Write a program that finds the smallest of several integers. Assume t
ID: 3624218 • Letter: #
Question
/*Problem: Write a program that finds the smallest of several integers. Assumethat the first value read specifies the number of values remaining.
WHAT IS WRONG WITH THE PROGRAM?*/
#include <stdio.h>
int main (void)
{
int x;
int y;
int i;
int small;
int large;
printf("Enter a count number: ");
scanf("%d",&x);
printf("x= %d ",x);
for (i=1; i<=x; i++)
{
printf(" Enter a number: ");
scanf("%d",&y);
y=small;
}
if(y>small)
{
small=y;
printf("Smallest number: %d ",small);
}
return 0;
}
I cant get this to work right..Help!
Explanation / Answer
please rate - thanks
#include <stdio.h>
int main (void)
{
int x;
int y;
int i;
int small;
int large;
printf("Enter a count number: ");
scanf("%d",&x);
printf("x= %d ",x);
printf(" Enter a number: ");
scanf("%d",&small);
for (i=1; i<x; i++)
{
printf(" Enter a number: ");
scanf("%d",&y);
if(y<small)
small=y;
}
printf("Smallest number: %d ",small);
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.