-
hi
i need some one to help me in this program
write a function to find a number of an integers array . the function must return [B]true [/B] if the number is existed and [B]false[/B] otherwise . then use that function in a program where the user enters the array elements and the number to be found . assume that the array size is 10 .
-
Re: hi
#include<stdio.h>
#include<conio.h>
int fun(int [],int );
void main()
{
int ary[]={10,20,50,30,40};
int t,a;
clrscr();
printf("Enter any number : ");
scanf("%d",&t);
a=fun(ary,t);
if(a==1)
printf("true");
else
printf("fales");
getch();
}
int fun(int ar[],int i)
{
for(int c=0;c<=5;c++)
if(ar[c]==i)
{
return 1;
}
else
{
return 0;
}
}
-
Re: hi
-
Re: hi
[QUOTE=bouloskh;22591]i need some one to help me in this program
write a function to find a number of an integers array . the function must return [B]true [/B] if the number is existed and [B]false[/B] otherwise . then use that function in a program where the user enters the array elements and the number to be found . assume that the array size is 10 .[/QUOTE]
You need to let us know what is your difficulty in writing a program to match the specifications. Did you not understand the problem OR are you having difficulty in implementing it??
One can learn programming by thinking about the problem, coming up with a solution and implementing it. Trust me: the reward is worth it. If you have any difficulty in any phase, you should ask. Just asking for a solution does not help.
Of course, you are free to do as you wish.:)