#include<iostream>
#include<conio.h>
using namespace std;
int n[10],i,ns;
string c;
main(){
        for(i=0;i<10;i++){   
                         cout<<"Enter a number:";
                     
        cin>>n[i];
                         }
       cout<<"Number to search:";
       cin>>ns;
       n[i]=0;
       for(n[i]=0;n[i]<10;n[i]++){
                         if(ns==n[i]){
                                      cout<<"Searched Number is Found!";
                                      }
                         else{
                                      cout<<"Searched Number is Lost!";
                                      }}
                                
                                      
                                      getch();
                                      return 0;
                                      }

help pls the output is repeating...

line 6: its int main(). c++ does not allow default function return types.

lines 4 and 5. Move those down so that they are within main() and not global variables. Globals are bad and can normally be avoided.

line 10: Entering numeric data types such as integers leaves the '\n' <Enter> key in the keyboard buffer which causes problems. You have to flush it out, like this: cin.ignore(); Here is a more detailed explanation how to flush the input buffer.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.