I have an assignment to write a code that will prompt the user to enter three integers, then it should print the integers in ascending order.
The code that I have written has six errors & two warnings, but I don't know what to do.
Here is the code:
Code:
#include <iostream>
#include <conio.h>
void main ()
{
clrscr();
int array [3], t;
for (int x=0; x<3; x++)
{
cout << "Enter integer number" << x+1 << " : " << endl;
cin<< array[x];
}
for (x=0; x<3; x++)
{
for (int y=0; y<2; y++)
{
if(array[y]>array[y+1])
{
t=array[y];
array[y]=array[y+1];
array[y+1]=t;
}
}
}
cout << "The integers in ascending order are : ";
for (x=0;x<3;x++)
cout << endl << array[x];
getch();
}
And the errors/warnings are:
C:\ascending.cpp(10) : error C2065: 'clrscr' : undeclared identifier
C:\ascending.cpp(14) : error C2065: 'cout' : undeclared identifier
C:\ascending.cpp(14) : error C2297: '<<' : illegal, right operand has type 'char [21]'
C:\ascending.cpp(14) : error C2065: 'endl' : undeclared identifier
C:\ascending.cpp(15) : error C2065: 'cin' : undeclared identifier
C:\ascending.cpp(15) : warning C4552: '<<' : operator has no effect; expected operator with side-effect
C:\ascending.cpp(29) : error C2297: '<<' : illegal, right operand has type 'char [40]'
C:\ascending.cpp(31) : warning C4552: '<<' : operator has no effect; expected operator with side-effect
I'm kind of stuck.
Oh, also, my teacher said to use scanf three times? I'm not sure if it matters that I didn't.