Skip to main content

Find Maximum Value C language Code

Find Maximum Value C language Code


#include <stdio.h>

int main()
{
  int array[100], maximum, size, c, location = 1;

  printf("Enter the number of elements in array\n");
  scanf("%d", &size);

  printf("Enter %d integers\n", size);

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

  maximum = array[0];

  for (c = 1; c < size; c++)
  {
    if (array[c] > maximum)
    {
       maximum  = array[c];
       location = c+1;
    }
  }

  printf("Maximum element is present at location %d and it's value is %d.\n", location, maximum);
  return 0;
}


THANKS FOR READING
 FOLLOW ME

Comments

Popular posts from this blog

Prime Number C language Code | Niks banna

Prime Number C language Code  C language code runs on some text editiors who compile it and run it. here is the code copy it all paste on your .c extension file #include<stdio.h> void main() {     int i,n,t=0; scanf("%d",&n); for(i=2;i<n;i++) {     if(n%i==0)     {         printf("not a prime number");         t=1;         break;     } }     if(t==0)     {         printf("Prime number");     } } THANKS FOR READING FOLLOW ME