import java.util.*; //Main class public class Main { //Main method public static void main(String[] args) { //Creating linked list object LinkedList linkedList = new LinkedList(); Scanner scan = new Scanner(System.in); //Getting number of nodes from user System.out.print("Input the number of nodes : "); int n = scan.nextInt(); int i=0; //Getting node elements from user for(i=0; i < n; i++) { System.out.print("Input data for node " + (i+1) + " : "); linkedList.add(i, scan.nextInt()); } //Print data entered by user System.out.println("\nData entered in the list are : "); for(i=0; i < n; i++) { System.out.println("Data " + (i+1) + " : " + linkedList.get(i)); } } }
Question: CONVERT THIS INTO C LANGUAGE
...
import java.util.*;
//Main class
public class Main
{
//Main method
public static void main(String[] args) {
//Creating linked list object
LinkedList<Integer> linkedList = new LinkedList<Integer>();
Scanner scan = new Scanner(System.in);
//Getting number of nodes from user
System.out.print("Input the number of nodes : ");
int n = scan.nextInt();
int i=0;
//Getting node elements from user
for(i=0; i < n; i++)
{
System.out.print("Input data for node " + (i+1) + " : ");
linkedList.add(i, scan.nextInt());
}
//Print data entered by user
System.out.println("\nData entered in the list are : ");
for(i=0; i < n; i++)
{
System.out.println("Data " + (i+1) + " : " + linkedList.get(i));
}
}
}
Step by step
Solved in 3 steps with 2 images