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

  • Home
  • SEARCH
  • 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 9032181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:54:58+00:00 2026-06-16T07:54:58+00:00

In this code, If I have to find an element ‘7’, it points to

  • 0

In this code, If I have to find an element ‘7’, it points to the position of array=2,
but how to get the multiple positions, if array has [4,7,7,8,9] then the answer should point the position as array=1 & array=2..

#include<stdio.h>


int main()
{
 int i;
 int a[5]={4,5,7,8,9};
 int ele,temp=0,pos=0;
 printf("Enter the element to be search\n");
 scanf("%d",&ele);


 // searching for the element

 for (i=0; i<5; i++)
 {
    a[i]=a[i];
     if (a[i]==ele)
     {
       temp=1;
       pos=i;
     }


  }

   if (temp==1)
   printf("Element found %d , position==%d,",ele,pos);
   else
   printf("Element not found\n");
} 
  • 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-06-16T07:54:59+00:00Added an answer on June 16, 2026 at 7:54 am

    Try this..

    #include<stdio.h>
    
    
    int main()
    {
     int i;
     int a[5]={4,5,7,8,9};
     int found_indices[5]; // array used to store indices of found entries..
     int count = 0; //n entries found;
     int ele;
     printf("Enter the element to be search\n");
     scanf("%d",&ele);
    
    
     // searching for the element
    
     for (i=0; i<5; i++)
     {
         //a[i]=a[i];
         if (a[i]==ele)
         {
           found_indices[count ++] = i; // storing the index of found entry
         }
      }
    
       if (count!=0) {
           for (i=0; i<count; i++)
               printf("Element found %d , position==%d,", ele, found_indices[i]);
       }
       else
           printf("Element not found\n");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have searched but can't find why this simple code will fail in Drools
I'm trying to get the direction property for the element. I have this code:
I have this setup, just to find the index() of an element, but it
I have this code App.Model('users').find(function (err, users) { users.forEach(function(user) { console.log(user.username); }); }); //make
I have this code, but i cant make it work: images = Image.find_by_sql('PREPARE stmt
I have borrowed code from this link PHP regex templating - find all occurrences
If I have a block of code like this: def show @post = Post.find(params[:id])
I have been unable to find any decent documentation on this function. The code
I have been struggling to find a solution to this problem. In my code,
I got a failure but I cant fix this problem. I have this code:

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.