06-05-2011, 10:32 PM
|
| Never Give Up | | Join Date: Jan 2011 Location: SahiwaL Age: 31
Posts: 26
Program / Discipline: BSIT Class Roll Number: 10-26 | |
A Program to find number in an array #include<iostream.h>
#include<conio.h>
void main()
{
int a[10]={1,5,8,9,4,6,0,3,7,2};
int i,n,index=-1;
cout<<"enter any no";
cin>>n;
for(i=0;i<=9;i++)
{
if(a[i]==n)
index=i;
}
if(index==-1)
cout<<"number not found";
else
cout<<"number found at index "<<index;
getch();
} |