-->
Showing posts with label WAP to input weight of 100 students and count number of students who have weight in between 40 and 60 kg. Pass Weight as an array as parameter.. Show all posts
Showing posts with label WAP to input weight of 100 students and count number of students who have weight in between 40 and 60 kg. Pass Weight as an array as parameter.. Show all posts

WAP to input weight of 100 students and count number of students who have weight in between 40 and 60 kg. Pass Weight as an array as parameter.

in turboc++
----------------------------------------------------------------------------------------------------------
/*WAP to input weight of 100 students and count number of students who have weight in between 40 and 60 kg.
Pass Weight as an array as parameter.*/
#include<stdio.h>
#include<conio.h>
void total_nu_of_array(float array[200],int size);//prototype with array and size parameters
int main()
{

float arr[200];int k;            // array declaration with maximum limit 200
int size;               // says about size of array to be entered
printf("enter size of array\n");
scanf("%d",&size);//input of size
printf("enter weights of students\n");
for(k=0;k<size;k++)//loop execution
{
   scanf("%f",&arr[k]);//data/weight inputs
}
total_nu_of_array(arr,size);//calling of function
getch();
return 0;
}

void total_nu_of_array(float array[200],int size)//body line
{

int k;//declaration
int count=0;

for(k=0;k<size;k++)//loop execution

{
if(array[k]>40 && array[k]<60)//condition testing
    {
        count++;//counting if the condition is true
    }
}

printf("total in range 40 and 60  is=%d",count);//printing total element

getch();

}







---------------------------------------------------------------------------------------------------------------
in codeblocks:
--------------------------------------------------------------------------------------------------------------------
/*WAP to input weight of 100 students and count number of students who have weight in between 40 and 60 kg.
Pass Weight as an array as parameter.*/
#include<stdio.h>
#include<conio.h>
void total_nu_of_array(float array[200],int size);//prototype with array and size parameters
int main()
{

float arr[200];int k;            // array declaration with maximum limit 200
int size;               // says about size of array to be entered
printf("enter size of array\n");
scanf("%d",&size);//input of size
printf("enter weights of students\n");
for(k=0;k<size;k++)//loop execution
{
   scanf("%f",&arr[k]);//data/weight inputs
}
total_nu_of_array(arr,size);//calling of function
return 0;
}

void total_nu_of_array(float array[200],int size)//body line
{

int k;//declaration
int count=0;

for(k=0;k<size;k++)//loop execution

{
if(array[k]>40 && array[k]<60)//condition testing
    {
        count++;//counting if the condition is true
    }
}

printf("total in range 40 and 60  is=%d",count);//printing total element

getch();

}