Posts

Showing posts from January, 2018

Java I/O Tutorial

Image
Java I/O Tutorial Java I/O  (Input and Output) is used  to process the input  and  produce the output . Java uses the concept of stream to make I/O operation fast. The java.io package contains all the classes required for input and output operations. We can perform  file handling in java  by Java I/O API. Stream A stream is a sequence of data. In Java a stream is composed of bytes. It's called a stream because it is like a stream of water that continues to flow. In java, 3 streams are created for us automatically. All these streams are attached with console. 1) System.out:  standard output stream 2) System.in:  standard input stream 3) System.err:  standard error stream Let's see the code to print  output and error  message to the console. System.out.println( "simple message" );   System.err.println( "error message" );   Let's see the code to get  input  from console. int  i=System.in.read(); //returns AS

Singly and Doubly Link List C Program

Link List Program Singly Linked List /* * File     : SLL.C * Author   : Piyush Patel * Purpose  : Singly Linked List Data Structure Using C Language * Copyright: Shree Matrumandir College */ #include <stdio.h> #include <stdlib.h> typedef struct node {     int data;     struct node* next; } node; typedef void (*callback)(node* data); /*     create a new node     initialize the data and next field     return the newly created node */ node* create(int data,node* next) {     node* new_node = (node*)malloc(sizeof(node));     if(new_node == NULL)     {         printf("Error creating a new node.\n");         exit(0);     }     new_node->data = data;     new_node->next = next;     return new_node; } //add a new node at the beginning of the list node* prepend(node* head,int data) {     node* new_node = create(data,head);     head = new_node;     return head; } //add a new node at the end of the list node* append(n