Hi, how do I get rid of a conversion from double to float warning??

Thanks

hi thanks, I tried that but I'm obviously not implimenting it properly. I'll go back and maybe create another variable to see if that fixes my problem....otherwise I'll post. I know I have to type cast, I just don't understand the logic yet, so struggling a bit...BRB.

:)

// RandLink.cpp : main project file.

#include "stdafx.h"
#include "bubble.h"
#include <list>
#include <iostream>
#include <time.h>

using namespace System;
using namespace std;

	
int main(array<System::String ^> ^args)
{
    double sum = 0;
	int count = 0;
	float average = 0;
	
	int Iarray[25];
	srand( (unsigned)time( NULL ) );
	for (int i=0;i<25;i++)
	{
		int number = rand() % 100;
		Iarray[i] = number;
	}
 
		list<int> randLink;
		randLink.assign(Iarray, Iarray + 25);
		cout << "contents of list are: " << ' ' << endl;

		list<int>::iterator p;
		for (p = randLink.begin(); p != randLink.end(); p++)
		cout << *p << endl;
		randLink.sort();
		cout<< "after the sort function the contents are: "<< endl;
		for (p = randLink.begin(); p != randLink.end(); p++)
		cout << *p << endl;

		for (p = randLink.begin(); p != randLink.end(); p++)
		{
			sum = sum + *p;
			count = count + 1;
		}
			average = static_cast<double>(sum/count);
		//average = sum/count;
		//double sum = double average;
			cout <<"The sum is equal to:  " << sum << endl;
			cout <<"The average is equal to:  " << average << endl;

}

Can you please help me to understand? Thanks

:-) okay, I got it, thanks for the help.

// RandLink.cpp : main project file.

#include "stdafx.h"
#include "bubble.h"
#include <list>
#include <iostream>
#include <time.h>

using namespace System;
using namespace std;

	
int main(array<System::String ^> ^args)
{

	
	int Iarray[25];
	srand( (unsigned)time( NULL ) );
	for (int i=0;i<25;i++)
	{
		int number = rand() % 100;
		Iarray[i] = number;
	}
 
		list<int> randLink;
		randLink.assign(Iarray, Iarray + 25);
		cout << "contents of list are: " << ' ' << endl;

		list<int>::iterator p;
		for (p = randLink.begin(); p != randLink.end(); p++)
		cout << *p << endl;
		randLink.sort();
		cout<< "after the sort function the contents are: "<< endl;
		for (p = randLink.begin(); p != randLink.end(); p++)
		cout << *p << endl;

		double sum = 0;
		int count = 0;
		float average = 0.00;
		

		for (p = randLink.begin(); p != randLink.end(); p++)
		{
			sum = sum + *p;
			count = count + 1;
		}
		average = static_cast<float>(sum/count);
		//average = sum/count;
		//double sum = double average;
		cout <<"The sum is equal to:  " << sum << endl;
		cout <<"The average is equal to:  " << average << endl;

}
This question has already been answered. Start a new discussion instead.