একটি array এর মাধ্যমে maximum সংখ্যা বের করার জন্য একটি program লিখ।
Program:
#include<stdio.h>
main()
{
int n, i, max, x[50], p, c=0;
printf("Enter number: N= ");
scanf("%d", &n);
for(i=0; i<n; i++)
{
printf("Enter number for [id %d]= ",i);
scanf("%d", &x[i]);
}
max=x[0];
p=0;
for(i=0; i<n; i++)
{
if(x[i]>max)
{
max=x[i];
p=i;
}
if(x[i]==max)
c++;
}
/*
for(i=0; i<n; i++)
{
if(x[i]==max)
c++;
}
*/
printf("Maximum number is=%d \n Position=%d", max,p);
printf("\n Total max=%d", c);
}
Program:
#include<stdio.h>
main()
{
int n, i, max, x[50], p, c=0;
printf("Enter number: N= ");
scanf("%d", &n);
for(i=0; i<n; i++)
{
printf("Enter number for [id %d]= ",i);
scanf("%d", &x[i]);
}
max=x[0];
p=0;
for(i=0; i<n; i++)
{
if(x[i]>max)
{
max=x[i];
p=i;
}
if(x[i]==max)
c++;
}
/*
for(i=0; i<n; i++)
{
if(x[i]==max)
c++;
}
*/
printf("Maximum number is=%d \n Position=%d", max,p);
printf("\n Total max=%d", c);
}