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 your question here (Keep it clear and simple to get the best answer)
weeeeeb [17]
What is your favorite book?
4 0
3 years ago
Read 2 more answers
7. In order to check your following distance, use a fixed object and count seconds.
rewona [7]

Answer:

False

Explanation:

7 0
3 years ago
Read 2 more answers
Suppose you develop an app and want to generate revenue but do not want to maintain the app. What would be your best choice?
valentinak56 [21]
I think it would be d
6 0
3 years ago
How to do assignment 5 on edhesive
s2008m [1.1K]

Answer:

//To pass in a string, and pass in a pivot string, and at that moment print in obligatory sequence, the string after pivot string till last as first string, and published beforehand the left slice of string.

import java.util.Scanner;

public class Main {

public static void main(String args[]) {

  Scanner s2 = new Scanner(System.in);

  System.out.println("Enter the parent String:");

  String f2 = s2.nextLine();

  System.out.println("Enter pivot(child string):");

  String piv1 = s2.nextLine();

  int start2 = f2.indexOf(piv1);

  int end2 = piv1.length()+start2;

  if (start2 == -1){

    System.out.println("Error: child string(Pivot) not discovered.");

    return;

}

String first2 = f2.substring(0,start2-1);

  String second2 = f2.substring(end2);

if (f2.charAt(start2-1)==' '){

System.out.println(second2 + " " + piv1 + " " + first2);

return;

}

System.out.println(second2 + piv1 + first2);

}

}

Explanation:

Please check the answer section.

6 0
3 years ago
PLEASEEEE PLEASEEE HELPPPP
olga nikolaevna [1]

Explanation:

you need a better pic if possible, it's kinda hard to read the question.

4 0
3 years ago
Other questions:
  • Pixels are small dots in columns and rows that allow an image to be seen on a display screen.
    6·1 answer
  • The critical path in a project network is:______ A. The Shortest path through the network. B. Longest path through the network.
    8·1 answer
  • How can cultural hearths be described
    5·1 answer
  • Chevening is looking for individuals with strong professional relationship building skills, who will engage with the Chevening c
    15·1 answer
  • Alto Innovations creates custom software for organizations. The company's managers want to build a high-performance culture in t
    11·1 answer
  • What will the following loop display? 0 1 2 3 4 5 0 1 2 3 4 0 1 2 3 4 The loop will display numbers starting at 0, for infinity.
    8·1 answer
  • Software companies will often release a(n) ___ version to a limited audience that will test it on their systems. Programmers can
    11·1 answer
  • Analyze and write a comparison of C's malloc and free functions with C++'s new and delete operators. Use safety as the primary c
    15·1 answer
  • For python how do I ask the user how many numbers they want to enter and then at the ending add those numbers up together?
    10·1 answer
  • 2. Why do you think the order of operations still applies in Java? Give an example to show what could happen if you didn't use o
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!