#include <stdio.h>
#include <stdlib.h>
struct Node {
int item;
struct Node *next;
};
struct Node *node = NULL;
void insert_at_begin(int);
int count = 0;
int main(){
int i, data;
printf("Insert the element that is remaining to make it 10kg.\n");
printf("Enter value of element\n");
scanf("%d", &data);
if(data<1.5){
insert_at_begin(data);
printf("Inserted successfully.\n");
}
else{
printf("Item must be less than or equal to 1.5.\n");
main();
}
}
void insert_at_begin(int x) {
struct Node *t;
t = (struct Node*)malloc(sizeof(struct Node));
t->item= x;
count++;
if (node == NULL) {
node = t;
node->next = NULL;
return;
}
t->next = node;
node = t;
}
Comments
Leave a comment