1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
maksim [4K]
3 years ago
6

Write a program to define a variable size array, ask the user to enter the size of array and its elements. Then search whether a

n element (x) exists in the array or not and print the indexes where it found (if it exists in more the one index).
Computers and Technology
1 answer:
Hunter-Best [27]3 years ago
8 0

Answer:

The program to this question can be given as:

Program:

//header file

#include <stdio.h>  

void search(int n)   //define function.

{

int a[n],find,i;  //variable declaration

printf("Enter elements of array :\n"); //message

for (i = 0; i <n; i++) //loop

{

scanf("%d", &a[i]); //input array elements

}

printf("Enter a number to search: ");

scanf("%d", &find); //input number for search

for (i = 0; i< n; i++) //search number.

{

if (a[i] == find) //if element is found in array

{

printf("%d is present at location %d.\n",find,i+1); //print location.

}

}

}

int main() //main method

{

int n; //variable declaration

printf("Enter size of array: "); //message

scanf("%d", &n); //input sizeof array.

search(n);  //calling function.

return 0;

}

Output:

Enter size of array: 6

Enter elements of array :

4

2

1

4

2

4

Enter a number to search: 4

4 is present at location 1.

4 is present at location 4.

4 is present at location 6.

Explanation:

In the above C language program firstly we define the header file that is stdio.h this header file is used to take stander input output from the user.

Then we define the main function. In this function, we declare a variable that is search, n, and i. In this, we also declare an array variable that is a[].

After inserting all array elements we take a number from the user to search number that is present in the array or not.

For this process, we define a loop. In this loop, we define a conditional statement in this if block we check elements of the array equal to search variable if this condition is true so it will print the position of number that is found in the array.  

You might be interested in
Which type of worker would most likely be able to begin work after receiving a high school degree and completing an
makvit [3.9K]
I’m pretty sure it’s miner

“I’ll give you head I mean brainiest”
3 0
3 years ago
An antonym for the word “help” which may be found in a dictionary is a. Assist c. Hold b. Abandon d. None of these
Luba_88 [7]
I would have to say the answer is abondon
5 0
3 years ago
Read 2 more answers
Where are some places that cyberbullying occurs? check all that apply
antiseptic1488 [7]

Answer:

social media like  snap chat twitter  and face book .it can even happen over email.or in school chats.

Explanation:

5 0
4 years ago
Read 2 more answers
A _________, such as apple.com and whitehouse.gov, uniquely identifies a site and a brand on the web.
Serga [27]

A <u>domain name </u>such as apple.com and whitehouse.gov, uniquely identifies a site and a brand on the web.

What is Domain name?

This is known to be a kind of Application programming interface. The  domain name is said to be a series or a string of letters that tells more about a realm of administrative autonomy.

It  tells about authority as well as control that is found  within the Internet. Domain names are said to be used in a lot of networking contexts and therefore, A <u>domain name </u>such as apple.com and whitehouse.gov, uniquely identifies a site and a brand on the web.

Learn more about Domain name from

brainly.com/question/13153286
#SPJ1

5 0
2 years ago
The operating system of a computer is an example of ________ software. science-forum
Aleks [24]
Os (Operating system) <span>The operating system of a computer is an example of OS software. </span>
8 0
3 years ago
Other questions:
  • Name format Many documents use a specific format for a person's name. Write a program whose input is: firstName middleName lastN
    14·2 answers
  • Write a program named Admission for a college’s admissions office. The user enters a numeric high school grade point average (fo
    15·1 answer
  • What type of malware actually evolves, changing its size and other external file characteristics to elude detection by antivirus
    5·1 answer
  • Why would you group data in a report? SQL
    9·1 answer
  • An online service allows users to integrate their phonebook with their social media profiles and stores it on the cloud. The pho
    12·1 answer
  • An object reference is required for the nonstatic field method or property True or False
    11·1 answer
  • Which of these communication avenues is not regulated by the Federal Communications Commission (FCC)?
    12·1 answer
  • This shows you where text will appear as you type.
    14·1 answer
  • Need Help! Asap 7.5 code practice (Edhesive)
    8·2 answers
  • The cost of a postsecondary education increases with the length of time involved in the program.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!