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
how old is the letter 3 on its 23rd birthday when your car turns 53 and your dog needs gas and your feet need lave then when is
forsale [732]

Answer:

ummm...idr.k..u got me....wat is it

Explanation:

8 0
3 years ago
Match the parts of the website address with its correct explanation. http://www.usa.gov/Agencies/federal.shtm/​
meriva

sorry I was just testing something

6 0
3 years ago
Read 2 more answers
There are N rectangular buildings standing along the road next to each other. The K-th building is of size H[K] × 1.
Sphinxa [80]

Answer:

# you can write to stdout for debugging purposes, e.g.

# print("this is a debug message")

def solution(H):

   # write your code in Python 3.6

   

   # return area of atmost 2 banners

   # 1 banner

   # maximum height * number of buildings

   single_banner = max(H) * len(H)

   smallest_area = single_banner

   

   

   # 2 banner

   for i in range(1, len(H)):

       double_banner = (max(H[0:i]) * len(H[0:i])) + (max(H[i:]) * len(H[i:]))

       if  double_banner < smallest_area:

           smallest_area = double_banner

   

   return smallest_area

8 0
4 years ago
Influencers are trusted above many other information sources because of their perceived ______ and ______.
Evgesh-ka [11]

Influencers are trusted above many other information sources because of their perceived  Authenticity  and Transparency.

<h3>Who is an influencer?</h3>

An influencer is known as a person that does the work of exerting their influence on a product or services.

Note that they help or act as guides or they inspire the actions of others and as such Influencers are trusted with lots of information sources because of their perceived  Authenticity  and Transparency.

See options below

Influencers are trusted above many other information sources because of their perceived ______ and ______.

a. Authenticity.

b. Transparency.

c. Expertise.

d. A & B.

e. A & C.

Learn more about Influencers from

brainly.com/question/26242633

8 0
2 years ago
Identify the careers that require a college degree
Vikentia [17]
Doctor or teacher or an engineer

8 0
3 years ago
Other questions:
  • Why people needs soft skills in the era of high technology.
    13·1 answer
  • The distance at which wi-fi signals can travel ranges typically between ____ and ____.
    15·1 answer
  • list the six external parts of a computer system, identify which is the output device and which is the input device?
    15·2 answers
  • 1. The acronym AUDIENCE serves to remind you of what to consider when analyzing an audience. The U for understanding. How does t
    15·1 answer
  • The domain name service (dns is a distributed database that allows users to communicate with each other computers by:
    7·1 answer
  • To access WordPad, Jill will click on Start, All Programs, Accessories, and WordPad. To access Notepad, Karl will click on Start
    14·1 answer
  • WHAT DOES THE SCRATCH CODE BELOW DO?
    7·1 answer
  • Which is the correct process for selecting consecutive rows in a worksheet?
    9·1 answer
  • ______ requires that any electronic communication must be backed up and secured with reasonable disaster recovery infrastructure
    6·1 answer
  • confidentiality ensures that only those with the rights and privileges to access information are able to do so.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!