iostream error when compiling

iostream always fatal error while compiling help

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 #include <conio.h>
#include <iostream.h>
main(){
int c,i,posisi;
int A[20]={3,2,4,10,20,1,5,8,7,9,6,5,11,12,14,13,16,15,17,19};


cout<<"Data : ";
for(i=0;i<20;i++){
 cout<<A[i]<<" ";
}

cout<<"\n postion data to search : ";
cin>>c;
i=0;
position=0;
while(i<19 && A[i]!=c){
 i++;
}
if (A[i]!=c){
 cout<<"sorry your data isn't found";
}else if(position=i+1)
   cout<<"discovered "<<posisi;
getch();
}
Hi,when you include iostream you don't need to write ".h", and then when you
write cout and cin you must specify before main() "using namespace std;",or write std::cout and st::cin in each cout and cin.
Last edited on
You never defined "position", so lines 16 and 22 are illegal. Perhaps you meant to use "posisi" instead?
i means posisi =position ok'thanks but can you give me example please
Last edited on
just #include <iostream>
this will fix your code.

but can you give me example please 

example of what?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
using namespace std;
main(){
int c,i,position;
int A[20]={3,2,4,10,20,1,5,8,7,9,6,5,11,12,14,13,16,15,17,19};


cout<<"Data : ";
for(i=0;i<20;i++){
 cout<<A[i]<<" ";
}

cout<<"\n postion data to search : ";
cin>>c;
i=0;
position=0;
while(i<19 && A[i]!=c){
 i++;
}
if (A[i]!=c){
 cout<<"sorry your data isn't found";
}else if(position=i+1)
   cout<<"discovered "<<position;
}
fatal error iostream no such file or directory?
fatal error iostream no such file or directory?

It appears you have one of those old-timey Borland-like compilers. This is not compliant with the C++ standard.
You can use "iostream.h", without the "using namespace std"

Better yet use a modern compiler that actual supports standard C++. You can find free ones for most platforms.
http://www.stroustrup.com/compilers.html
Last edited on
Topic archived. No new replies allowed.