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
Naya [18.7K]
2 years ago
10

Write a program that will read in id numbers and place them in an array.The array is dynamically allocated large enough to hold

the number of id numbers given by the user. The program will then input an id and call a function to search for that id in the array. It will print whether the id is in the array or not.
Computers and Technology
1 answer:
AveGali [126]2 years ago
3 0

Answer:

#include <stdio.h>

#include <stdlib.h>

int main() {

  int n, i, *p, s;

  scanf("%d", n);

  p = (int*) malloc(n * sizeof(int));

  if(p == NULL) {

     printf("\nError! memory not allocated.");

     exit(0);

  }

  printf("\nEnter elements of array : ");

  for(i = 0; i < n; ++i) {

     scanf("%d", p + i);  

  }

  scanf("Enter Id to be searched: %d", s);

  for(j = 0; j < n; ++j) {

     if (s == *(p+j)){

         printf("ID number is in the array at position %d", j);

     }else{

         printf("Error: ID number does not exist.");

     }  

  }

  return 0;

Explanation:

The C program source code inputs integer values to dynamic array size, and the search variable is looked for in the array using a for loop. If the search term exists, then the index position is printed on the screen, else an error message is displayed on the screen.

You might be interested in
Volume of a cuboid is 14400 ​
Yanka [14]

Answer:

WHAT?

Explanation:

8 0
3 years ago
Jacob is preparing a presentation on the health and social advantages of taking up a sport at an early age. Most of the slides i
NARA [144]

Answer:

It's C

Explanation:

On edgenuity

4 0
3 years ago
Give an example of a file suffix for the files created by each of the following: 1) a word processing program 2) a spread sheet
gayaneshka [121]
1) .docx
2) .xlsx
3) .pptx
4) .zip
7 0
2 years ago
What helps you to ensure that writing is well organized?
mezya [45]
Chronological Order. ...
Logical Order. ...
Climactic Order. ...
Random Order. ...
Spatial Order.
5 0
3 years ago
During the reconnaissance step of the attack, what open ports were discovered by Zenmap? What services were running on those por
Setler [38]

Answer:

Following are the solution to the given question:

Explanation:

It sends commands to its Nmap executable platForm, which is used to specified and retrieves the production. The  ZenMap utilizes templates, which are primarily Nmap.

The parameter templates to decide how scans become formed Several ports, like ports, are available: 11, 21, 22, 25, 53, 445, and 3306, all of which run TCP: Linux services, SMTP Postfix, Apache Tomcat/Coyote JSP.

5 0
3 years ago
Other questions:
  • Maria's manager asked her to print a certain document for their meeting. It took her so long to find the file that she was late
    6·2 answers
  • Revenue xls en excel
    8·1 answer
  • Which of these engine components forms a tight seal between the piston and the cylinder and is necessary for proper engine opera
    13·2 answers
  • In which phase of the software development process would probing questions be used to verify the problem definition?
    12·1 answer
  • What is the output of the second println statement in the main method, public class foo { int i ; static int s ; public sttic vo
    15·1 answer
  • Help meeeeeeeeeeeeeee please​
    6·1 answer
  • 4.15 LAB: Password modifier
    14·1 answer
  • Why has base 2 been accepted and used as the basis for computing?​
    8·1 answer
  • How do you change your grade level
    10·1 answer
  • How many grams are in 100 pounds?
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!