Searching a Number and Its Position C++ Language Program Code

C++ – Find the No. and its Position.

#include
#include
void main()
{
int a[5],i,s,f=0;
clrscr();
cout<<"Enter the numbers:n";
for(i=0;i<5;i++)
{
cin>>a[i];
}
cout<<"nEnter the number to be searched:";
cin>>s;
for(i=0;i<5;i++)
{
if(a[i]==s)
{
f=1;
break;
}
else
{
f=0;
}
}
if(f==1)
{
cout<<"nNumber found at position "< }
else
{
cout<<"nNumber not found.";
}
getch();
}

Add Comment