linked list in c

linked list in c
--------------
hello
i hope you can help me on this.
the user gives you a number x.
i want to create a list in C consisting of x , 2*x , 4*x .. 128*x
can you help me in this?

i cant manage to add a node, i am really confused.

my current code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include<iostream>
 struct node {
  int x;
  struct node *next;
};
int main()
{
    int n;
    cin>>n;
    struct node *root;
    root = (struct node *) malloc( sizeof(struct node) );
    root->next = 0;
    root->x=n;
}
Topic archived. No new replies allowed.