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

Finding Average and Grade of Five numbers Coding in C language

Finding Average and Grade of Five numbers Coding in C language #include<stdio.h> void main() {     int a,b,c,d,e,f;     float g;     printf("Please enter any five numbers");     scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);     f=a+b+c+d+e;     printf("%d",f);     printf("\nThis is average of all numbers");     g=f/5.0;     printf("\n%.2f",g);     printf("\nThis is grade of average");         if(g>90)         {             printf("\nA");         }         else if(g>75)         {             printf("\nB");         }         else if(g>60)         {              printf("\nC");   ...

Diamond Coding in C language

Diamond Coding in C language for Beginner #include<stdio.h> void main() {     int i,j,k=9,l=5;     for(i=1;i<=5;i++)     {         for(j=1;j<=k;j++)         {         printf(" ");         }     k--;     for(j=1;j<=i+i-1;j++)     {         printf("*");     }     printf("\n"); }  for(i=1;i<=5;i++)     {         for(j=1;j<=k+1;j++)         {         printf(" ");         }     k++;     for(j=1;j<=l+l-1;j++)     {         printf("*");     }     l--;     printf("\n"); } }