how this code is wrong ? #finding_max_of_no. ?

#include <stdio.h>

int main()

    int array[50],k, size, i,c, largest;


    scanf("%d", &size);
    for (i = 0; i < size; i++)
	scanf("%d", &array[i]);

    largest = array[0];

    for (i = 1; i < size; i++)
	if (largest < array[i])
		largest = array[i];

    printf("\n%d", largest);
    return 0;


Question link - . Please provide question link from next time.

YOur code is the correct code to find the largest element in each array.

However, in the question you’re trying to do, the size is not the first element of the test case. So array is not input properly. What you have to do is take each line as input in a string, and parse the string to get the integers (in C).
For C++, you can do it in an easier way using stringstream.

You can look at the editorial here. By the way, I feel this problem is hardly of ‘cakewalk’ difficulty level.

This is not necessary .