Originally Posted by
Shakti
for arrays you dont need to include anything. For std::vector though you need to include vector, for math-functions you need cmath. Mod however is a built in operator
a % b is a mod b.
but then why is my code not working?
Code:
#include "stdafx.h"
#include <iostream>
#include<limits>
using namespace std;
void main()
{
int array[20];
int tot=0;
for(int i=0;i<19;i++)
{
cin<<array[i];
tot=tot+array[i];
}
float avg=tot/20;
cout<<"tot"<<"="<<tot<< <<"avg"<<"="<<avg;
system("pause");
}
Error 1 error C2784: 'std::basic_ostream<char,_Traits> &std:perator <<(std::basic_ostream<char,_Traits> &,unsigned char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'
Error 2 error C2784: 'std::basic_ostream<char,_Traits> &std:perator <<(std::basic_ostream<char,_Traits> &,unsigned char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'
Warning 42 warning C4244: 'initializing' : conversion from 'int' to 'float', possible loss of data c:\documents and settings\administrator\my documents\visual studio 2008\projects\oogh\oogh.cpp 16 oogh