#include<stdio.h>
// Author- Khadiza Sultana
// 10/8/2024
//Finding the largest number with the help of loop
int main()
{
double number = 0, largest = 0; // initialization is done
for(;;)
{
printf("Enter the number:");
scanf("%lf", &number);
if(number <= 0)
break; // when zero or negative number then the infinite loop is broke
if(number > largest)
largest = number; // storing the largest number after comparing
}
printf("\nThe largest number is %g\n", largest);
return 0;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter