Input five numbers in an array and search a number in that array.
#include <stdio.h>
#include <conio.h>
void main ( )
{
int arr[5], i, n, f = 0;
clrscr ( );
for ( i = 0; i < 5; i++ )
{
printf("\n\t\t\t Enter a number..:"); scanf("%d",&arr[i]);
}
printf("\n\t\t\t Enter the number to search..:"); scanf("%d",&n);
for ( i = 0; i < 5; i++ )
{
if ( arr[i] == n )
{
f = 1;
printf("\n\n\t\t\t Found in position %d",i);
}
}
if ( f == 0 )
{
printf("\n\t\t\t Not Found.");
}
getch ( );
}
Click here to contact us
#include <stdio.h>
#include <conio.h>
void main ( )
{
int arr[5], i, n, f = 0;
clrscr ( );
for ( i = 0; i < 5; i++ )
{
printf("\n\t\t\t Enter a number..:"); scanf("%d",&arr[i]);
}
printf("\n\t\t\t Enter the number to search..:"); scanf("%d",&n);
for ( i = 0; i < 5; i++ )
{
if ( arr[i] == n )
{
f = 1;
printf("\n\n\t\t\t Found in position %d",i);
}
}
if ( f == 0 )
{
printf("\n\t\t\t Not Found.");
}
getch ( );
}
Click here to contact us
No comments:
Post a Comment