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

Bottle Coding C language

Bottle Coding C language #include<stdio.h> void main() {    int i,j,k;    for(i=1;i<=5;i++)    {        printf("     ");        for(j=1;j<=5;j++)        {            printf("*");        }        printf("\n");     }     k=4;     for(i=1;i<=5;i++)     {         for(j=1;j<=5+5+i;j++)         {             if(j<=k)                 printf(" ");             else                 printf("*");         }         printf("\n");         k--;     }     for(i=1;i<=10;i++)   ...

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  

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");   ...