I have to write a code that asks the user

How many numbers would you like to enter?

And the program is supposed to give the smallest, largest , average

and the difference between each number and the average.

I have most of it here thanks to some help from ( M.D ). But i have

trouble with the difference between each number and the average.

Everything else works fine.

Could you please go through the code and show me what is wrong and how to fix

it. I am a beginner so please use the most basic of code possible.

I Thank You in advance.

Ercan

#include <iostream.h>

#include <conio.h>

main()

{

clrscr();

int a,b,f,min,max,sum=0;

float tavg,davg,avg;

cout<<"How many numbers would you like to enter?\t";

cin>>a;

for (int count = 0; count < a; count++)

{

cout<<"\n\nEnter a number please:\t";

cin>>b;

sum += b;

f+=b;

{

if (count>1)

avg=(f/2);

cout<<"\nAverage of these Numbers are\t"<<avg;

davg=(f-avg);

cout<<"\nDifference between these Numbers and there Average is\t"<<davg;

}

if (count == 0)

{

min = max = b;

}

else

{

if (b < min)

min = b;

if (b > max)

max = b;

}

}

tavg = sum / a;

cout<<"\nSmallest number is\t"<<min;

cout<<"\nLargest number is\t"<<max;


cout<<"\nTotal Average is\t\t"<<tavg;

getch();

return 0;

}