in turboc++
----------------------------------------------------------------------------------------------------------
//WAp to find greatest number among ten or more numbers. PAss array as parameter. and it returns some value.
#include<stdio.h>
#include<conio.h>
float max_of_array(float array[5],int size);//prototype with array and size parameters
int main()
{
float arr[100];int k; // array declaration with maximum limit 100
int size; // says about size of array to be entered
printf("enter size of array\n");
scanf("%d",&size);//input of size
for(k=0;k<size;k++)//loop execution
{
printf("enter element for location=%d\n",k); // for elements in particular location
scanf("%f",&arr[k]);//data inputs
}
printf("maximum value=%f",max_of_array(arr,size));//calling of function
getch();
return 0;
}
float max_of_array(float array[5],int size)//body line
{
int k;//declaration
int max;
max=array[0];//assigning first value to max.
for(k=0;k<size;k++)//loop execution
{
if(max<array[k])//condition testing
{
max=array[k];//assigning value if the condition is true
}
}
return max;//returning maxmimum element
getch();
}
----------------------------------------------------------------------------------------------------------------------
in codeblocks:
----------------------------------------------------------------------------------------------------------------------
//WAp to find greatest number among ten or more numbers. PAss array as parameter. and it returns some value.
#include<stdio.h>
#include<conio.h>
float max_of_array(float array[5],int size);//prototype with array and size parameters
int main()
{
float arr[100];int k; // array declaration with maximum limit 100
int size; // says about size of array to be entered
printf("enter size of array\n");
scanf("%d",&size);//input of size
for(k=0;k<size;k++)//loop execution
{
printf("enter element for location=%d\n",k); // for elements in particular location
scanf("%f",&arr[k]);//data inputs
}
printf("maximum value=%f",max_of_array(arr,size));//calling of function
return 0;
}
float max_of_array(float array[5],int size)//body line
{
int k;//declaration
int max;
max=array[0];//assigning first value to max.
for(k=0;k<size;k++)//loop execution
{
if(max<array[k])//condition testing
{
max=array[k];//assigning value if the condition is true
}
}
return max;//returning maxmimum element
getch();
}
----------------------------------------------------------------------------------------------------------
//WAp to find greatest number among ten or more numbers. PAss array as parameter. and it returns some value.
#include<stdio.h>
#include<conio.h>
float max_of_array(float array[5],int size);//prototype with array and size parameters
int main()
{
float arr[100];int k; // array declaration with maximum limit 100
int size; // says about size of array to be entered
printf("enter size of array\n");
scanf("%d",&size);//input of size
for(k=0;k<size;k++)//loop execution
{
printf("enter element for location=%d\n",k); // for elements in particular location
scanf("%f",&arr[k]);//data inputs
}
printf("maximum value=%f",max_of_array(arr,size));//calling of function
getch();
return 0;
}
float max_of_array(float array[5],int size)//body line
{
int k;//declaration
int max;
max=array[0];//assigning first value to max.
for(k=0;k<size;k++)//loop execution
{
if(max<array[k])//condition testing
{
max=array[k];//assigning value if the condition is true
}
}
return max;//returning maxmimum element
getch();
}
----------------------------------------------------------------------------------------------------------------------
in codeblocks:
----------------------------------------------------------------------------------------------------------------------
//WAp to find greatest number among ten or more numbers. PAss array as parameter. and it returns some value.
#include<stdio.h>
#include<conio.h>
float max_of_array(float array[5],int size);//prototype with array and size parameters
int main()
{
float arr[100];int k; // array declaration with maximum limit 100
int size; // says about size of array to be entered
printf("enter size of array\n");
scanf("%d",&size);//input of size
for(k=0;k<size;k++)//loop execution
{
printf("enter element for location=%d\n",k); // for elements in particular location
scanf("%f",&arr[k]);//data inputs
}
printf("maximum value=%f",max_of_array(arr,size));//calling of function
return 0;
}
float max_of_array(float array[5],int size)//body line
{
int k;//declaration
int max;
max=array[0];//assigning first value to max.
for(k=0;k<size;k++)//loop execution
{
if(max<array[k])//condition testing
{
max=array[k];//assigning value if the condition is true
}
}
return max;//returning maxmimum element
getch();
}
No comments:
Post a Comment