
|
// define ARRAY of assign any 10 numbers, Enter number and search it in
array and print that number is present or not. And if present it is present
at which position
# include <iostream.h>
# include <conio.h>
void main()
{
int no[10],n,x;
clrscr();
// In a loop for entering 10 nos
for (n=0;n<10;n++)
{
cout<<"Enter any no ";
cin>>no[n];
}
// printing original entered no
cout<<"\nOriginal nos are\n ";
for (n=0;n<10;n++)
{
cout<<no[n]<<" ";
}
// Enter number to search it in array
cout<<"\nEnter no to search it in array ";
cin>>x;
// Searching Array
for (n=0;n<10;n++)
{
if (no[n]==x)
{
cout<<x<<" Value is found at
"<<n<<" Position";
goto last;
}
}
cout<<x<<" Value is not found ";
last:
getch();
}
|