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...


write a program to search for an element in a given array.
If the array was found then display its position otherwise
display appropriate message in c language

Answers were Sorted based on User's Feedback



write a program to search for an element in a given array. If the array was found then display its ..

Answer / e v n raja

#include<stdio.h>
#include<conio.h>

void main()
{
int a[5],i,ele;


clrscr();

printf("enter the array elements
");

for (i=0; i<5; i++)
scanf("%d",&a[i]);

printf("Enter the element to be search
");
scanf("%d",&ele);

// searching for the element

for (i=0; i<5; i++)
{
if (a[i]==ele)
{
printf("Element found %d , position==%d",ele,i);
break;
}
}

} // end of main()

Is This Answer Correct ?    0 Yes 0 No

write a program to search for an element in a given array. If the array was found then display its ..

Answer / laxmi

#include<stdio.h>
#include<conio.h>
void main()
{
int a[5]={1,2,3,4,5};
int i;
clrscr();
printf("
enter the value");
scanf("%d",&i);
for(i=0;i<5;i++)
if(i<5)
{
printf("
the value is present=%d");
}
else
{
printf("
the value is absent=%d");
}
getch();
}

Is This Answer Correct ?    0 Yes 0 No

write a program to search for an element in a given array. If the array was found then display its ..

Answer / vs

#include<stdio.h>
#include<conio.h>
void main()
int a[5],i;
int e,t=0,p=0;
clrscr();
printf("enter the array of elements/n");
for(i=0;i<5;i++)
scanf("%d",&a[i]);
clrscr();
printf("enter the element to search/n");
scanf("%d",&e);
for(i=0;i<5;i++)
{
if(a[i]==e)
{
t=1;
p=i;
}
}
if(t==1)
printf("element found--%d/n position--%d",e,p);
else
printf("element not found/n");
getch();
}

Is This Answer Correct ?    21 Yes 22 No

write a program to search for an element in a given array. If the array was found then display its ..

Answer / satys

we can use any variable in the place of temp

Is This Answer Correct ?    1 Yes 2 No

write a program to search for an element in a given array. If the array was found then display its ..

Answer / aishwarya rajan

#include<iostream.h>
#include<conio.h>
void main()
{
int i,n,a[30];
char item;
cout<<"Enter the number of elements you would like to enter in the array: ";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"Enter the element"<<i+1<<" :";
cin>>a[i];
}
cout<<"Enter the element you are searching for in the array:";
cin>>item;
if(a[i]==item)
cout<<"The item does exist in the array!! it is the "<<i+1<<" element!!";
else
cout<<"The item is not found in the array!!";
getch();
}

Is This Answer Correct ?    0 Yes 2 No

write a program to search for an element in a given array. If the array was found then display its ..

Answer / priya chauhan

Find the presence of a given number in a set of numbers
using array. also find the position of the number.

Is This Answer Correct ?    5 Yes 8 No

write a program to search for an element in a given array. If the array was found then display its ..

Answer / jamshed

IF WE STORE ELEMENTS IN AN ARRAY :


import java.io.*;
class Search
{
public static void main()throws IOException
{
InputStreamReader isr=new
InputStreamReader(System.in);
BufferedReader br=new BufferedReader(isr);
int a[]={5,7,9,11,15,20,30,45,89,97};
int i,n,c=0;
System.out.println("Enter a Number to Search");
n=Integer.parseInt(br.readLine());

for(i=0;i<a.length;i++)
{
if(a[i]==n)
{
c++;
System.out.println("\nThe Number "+n+"
Does Exist");
System.out.println("The Position is
"+(i+1));
}
}
if(c==0)
System.out.println("Search Element Not Found");
}
}

Is This Answer Correct ?    18 Yes 27 No

write a program to search for an element in a given array. If the array was found then display its ..

Answer / all

#include<stdio.h>

Is This Answer Correct ?    11 Yes 30 No

Post New Answer

More C Interview Questions

Badboy is defined who has ALL the following properties: Does not have a girlfriend and is not married. He is not more than 23 years old. The middle name should be "Singh" The last name should have more than 4 characters. The character 'a' should appear in the last name at least two times. The name of one of his brothers should be "Ram" Write a method: boolean isBadBoy(boolean hasGirlFriend , boolean isMarried, int age , String middleName , String lastName , String[] brotherName); isHaveGirlFriend is true if the person has a girlfriend isMarried is true if the person is married age is the age of the person middleName is the middle name of the person lastName is the last name of the person brotherName is the array of the names of his brothers

0 Answers  


5. What kind of sorting is this: SORT (k,n) 1.[Loop on I Index] repeat thru step2 for i=1,2,........n-1 2.[For each pass,get small value] min=i; repeat for j=i+1 to N do { if K[j]<k[min] min=j; } temp=K[i];K[i]=K[min];K[min]=temp; 3.[Sorted Values will be returned] A)Bubble Sort B)Quick Sort C)Selection Sort D)Merge Sort

2 Answers   Accenture,


Two's compliment of -5

4 Answers   Adobe,


What is pointers in c?

0 Answers  


Write a program to swap two numbers without using a temporary variable?

0 Answers   Infosys,


int far *near * p; means

0 Answers   Honeywell,


4) Write a program that takes a 5 digit number and calculates 2 power that number and prints it. i have done maximum par but i m findind problem in the commented area. please help...

3 Answers  


void main() { int *ptr; ptr = (int *) 0x400 ; printf("ptr=%d",ptr); } output?

1 Answers  


what is the use of ~ in c lang?????

3 Answers  


what is Array?

3 Answers  


How can I change their mode to binary?

0 Answers  


Was 2000 a leap year?

0 Answers  


Categories