Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can I have A flowchart or pseudo-code for below C program code please? #include #include #include int main() { //declaring the variables and array needed

Can I have A flowchart or pseudo-code for below C program code please?

#include

#include

#include

int main()

{

//declaring the variables and array needed in code

float arr[100],in,sum=0,avg;

int n=0;

//infinte loop , its break when user enters 0

while(1){

//reading input from the user

printf("Enter a weight in Kg or 0 to quit : ");

scanf("%f",&in);

//input is 0 while loop stops

if (in==0){

break;

}

//if input is less than 0 , it prints ignore the negative value

else if(in<0){

printf("Ignoring the Negative Value ");

}

//if it is a positive float value , we need to store in array

else if (in>0){

//storing the input in array

arr[n]=in;

//calculating sum

sum+=in;

//incrementing n value here

n+=1;

}

}

//calculating average here

avg = sum/n;

//printing number of entries and average weight here

printf("Number of Entries : %d ",n);

printf("Average Weight : %f ",avg);

//declaring variables

float weight[100];

int i,c=0;

//finding the deviation of weights

for (i=0;i

weight[i] = avg - arr[i];

}

//calculating no of items closest to average

for (i=0;i

{

if (weight[i]==0 || (weight[i]>-1 && weight[i]<1))

c+=1

}

//printing the number of values closest to average here

printf("Number of Items Closest to Average : %d ",c);

printf("The items - weight in kg : ");

for (i=0;i

{

if (weight[i]==0 || (weight[i]>-1 && weight[i]<1))

printf("%f ",arr[i]);

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Machine Performance Modeling Methodologies And Evaluation Strategies Lncs 257

Authors: Francesca Cesarini ,Silvio Salza

1st Edition

3540179429, 978-3540179429

More Books

Students also viewed these Databases questions

Question

1. Who should participate and how will participants be recruited?

Answered: 1 week ago