Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help please Write a method called smallestLargest that accepts a Scanner fo

ID: 674844 • Letter: N

Question

Need help please Write a method called smallestLargest that accepts a Scanner for the console as a parameter and asks the user to enter numbers, then prints the smallest and largest of all the numbers supplied by the user. You may assume that the user enters a valid number greater than 0 for the number of numbers to read. Here is a sample execution: Write a method called evenSumMax that accepts a Scanner for the console as a parameter. The method should prompt the user for a number of integers, then prompt the integer that many times. Once the user has entered all the

Explanation / Answer

CODE :

#include <stdio.h>
#include <conio.h>
int main()
{
unsigned int smallest,largest,in,buf;
smallest=0,largest=0;

printf(" Enter The Numbers or press Zero to exit....");
do
{
scanf("%u",&in);
if(in!=0)
{
if(in>=largest)
{
largest=in;
}
if(in<=buf)
{
smallest=in;
}
buf=in;
}
else
{
printf("The Largest & Smallest value Entered are : %u %u",largest,smallest);
break;
}
}while(1);
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote