20_10

Write a C program to find the largest element of a given array.

Source code:

 //Write a C program to find the largest element of a given array

#include <stdio.h>

int main() 

{

int j, array[5];

for(j=0;j<5;++j)

{

printf("Enter the value for %d: ",j);

scanf("%d",&array[j]);

}

int i, largest;

    largest = array[0];

   

    for(i = 0; i < 5; i++) 

{

    if( largest < array[i] ) 

        largest = array[i];

   } 

   printf("%d", largest); 

   return 0;

}

Output:
C program to find the largest element of a given array


No comments:

Post a Comment

Write a program in C to convert a decimal number to binary using recursion.

 Source code: //Write a program in C to convert a decimal number to binary using recursion. #include<stdio.h> long convertB_to_D(int d...