Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

wite a programme in c to linear search a data using flag and
without using flags?

Answer Posted / ruchi

#include<stdio.h>
#include<conio.h>
int main()
{
int n,i,a[15],num;
printf("\nHow many elements are there ");
scanf("%d",&n);
printf("\nEnter the elements ");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("\nEnter the element do you want to search ");
scanf("%d",&num);
for(i=0;i<n;i++)
{
if(a[i]==num)
{
printf("\nElement is present ");
break;
}
else if((a[i]!=num)&&(i==n-1
))
{
printf("\nElement is not present");
}
}
getch();
}

Is This Answer Correct ?    19 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is data structure in c language?

1055


What's the right way to use errno?

1086


Explain what is the benefit of using an enum rather than a #define constant?

1168


code for quick sort?

1984


Which is better pointer or array?

973


What does volatile do?

936


In C, What is the #line used for?

2097


Is c procedural or object oriented?

952


What is build process in c?

1079


How we can insert comments in a c program?

1069


What is the difference between %d and %i?

1042


Distinguish between actual and formal arguments.

1012


Does sprintf put null character?

987


What is the use of a static variable in c?

1007


What are the applications of c language?

1011