Posts

DSA (Binary tree)

Linked List Program Linked List Program in C //For better view open in laptop #include <stdio.h> #include <stdlib.h> // Definition of the node structure struct node { int info; // Data to store struct node *link; // Pointer to the next node }; // Function to create a new node struct node *createnode(int x) { struct node *new_node = (struct node *) malloc(sizeof(struct node)); if (new_node == NULL) { printf("Memory allocation failed\\n"); exit(1); } new_node->info = x; new_node->link = NULL; return new_node; } // Function to insert a node at the beginning of the list struct node *insert_beg(struct node *first, int x) { struct node *new_node = createnode(x); new_node->link = first; return new_node; } // Function to insert a node at the end of the list struct node *insert_end(struct node *first, int x) { struct node *new_node = createnode(x); ...

DSA(linked list)

Linked List Program Linked List Program in C write a menu driven program for all the operations in linked list #include <stdio.h> #include <stdlib.h> // Definition of the node structure struct node { int info; // Data to store struct node *link; // Pointer to the next node }; // Function to create a new node struct node *createnode(int x) { struct node *new_node = (struct node *) malloc(sizeof(struct node)); if (new_node == NULL) { printf("Memory allocation failed\\n"); exit(1); } new_node->info = x; new_node->link = NULL; return new_node; } // Function to insert a node at the beginning of the list struct node *insert_beg(struct node *first, int x) { struct node *new_node = createnode(x); new_node->link = first; return new_node; } // Function to insert a node at the end of the list struct node *insert_end(struct node *first, int x) { struct node *new_...

JAVA Basic program(practical-2)

Java Code Examples with Comments prac 2.1. WAP to find a diameter from given area of circle. import java.util.Scanner; public class prac_2_1 { public static void main(String[] args) { Scanner SC = new Scanner(System.in); System.out.println("enter area"); Float a = SC.nextFloat(); // Input area of the circle System.out.println(Math.sqrt((a / 3.14)) * 2); // Calculate diameter using the area } } prac 2.2. WAP to check whether the given number is positive or negative. import java.util.Scanner; public class prac_2_2 { public static void main(String[] args) { Scanner SC = new Scanner(System.in); System.out.println("enter number"); int n = SC.nextInt(); // Input the number if (n > 0) { System.out.println("Number is positive"); } else if (n == 0) { System.out...

java basic program(practical-1)

Java Code Examples BASIC PROGRAM OF JAVA Demonstrate of Basics of java programming and implementation of Scanner class 1. Introduction to JDK (Java development kit) Introduction to JDK (Java Development Kit) The JDK (Java Development Kit) is a software development kit used by Java developers to build, compile, debug, and run Java applications. It includes essential tools and libraries necessary for Java development. Here's a brief overview of its components: Javac (Java Compiler): Javac is the Java compiler that translates Java source code (.java files) into bytecode (.class files) that can be executed by the Java Virtual Machine (JVM). JVM (Java Virtual Machine): JVM is an essential part of the JDK. It executes Java bytecode on various platforms, providing platform independence for Java applications. Java Runtime Environment (JRE): The JRE is included in the JDK and provides the libraries, resources, and environment necessary for running Java ...

OOPS

Image
Object Oriented Programming (OOPs) Concept in Java  As the name suggests, Object-Oriented Programming or Java OOPs concept refers to languages that use objects in programming, they use objects as a primary source to implement what is to happen in the code. Objects are seen by the viewer or user, performing tasks you assign. Object-oriented programming aims to implement real-world entities like inheritance, hiding, polymorphism, etc. in programming. The main aim of OOPs is to bind together the data and the functions that operate on them so that no other part of the code can access this data except that function.    . Let us discuss prerequisites by polishing concepts of method declaration and message passing. Starting off with the method declaration, it consists of six components:  Access Modifier : Defines the  access type  of the method i.e. from where it can be accessed in your application. In Java, there are 4 types of access specifiers:  public: ...