Write a program which reads a sequence of positive real numbers. The program stops when the user fills a negative value and show the maximum of these numbers.


Difficulty level
Video recording
This exercise is mostly suitable for students
#include<stdio.h>
#include<limits.h>

int main()
{
	int N,  max;
    
     max =  INT_MIN;
	
	do{
	    printf("Enter an integer: ");
	    scanf("%d", &N);
	    if(N>=0 && N>max)
	        max = N;
	}while(N>=0);

    printf("Max = %d\n",max);
 
	return 0;
}

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
GCD and LCM