Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7617815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:14:28+00:00 2026-05-31T03:14:28+00:00

This question has been asked here on SO before with below code find3missing(int* array)

  • 0

This question has been asked here on SO before with below code

find3missing(int* array)
{ 
    int newarray[100] = {0};
    For i = 0 to 99  
        ++newarray[array[i]] ;
    For i = 0 to 99 
        If newarray[i] != 1
            Cout << “the missing number is ” << i+1 << endl ;
} 

But when I checked this code, it doesn’t seem to work. Suppose I have an array of {1,2,6}. The output should be 3,4,5 but with the code above I get 1,4,5,6 instead. Below is my implementation of pseudo code with array size 6.

main()
{
    int a[6]={1,2,6};
    int tmp[6]={0},i;
    for(i=0;i<6;i++)
    {
        ++tmp[a[i]];
    }
    for(i=0;i<6;i++)
    {
        if(tmp[i]!=1)
        {
            printf("%d",i+1);
        }
    }
}

Is this the right code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T03:14:30+00:00Added an answer on May 31, 2026 at 3:14 am

    This ++newarray[array[i]] should be ++newarray[array[i] - 1]. This because you are interested in a sequence of 1-100 numbers, so no 0, but C arrays are 0 based. If you then look at the cout: the missing number is ” << i+1 here you “unshift” the number by adding 1.

    There is another problem: you should pass the number of elements of the array, something like:

    find3missing(int* array, int length) { 
      int newarray[100] = {0};
    
      for (int i = 0; i < length; i++) {
          ++newarray[array[i] - 1] ;
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this question has been asked here before, but I don't think those
This question has been asked in various forms on here before, but I cannot
I know this question has been asked here a few times before. But i
Ok, so this question has been asked before here . In the response/answer to
This question has been asked here before, but the author wasn't very clear and
I apologise if this question has already been asked on here before but I
Folks, I know this question has been asked before here, though indirectly . But
This question has been asked before (see here and here , for example). However,
It looks like this question has been asked before, here and in other places
I know this kind of question has been asked before, for example here: Android:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.