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 4034158
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:56:14+00:00 2026-05-20T11:56:14+00:00

Before I begin I want to make it clear that I don’t want the

  • 0

Before I begin I want to make it clear that I don’t want the answer to my HOMEWORK problem, I would just like if someone could actually explain what exactly my instructor is asking for in this assignment (preferably a dumbed down version) and maybe a helpful push in the right direction. I’m having a lot of trouble with this topic and whenever I ask the instructor I find that he confuses me more than anything else.

So, here is the assignment:

1.Add a new function insertN(struct list *x, int num, int pos, int n) that will insert n copies of the integer num at position pos, if that is possible (if pos is too big, take appropriate action).
The main thing I’m confused by here is what he means by the position pos.

Here’s the code I am working with-which was written by my teacher and I have to modify it.

#include<stdio.h>
#include<stdlib.h>

struct list {
    int data;
    struct list * next;
        };

struct list *slist;

/*adds a node at the end of the linked list*/
void insert(struct list *x,int num){
  /*if the list is empty*/
  if(x==NULL){
    /*create first node*/
    slist=malloc(sizeof(struct list));
    slist->data=num; 
    slist->next=NULL;
    }
  else{
    /*go to the last node*/
    while(x->next!=NULL) x=x->next;
    /*add node at the end*/
      x->next=malloc(sizeof(struct list));
      x->next->data=num;
      x->next->next=NULL;

  }
}


void display(struct list *x){
  /*traverse the entire linked list*/
  while(x!=NULL){
    printf("%d->",x->data);
    x=x->next;
  }
  printf("NULL");
}

void reverse(struct list *x){
  struct list *prev,*rev,*temp;

  prev=x;
  rev=NULL;

  while(prev!=NULL){
    temp=rev;
    rev=prev;
    prev=prev->next;
    rev->next=temp;
  }
  slist=rev;
}

void search(struct list *x,int a){
struct list *runner;
int found=0;
  for(runner=x;runner!=NULL;runner=runner->next){
  if(runner->data==a){
    printf("data found"); 
    found=1;
break;
  }
  }
if(found==0) printf("data not found");

}

main(){
  int number,a;

  slist=NULL;/*empty linked list*/

  printf("Enter the element for data part:");
  scanf("%d",&number);
  insert(slist,10);
  insert(slist,number);

  insert(slist,20);

  display(slist);
  printf("\n");

  reverse(slist);

  display(slist);
  printf("\nEnter the element for searching:");
  scanf("%d",&a);
  search(slist,a);
  printf("\n");
  getchar();
  getchar();
}

Again, I don’t expect an answer to the problem, just an explanation and a push in the right direction.

  • 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-20T11:56:15+00:00Added an answer on May 20, 2026 at 11:56 am

    By saying “at position 5” he means that he wants you to iterate through (“go through”) the list 5-steps, then insert there.

    If you have a reference to a list like so:

    struct list * current;
    

    A single step can be done like this:

    current = current -> next;
    

    Now what you have to do is do that until you are at the right position, then insert there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Before I begin, I would like to highlight the structure of what I am
Before I begin, let me just say that I know my question is almost
Before we begin, don't blame me, I didn't design the database. I am well
Just before I begin heres a small overview of what I'm trying to achieve
To clarify before I begin, this is NOT homework but rather I am studying
before I start I want to point out that I tagged this question as
I want to make a trigger that will prevent the insertion if the birthdate
Before I begin, I must warn you that I'm not much of a web
I want to make a trigger that sets the joined attribute to the current
I want to validate (preferably with .matches()) that the part before % in for

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.