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]
3 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]3 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
Write a c program that asks the user to enter two numbers. the program should use the conditional operator to determine which nu
iris [78.8K]

Using the knowledge in computational language in C++ it is possible to write a code that asks the user to enter two numbers. the program should use the conditional operator to determine which number is the smaller and which is the larger.

<h3>Writting in C++ code:</h3>

#include <iostream>

using namespace std;

int main(){

float a, b;

cout<<"Enter two numbers:";

cin>>a>>b;

if(a>b) {

cout<<"Larger Number:"<<a<<endl;;

cout<<"Smaller Number:"<<b;

}

else if(b<a){

cout<<"Larger Number:"<<b<<endl;

cout<<"Smaller Number:"<<a;

}else{

cout<<"Number are equal!"<<endl;

}

}

See more about C++ code at brainly.com/question/19705654

#SPJ1

6 0
2 years ago
A security analyst is investigating a call from a user regarding one of the websites receiving a 503: Service unavailable error.
OverLord2011 [107]

Answer:

C. Denial of Service

Explanation:

Denial of service error occurs when the legitimate users are unable to access the system. They are then unable to access the information contained in the system. This can also be a cyber attack on the system in which user are stopped from accessing their personal and important information and then ransom is claimed to retrieve the attack. In such case system resources and information are temporarily unavailable to the users which disrupts the services.

5 0
4 years ago
Visual culture is an area of academic study that deals with the totality of images and visual objects produced in ____________,
leonid [27]

Answer:

In: industrial and postindustrial nations

5 0
4 years ago
En que parte del mall del rio venden tarjetas de google play en cuenca​
JulijaS [17]

chxgfk hcyskvuct auhchovuzq vuvscisv

6 0
3 years ago
Stephanie is a zoologist who loves the outdoors and often travels the world researching wildlife and serving as a consultant it
Flauer [41]

Answer:

Nature (at all) is the best place for her to work at. Researcher or Environmental activist or Biologist Professor or Zoo care/assistant. All of the mentioned works can be applied to her.

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • A special symbol that is used as an underlining structure to an agenda
    5·1 answer
  • Which method do software testers use to isolate new code from the rest of the network during the test stage of the software deve
    15·1 answer
  • Rate monotonic Analysis (RMA) is a model for predicting whether or not a system will meet its timing as well as throughput requi
    6·1 answer
  • To answer the research question "How am I going to find the information I need on the tople?" the best thing Georgia should
    15·1 answer
  • Under which menu option of a word processing program does a callout appear?
    7·2 answers
  • Consider the following MARIE Code: 100 If, Load X /Load the first value 101 Subt Y /Subtract the value of Y, store result in AC
    8·1 answer
  • Guys help me, to get 25 examples of computer software​
    8·1 answer
  • Programs for embedded devices are often written in assembly language. Some embedded processors have limited instructions, like M
    5·1 answer
  • What are the main dimensions of information system and their components
    13·1 answer
  • Which statement best describes how the programming layer of abstraction in
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!