Snippets Collections
#include <stdio.h>
#include <math.h>

void compute_trig(float deg, float* sin_angle, float* cos_angle);

int main(void)
{
    float sin_result = 0.0f;
    float cos_result = 0.0f;
    float angle = 0.0f;
 
    printf("Angle? \n");
    scanf("%f", &angle);
    // TODO: Call compute_trig
    compute_trig(angle,&sin_result,&cos_result);
    
    printf("sin(%f) is %f\n", angle, sin_result);
    printf("cos(%f) is %f\n", angle, cos_result);
 
    return 0;
}

void compute_trig(float deg, float* sin_angle, float* cos_angle)
{
    float pi = 3.14159f;
    float radians = deg * pi / 180.0f;
    // TODO: Compute sine angle...
    *sin_angle = sinf(radians);
    
    // TODO: Compute cosine angle...
    *cos_angle = cosf(radians);
}
#include <stdio.h>

void increment(int* int_pointer);

int main(void)
{
	int x = 0;
	printf("> \n");
	scanf("%d", &x);
	// TODO: Call increment with x by reference
	increment(&x);
	printf("x holds %d\n\n", x);
	// TODO: Call increment with x by reference
	increment(&x);
	printf("x holds %d\n\n", x);
	// TODO: Call increment with x by reference
	increment(&x);
	printf("x holds %d\n\n", x);
	return 0;
}

// TODO: Define increment function:
void increment(int* int_pointer)
{
     (*int_pointer) ++;
    
}
#include <stdio.h>

struct Softdrink
{
	char name [16];
	int size;
	int energy;
	float caffeine;
	int max_daily;
};

void print_soft_drink(struct Softdrink a_soft_drink);

int main(void)
{
    struct Softdrink life_mod;

	sprintf(life_mod.name, "Life Modulus");
	life_mod.size = 250;
	life_mod.energy = 529;
	life_mod.caffeine = 80.5f;
	life_mod.max_daily = 500;

	print_soft_drink(life_mod);
	
	return 0;
}

void print_soft_drink(struct Softdrink a_soft_drink)
{
    
	printf("A soft drink...\n\n");
	printf("Name: %s\n",a_soft_drink.name);
	printf("Serving size: %d mL\n",a_soft_drink.size);
	printf("Energy content: %d kJ\n",a_soft_drink.energy);
	printf("Caffeine content: %f mg\n",a_soft_drink.caffeine);
	printf("Maximum daily intake: %d mL\n",a_soft_drink.max_daily);
}
#include <stdio.h>

// TODO: Declare Colour structure:
struct Colour
{
    unsigned char red;
    unsigned char green;
    unsigned char blue;
};

// TODO: Declare functions:
//struct Colour create_colour(...
struct Colour create_colour(unsigned char red, unsigned char green, unsigned char blue);
//void print_colour(...
void print_colour(struct Colour a_colour);

int main(void)
{
	print_colour(create_colour(255, 0, 0)); // RED
	print_colour(create_colour(0, 255, 0)); // GREEN
	print_colour(create_colour(0, 0, 255)); // BLUE
	print_colour(create_colour(255, 255, 0)); // YELLOW
	print_colour(create_colour(255, 0, 127)); // PINK

	return 0;
}

// TODO: Define functions:
struct Colour create_colour(unsigned char red, unsigned char green, unsigned char blue)
{
	struct Colour colour;
	colour.red = red;
	colour.green = green;
	colour.blue = blue;
	
	return colour;
}

void print_colour(struct Colour a_colour)
{
    printf("RGB: %u, %u, %u\n",a_colour.red,a_colour.green,a_colour.blue);
}
selector li a::before{
    opacity: 1 !important;
    position: relative;
    transform: translateY(2px);
    z-index: 2 !important;
}

selector li a{
    gap: 6px !important;
    z-index: 2 !important;
}
.nav-home a::before{
    content: url(https://ways2learn.co.il/wp-content/uploads/Mask-Group-62.svg) !important;
}
.nav-blog a::before{
    content: url(https://ways2learn.co.il/wp-content/uploads/Mask-Group-64.svg) !important;
}
.nav-courses a::before{
    content: url(https://ways2learn.co.il/wp-content/uploads/Mask-Group-71.svg) !important;
}

.nav-reco a::before{
    content: url(https://ways2learn.co.il/wp-content/uploads/v.svg) !important;
}
.nav-school a::before{
    content: url(https://ways2learn.co.il/wp-content/uploads/elearning-icon-1.svg) !important;
}

selector li:hover a:after{
    content: '';
    width: calc(100% - 4px);
    height: calc(100% - 4px);
    background-color: #fff;
    position: absolute;
    left: 2px;
    top: 2px;
    border-radius: 50px;
    z-index: -2;
}

selector li:hover, selector .elementor-item-active{
    background-image: linear-gradient(90deg, #1BC5E4, #7C19FF);
    border-radius: 50px !important;
}

selector .elementor-item-active:hover:after{
    content: none !important;
}

selector li{
    border-radius: 50px !important;
}

selector li a{
    transition: all 0s !important;
}

selector .menu-item a.elementor-item-active::before{
    filter: brightness(0) invert(1) !important;
}

selector .elementor-nav-menu{
    gap: 8px;
}

@media (max-width: 1224px){
    selector .elementor-nav-menu--dropdown{
        width: 300px !important;
        padding:10px !important;
    }
    selector .elementor-nav-menu--dropdown a{
        max-width: 300px !important;
        margin-bottom: 5px !important;
    }
class Node<T extends Comparable<T>> {
    T data;
    Node<T> next;

    public Node(T data) {
        this.data = data;
        this.next = null;
    }
}

public class SortedChain<T extends Comparable<T>> {
    private Node<T> head;

    public void insert(T data) {
        Node<T> newNode = new Node<>(data);
        
        if (head == null || head.data.compareTo(data) >= 0) {
            newNode.next = head;
            head = newNode;
        } else {
            Node<T> current = head;
            while (current.next != null && current.next.data.compareTo(data) < 0) {
                current = current.next;
            }
            newNode.next = current.next;
            current.next = newNode;
        }
    }

    public void display() {
        Node<T> current = head;
        while (current != null) {
            System.out.print(current.data + " ");
            current = current.next;
        }
        System.out.println();
    }

    public static void main(String[] args) {
        SortedChain<Integer> sortedChain = new SortedChain<>();
        sortedChain.insert(5);
        sortedChain.insert(3);
        sortedChain.insert(7);
        sortedChain.insert(1);
        sortedChain.insert(9);

        System.out.println("Sorted Chain:");
        sortedChain.display();
    }
}
import java.util.LinkedList;

class SeparateChainingHashTable {
    private static final int TABLE_SIZE = 10;
    LinkedList<String>[] hashTable;

    public SeparateChainingHashTable() {
        hashTable = new LinkedList[TABLE_SIZE];
        for (int i = 0; i < TABLE_SIZE; i++) {
            hashTable[i] = new LinkedList<>();
        }
    }

    public int hash(String key) {
        return Math.abs(key.hashCode() % TABLE_SIZE);
    }

    public void insert(String key, String value) {
        int index = hash(key);
        hashTable[index].add(value);
    }

    public boolean search(String key, String value) {
        int index = hash(key);
        return hashTable[index].contains(value);
    }

    public void display() {
        System.out.println("Hash Table Contents:");

        for (int i = 0; i < TABLE_SIZE; i++) {
            System.out.print("Index " + i + ": ");
            if (!hashTable[i].isEmpty()) {
                for (String value : hashTable[i]) {
                    System.out.print(value + " -> ");
                }
            }  
            System.out.println();
        }
        
    }

    public static void main(String[] args) {
        SeparateChainingHashTable hashTable = new SeparateChainingHashTable();

        // Insert some key-value pairs
        hashTable.insert("John", "Doe");
        hashTable.insert("Jane", "Smith");
        hashTable.insert("Alice", "Johnson");
        hashTable.insert("Smith", "Williams");

        // Display contents
        hashTable.display();

        // Search for values
        System.out.println("Searching for 'Doe': " + hashTable.search("John", "Doe"));
 
    }
}
public class LinearProbingHashTable {
    private String[] keys;
    private String[] values;
    private int size;
    private int capacity;

    // Constructor
    public LinearProbingHashTable(int capacity) {
        this.capacity = capacity;
        this.keys = new String[capacity];
        this.values = new String[capacity];
        this.size = 0;
    }

    // Hash function (simple demonstration using string length)
    private int hash(String key) {
        return key.length() % capacity;
    }

    // Insert key-value pair into the hash table
    public void put(String key, String value) {
        if (key == null || value == null) {
            throw new IllegalArgumentException("Key or value cannot be null.");
        }
        
        int index = hash(key);
        while (keys[index] != null) {
            if (keys[index].equals(key)) {
                // Update value if key already exists
                values[index] = value;
                return;
            }
            // Linear probing to find next available slot
            index = (index + 1) % capacity;
        }
        // Insert key-value pair
        keys[index] = key;
        values[index] = value;
        size++;
    }

    // Get value associated with the given key
    public String get(String key) {
        int index = hash(key);
        while (keys[index] != null) {
            if (keys[index].equals(key)) {
                return values[index];
            }
            // Linear probing to search for key
            index = (index + 1) % capacity;
        }
        return null; // Key not found
    }

    // Display hash table contents
    public void display() {
        for (int i = 0; i < capacity; i++) {
            if (keys[i] != null) {
                System.out.println("Key: " + keys[i] + ", Value: " + values[i]);
            }
        }
    }

    public static void main(String[] args) {
        LinearProbingHashTable hashTable = new LinearProbingHashTable(10);
        
        // Insert key-value pairs
        hashTable.put("John", "Doe");
        hashTable.put("Alice", "Smith");
        hashTable.put("Bob", "Johnson");
        hashTable.put("Charlie", "Brown");
        
        // Display hash table contents
        hashTable.display();
        
        // Retrieve values
        System.out.println("Value associated with 'John': " + hashTable.get("John"));
        System.out.println("Value associated with 'Alice': " + hashTable.get("Alice"));
        System.out.println("Value associated with 'Bob': " + hashTable.get("Bob"));
        System.out.println("Value associated with 'Charlie': " + hashTable.get("Charlie"));
        System.out.println("Value associated with 'Dave': " + hashTable.get("Dave")); // Not found
    }
}
import java.util.*;

public class TreeMapExample {
    public static void main(String[] args) {
        // Creating a TreeMap
        TreeMap<Integer, String> treeMap = new TreeMap<>();

        // Adding elements to the TreeMap
        treeMap.put(1, "Apple");
		 treeMap.put(4, "Mango");
        treeMap.put(5, "Grapes");
        treeMap.put(2, "Banana");
        treeMap.put(3, "Orange");
       

        // Printing the TreeMap
        System.out.println("TreeMap: " + treeMap);

        // Getting the size of the TreeMap
        System.out.println("Size of TreeMap: " + treeMap.size());

        // Checking if TreeMap is empty
        System.out.println("Is TreeMap empty? " + treeMap.isEmpty());

        // Getting value associated with a key
        System.out.println("Value associated with key 3: " + treeMap.get(3));

        // Checking if TreeMap contains a key
        System.out.println("Does TreeMap contain key 4? " + treeMap.containsKey(4));

        // Checking if TreeMap contains a value
        System.out.println("Does TreeMap contain value 'Grapes'? " + treeMap.containsValue("Grapes"));

        // Removing an element from TreeMap
        treeMap.remove(2);
        System.out.println("After removing key 2: " + treeMap);

        // Getting the first key and value
        System.out.println("First key in TreeMap: " + treeMap.firstKey());
        System.out.println("First value in TreeMap: " + treeMap.firstEntry().getValue());

        // Getting the last key and value
        System.out.println("Last key in TreeMap: " + treeMap.lastKey());
        System.out.println("Last value in TreeMap: " + treeMap.lastEntry().getValue());

        // Getting a submap from TreeMap
        SortedMap<Integer, String> subMap = treeMap.subMap(1, 4);
        System.out.println("Submap from key 1 to key 3: " + subMap);

        // Clearing the TreeMap
        treeMap.clear();
        System.out.println("TreeMap after clearing: " + treeMap);
    }
}
import java.util.LinkedHashMap;
import java.util.Map;

public class LinkedHashMapExample {
    public static void main(String[] args) {
        // Creating a LinkedHashMap
        LinkedHashMap<Integer, String> linkedHashMap = new LinkedHashMap<>();

        // Adding elements to the LinkedHashMap
        linkedHashMap.put(1, "Apple");
        linkedHashMap.put(2, "Banana");
        linkedHashMap.put(3, "Orange");
        linkedHashMap.put(4, "Grapes");
        linkedHashMap.put(5, "Mango");

        // Displaying the elements in the LinkedHashMap
        System.out.println("LinkedHashMap elements:");
        for (Map.Entry<Integer, String> entry : linkedHashMap.entrySet()) {
            System.out.println(entry.getKey() + " => " + entry.getValue());
        }

        // Removing an element from the LinkedHashMap
        String removedElement = linkedHashMap.remove(2);
        System.out.println("Removed element with key 2: " + removedElement);

        // Checking if a key exists in the LinkedHashMap
        boolean containsKey = linkedHashMap.containsKey(3);
        System.out.println("LinkedHashMap contains key 3: " + containsKey);

        // Checking if a value exists in the LinkedHashMap
        boolean containsValue = linkedHashMap.containsValue("Banana");
        System.out.println("LinkedHashMap contains value 'Banana': " + containsValue);

        // Getting a value from the LinkedHashMap
        String value = linkedHashMap.get(4);
        System.out.println("Value associated with key 4: " + value);

        // Iterating over the elements in the LinkedHashMap using an Iterator
        System.out.println("Iterating over LinkedHashMap elements using Iterator:");
        for (Map.Entry<Integer, String> entry : linkedHashMap.entrySet()) {
            System.out.println(entry.getKey() + " => " + entry.getValue());
        }

        // Clearing the LinkedHashMap
        linkedHashMap.clear();
        System.out.println("LinkedHashMap cleared. Current size: " + linkedHashMap.size());
    }
}
import java.util.*;
import java.util.Map;

public class HashMapExample {
    public static void main(String[] args) {
        // Create a new HashMap instance
        Map<String, Integer> ageMap = new LinkedHashMap<>();

        // Add key-value pairs to the map
        ageMap.put("John", 30);
        ageMap.put("Alice", 25);
        ageMap.put("Bob", 35);
        ageMap.put("Eve", 28);

        // Access values using keys
        System.out.println("Age of John: " + ageMap.get("John"));
        System.out.println("Age of Alice: " + ageMap.get("Alice"));

        // Update the value associated with a key
        ageMap.put("John", 32);
        System.out.println("Updated age of John: " + ageMap.get("John"));

        // Check if a key exists in the map
        String name = "Bob";
        if (ageMap.containsKey(name)) {
            System.out.println(name + " exists in the map.");
        } else {
            System.out.println(name + " does not exist in the map.");
        }

        // Remove a key-value pair from the map
        ageMap.remove("Eve");
        System.out.println("Map after removing Eve: " + ageMap);

        // Iterate over the map entries
        System.out.println("Iterating over map entries:");
        for (Map.Entry<String, Integer> entry : ageMap.entrySet()) {
            System.out.println(entry.getKey() + " : " + entry.getValue());
        }

        // Clear the map
        ageMap.clear();
        System.out.println("Map after clearing: " + ageMap);
    }
}
import java.util.TreeSet;
import java.util.Iterator;

public class TreeSets {
    public static void main(String[] args) {
        // Creating a TreeSet
        TreeSet<String> treeSet = new TreeSet<>();

        // Adding elements to the TreeSet
        treeSet.add("Apple");
        treeSet.add("Banana");
        treeSet.add("Orange");
        treeSet.add("Grapes");
        treeSet.add("Mango");

        // Trying to add a duplicate element
        boolean added = treeSet.add("Apple");
         
        boolean removed = treeSet.remove("Banana");
   
            System.out.println("Element 'Banana' removed from the TreeSet.");
         

        // Checking if an element exists in the TreeSet
        boolean contains = treeSet.contains("Orange");
        System.out.println("TreeSet contains 'Orange': " + contains);

        // Iterating over the elements in the TreeSet using an Iterator
        System.out.println("Iterating over TreeSet elements using Iterator:");
        Iterator<String> iterator = treeSet.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }

        // Getting the first and last elements
        System.out.println("First element: " + treeSet.first());
        System.out.println("Last element: " + treeSet.last());

        // Clearing the TreeSet
        treeSet.clear();
        System.out.println("TreeSet cleared. Current size: " + treeSet.size());
    }
}
import java.util.HashSet;
import java.util.Iterator;

public class Main {
    public static void main(String[] args) {
        // Creating a HashSet
        HashSet<String> hashSet = new HashSet<>();

        // Adding elements to the HashSet
        hashSet.add("Apple");
        hashSet.add("Banana");
        hashSet.add("Orange");
        hashSet.add("Grapes");
        hashSet.add("Mango");

        
        // Removing an element from the HashSet
        boolean removed = hashSet.remove("Banana");
     
            System.out.println("Element 'Banana' removed from the HashSet.");
       

        // Checking if an element exists in the HashSet
        boolean contains = hashSet.contains("Orange");
        System.out.println("HashSet contains 'Orange': " + contains);

        // Iterating over the elements in the HashSet using an Iterator
        System.out.println("Iterating over HashSet elements using Iterator:");
        Iterator<String> iterator = hashSet.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }

        // Clearing the HashSet
        hashSet.clear();
        System.out.println("HashSet cleared. Current size: " + hashSet.size());
    }
}
import java.util.LinkedHashSet;
import java.util.Iterator;

public class LinkedHashSetDemo {
    public static void main(String[] args) {
        
        LinkedHashSet<String> lhs= new LinkedHashSet<>();
        
        lhs.add("Apple");
        lhs.add("Banana");
        lhs.add("Orange");
        lhs.add("Grapes");
        lhs.add("Watermelon");
        System.out.println("LinkedHashSet: " + lhs);        
        System.out.println("Contains 'Banana'? " + lhs.contains("Banana"));        
        System.out.println("Is the LinkedHashSet empty? " + lhs.isEmpty());        
        System.out.println("Size of the LinkedHashSet: " + lhs.size());       
        lhs.remove("Orange");
        System.out.println("LinkedHashSet after removing 'Orange': " + lhs);
        lhs.clear();
        System.out.println("LinkedHashSet after clearing: " + lhs);
        lhs.add("Apple");
        lhs.add("Banana");
        lhs.add("Orange");
        System.out.println("Iteration using Iterator:");
        Iterator<String> iterator = lhs.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
        Object[] array = lhs.toArray();
        System.out.print("LinkedHashSet as Array: ");
        for (Object element : array) {
            System.out.print(element + " ");
        }
        System.out.println();
        System.out.println("Hash code of the LinkedHashSet: " + lhs.hashCode());
    }
}
//GenericArrayListQueue
import java.util.ArrayList;

public class GenericArrayListQueue<T> {
    private ArrayList<T> queueList;

    public GenericArrayListQueue() {
        queueList = new ArrayList<>();
    }

    public void enqueue(T value) {
        queueList.add(value);
    }

    public T dequeue() {
        if (isEmpty()) {
            System.out.println("Queue is empty.");
            return null;
        } else {
            return queueList.remove(0);
        }
    }

    public T peek() {
        if (isEmpty()) {
            System.out.println("Queue is empty.");
            return null;
        } else {
            return queueList.get(0);
        }
    }

    public boolean isEmpty() {
        return queueList.isEmpty();
    }

    public int size() {
        return queueList.size();
    }
}
//Main
public class Main {
    public static void main(String[] args) {
        // Queue for Integers
        GenericArrayListQueue<Integer> intQueue = new GenericArrayListQueue<>();
        intQueue.enqueue(1);
        intQueue.enqueue(2);
        System.out.println(intQueue.dequeue());  // Output: 1
        System.out.println(intQueue.peek()); // Output: 2

        // Queue for Doubles
        GenericArrayListQueue<Double> doubleQueue = new GenericArrayListQueue<>();
        doubleQueue.enqueue(1.1);
        doubleQueue.enqueue(2.2);
        System.out.println(doubleQueue.dequeue());  // Output: 1.1
        System.out.println(doubleQueue.peek()); // Output: 2.2

        // Queue for Strings
        GenericArrayListQueue<String> stringQueue = new GenericArrayListQueue<>();
        stringQueue.enqueue("Hello");
        stringQueue.enqueue("World");
        System.out.println(stringQueue.dequeue());  // Output: Hello
        System.out.println(stringQueue.peek()); // Output: World
    }
}
//GenericLinkedListQueue
import java.util.LinkedList;

public class GenericLinkedListQueue<T> {
    private LinkedList<T> queueList;

    public GenericLinkedListQueue() {
        queueList = new LinkedList<>();
    }

    public void enqueue(T value) {
        queueList.addLast(value);
    }

    public T dequeue() {
        if (isEmpty()) {
            System.out.println("Queue is empty.");
            return null;
        } else {
            return queueList.removeFirst();
        }
    }

    public T peek() {
        if (isEmpty()) {
            System.out.println("Queue is empty.");
            return null;
        } else {
            return queueList.getFirst();
        }
    }

    public boolean isEmpty() {
        return queueList.isEmpty();
    }

    public int size() {
        return queueList.size();
    }
}
//Main
public class Main {
    public static void main(String[] args) {
        // Queue for Integers
        GenericLinkedListQueue<Integer> intQueue = new GenericLinkedListQueue<>();
        intQueue.enqueue(1);
        intQueue.enqueue(2);
        System.out.println(intQueue.dequeue());  // Output: 1
        System.out.println(intQueue.peek()); // Output: 2

        // Queue for Doubles
        GenericLinkedListQueue<Double> doubleQueue = new GenericLinkedListQueue<>();
        doubleQueue.enqueue(1.1);
        doubleQueue.enqueue(2.2);
        System.out.println(doubleQueue.dequeue());  // Output: 1.1
        System.out.println(doubleQueue.peek()); // Output: 2.2

        // Queue for Strings
        GenericLinkedListQueue<String> stringQueue = new GenericLinkedListQueue<>();
        stringQueue.enqueue("Hello");
        stringQueue.enqueue("World");
        System.out.println(stringQueue.dequeue());  // Output: Hello
        System.out.println(stringQueue.peek()); // Output: World
    }
}
//GenericLinkedListStack
import java.util.LinkedList;

public class GenericLinkedListStack<T> {
    private LinkedList<T> stackList;

    public GenericLinkedListStack() {
        stackList = new LinkedList<>();
    }

    public void push(T value) {
        stackList.addFirst(value);
    }

    public T pop() {
        if (isEmpty()) {
            System.out.println("Stack is empty.");
            return null;
        } else {
            return stackList.removeFirst();
        }
    }

    public T peek() {
        if (isEmpty()) {
            System.out.println("Stack is empty.");
            return null;
        } else {
            return stackList.getFirst();
        }
    }

    public boolean isEmpty() {
        return stackList.isEmpty();
    }

    public int size() {
        return stackList.size();
    }
}
//Main
public class Main {
    public static void main(String[] args) {
        // Stack for Integers
        GenericLinkedListStack<Integer> intStack = new GenericLinkedListStack<>();
        intStack.push(1);
        intStack.push(2);
        System.out.println(intStack.pop());  // Output: 2
        System.out.println(intStack.peek()); // Output: 1

        // Stack for Doubles
        GenericLinkedListStack<Double> doubleStack = new GenericLinkedListStack<>();
        doubleStack.push(1.1);
        doubleStack.push(2.2);
        System.out.println(doubleStack.pop());  // Output: 2.2
        System.out.println(doubleStack.peek()); // Output: 1.1

        // Stack for Strings
        GenericLinkedListStack<String> stringStack = new GenericLinkedListStack<>();
        stringStack.push("Hello");
        stringStack.push("World");
        System.out.println(stringStack.pop());  // Output: World
        System.out.println(stringStack.peek()); // Output: Hello
    }
}
import java.util.ArrayList;
//GenericArrayListStack
public class GenericArrayListStack<T> {
    private ArrayList<T> stackList;

    public GenericArrayListStack() {
        stackList = new ArrayList<>();
    }

    public void push(T value) {
        stackList.add(value);
    }

    public T pop() {
        if (isEmpty()) {
            System.out.println("Stack is empty.");
            return null;
        } else {
            return stackList.remove(stackList.size() - 1);
        }
    }

    public T peek() {
        if (isEmpty()) {
            System.out.println("Stack is empty.");
            return null;
        } else {
            return stackList.get(stackList.size() - 1);
        }
    }

    public boolean isEmpty() {
        return stackList.isEmpty();
    }

    public int size() {
        return stackList.size();
    }
}
//Main
public class Main {
    public static void main(String[] args) {
        // Stack for Integers
        GenericArrayListStack<Integer> intStack = new GenericArrayListStack<>();
        intStack.push(1);
        intStack.push(2);
        System.out.println(intStack.pop());  // Output: 2
        System.out.println(intStack.peek()); // Output: 1

        // Stack for Doubles
        GenericArrayListStack<Double> doubleStack = new GenericArrayListStack<>();
        doubleStack.push(1.1);
        doubleStack.push(2.2);
        System.out.println(doubleStack.pop());  // Output: 2.2
        System.out.println(doubleStack.peek()); // Output: 1.1

        // Stack for Strings
        GenericArrayListStack<String> stringStack = new GenericArrayListStack<>();
        stringStack.push("Hello");
        stringStack.push("World");
        System.out.println(stringStack.pop());  // Output: World
        System.out.println(stringStack.peek()); // Output: Hello
    }
}
//GenericArrayQueue
public class GenericArrayQueue<T> {
    private T[] queueArray;
    private int front;
    private int rear;
    private int maxSize;
    private int currentSize;

    @SuppressWarnings("unchecked")
    public GenericArrayQueue(int size) {
        maxSize = size;
        queueArray = (T[]) new Object[maxSize];
        front = 0;
        rear = -1;
        currentSize = 0;
    }

    public void enqueue(T value) {
        if (isFull()) {
            System.out.println("Queue is full.");
        } else {
            rear = (rear + 1) % maxSize;
            queueArray[rear] = value;
            currentSize++;
        }
    }

    public T dequeue() {
        if (isEmpty()) {
            System.out.println("Queue is empty.");
            return null;
        } else {
            T temp = queueArray[front];
            front = (front + 1) % maxSize;
            currentSize--;
            return temp;
        }
    }

    public T peek() {
        if (isEmpty()) {
            System.out.println("Queue is empty.");
            return null;
        } else {
            return queueArray[front];
        }
    }

    public boolean isEmpty() {
        return (currentSize == 0);
    }
    
    public boolean isFull() {
        return (currentSize == maxSize);
    }

    public int size() {
        return currentSize;
    }
}
//Node.java
public class Node<T> {
    T data;
    Node<T> next;

    public Node(T data) {
        this.data = data;
        this.next = null;
    }
}
//GenericLinkedListQueue
public class GenericLinkedListQueue<T> {
    private Node<T> front;
    private Node<T> rear;
    private int size;

    public GenericLinkedListQueue() {
        front = null;
        rear = null;
        size = 0;
    }

    public void enqueue(T value) {
        Node<T> newNode = new Node<>(value);
        if (isEmpty()) {
            front = newNode;
        } else {
            rear.next = newNode;
        }
        rear = newNode;
        size++;
    }

    public T dequeue() {
        if (isEmpty()) {
            System.out.println("Queue is empty.");
            return null;
        } else {
            T value = front.data;
            front = front.next;
            if (front == null) {
                rear = null;
            }
            size--;
            return value;
        }
    }

    public T peek() {
        if (isEmpty()) {
            System.out.println("Queue is empty.");
            return null;
        } else {
            return front.data;
        }
    }

    public boolean isEmpty() {
        return (size == 0);
    }

    public int size() {
        return size;
    }
}
//Main
public class Main {
    public static void main(String[] args) {
        // Array-based queue
        GenericArrayQueue<Integer> intArrayQueue = new GenericArrayQueue<>(10);
        intArrayQueue.enqueue(1);
        intArrayQueue.enqueue(2);
        System.out.println(intArrayQueue.dequeue());  // Output: 1
        System.out.println(intArrayQueue.peek()); // Output: 2

        GenericArrayQueue<Double> doubleArrayQueue = new GenericArrayQueue<>(10);
        doubleArrayQueue.enqueue(1.1);
        doubleArrayQueue.enqueue(2.2);
        System.out.println(doubleArrayQueue.dequeue());  // Output: 1.1
        System.out.println(doubleArrayQueue.peek()); // Output: 2.2

        GenericArrayQueue<String> stringArrayQueue = new GenericArrayQueue<>(10);
        stringArrayQueue.enqueue("Hello");
        stringArrayQueue.enqueue("World");
        System.out.println(stringArrayQueue.dequeue());  // Output: Hello
        System.out.println(stringArrayQueue.peek()); // Output: World

        // Linked list-based queue
        GenericLinkedListQueue<Integer> intLinkedListQueue = new GenericLinkedListQueue<>();
        intLinkedListQueue.enqueue(1);
        intLinkedListQueue.enqueue(2);
        System.out.println(intLinkedListQueue.dequeue());  // Output: 1
        System.out.println(intLinkedListQueue.peek()); // Output: 2

        GenericLinkedListQueue<Double> doubleLinkedListQueue = new GenericLinkedListQueue<>();
        doubleLinkedListQueue.enqueue(1.1);
        doubleLinkedListQueue.enqueue(2.2);
        System.out.println(doubleLinkedListQueue.dequeue());  // Output: 1.1
        System.out.println(doubleLinkedListQueue.peek()); // Output: 2.2

        GenericLinkedListQueue<String> stringLinkedListQueue = new GenericLinkedListQueue<>();
        stringLinkedListQueue.enqueue("Hello");
        stringLinkedListQueue.enqueue("World");
        System.out.println(stringLinkedListQueue.dequeue());  // Output: Hello
        System.out.println(stringLinkedListQueue.peek()); // Output: World
    }
}
import java.util.Scanner;

class Node<T> {
    T data;
    Node<T> next;

    public Node(T data) {
        this.data = data;
        this.next = null;
    }
}

class GenericStackArray<T> {
    private T[] stackArray;
    private int top;
    private int maxSize;

    @SuppressWarnings("unchecked")
    public GenericStackArray(int size) {
        this.maxSize = size;
        this.stackArray = (T[]) new Object[maxSize];
        this.top = -1;
    }

    public void push(T item) {
        if (top < maxSize - 1) {
            stackArray[++top] = item;
        } else {
            System.out.println("Stack Overflow");
        }
    }

    public T pop() {
        if (top >= 0) {
            return stackArray[top--];
        } else {
            System.out.println("Stack Underflow");
            return null;
        }
    }
public T peek() {
        if (top == -1) {
            System.out.println("Stack is empty.");
            return null;
        } else {
            return stackArray[top];
        }
    }

    public boolean isEmpty() {
        return top == -1;
    }
}

class GenericStackLinkedList<T> {
    private Node<T> top;

    public GenericStackLinkedList() {
        this.top = null;
    }

    public void push(T item) {
        Node<T> newNode = new Node<>(item);
        newNode.next = top;
        top = newNode;
    }

    public T pop() {
        if (top == null) {
            System.out.println("Stack Underflow");
            return null;
        }
        T data = top.data;
        top = top.next;
        return data;
    }
public T peek() {
        if (top == null) {
            System.out.println("Stack is empty.");
            return null;
        } else {
            return top.data;
        }
    }
    public boolean isEmpty() {
        return top == null;
    }
}

public class Main{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("ARRAY....");
        GenericStackArray<Integer> intArrayStack = new GenericStackArray<>(10);
        intArrayStack.push(1);
        intArrayStack.push(2);
        System.out.println(intArrayStack.pop());  // Output: 2
        System.out.println(intArrayStack.peek()); // Output: 1

        GenericStackArray<Double> doubleArrayStack = new GenericStackArray<>(10);
        doubleArrayStack.push(1.1);
        doubleArrayStack.push(2.2);
        System.out.println(doubleArrayStack.pop());  // Output: 2.2
        System.out.println(doubleArrayStack.peek()); // Output: 1.1

        GenericStackArray<String> stringArrayStack = new GenericStackArray<>(10);
        stringArrayStack.push("Hello");
        stringArrayStack.push("World");
        System.out.println(stringArrayStack.pop());  // Output: World
        System.out.println(stringArrayStack.peek()); // Output: Hello

System.out.println("\nLINKED LIST....");
        // Linked list-based stack
        GenericStackLinkedList<Integer> intLinkedListStack = new GenericStackLinkedList<>();
        intLinkedListStack.push(1);
        intLinkedListStack.push(2);
        System.out.println(intLinkedListStack.pop());  // Output: 2
        System.out.println(intLinkedListStack.peek()); // Output: 1

        GenericStackLinkedList<Double> doubleLinkedListStack = new GenericStackLinkedList<>();
        doubleLinkedListStack.push(1.1);
        doubleLinkedListStack.push(2.2);
        System.out.println(doubleLinkedListStack.pop());  // Output: 2.2
        System.out.println(doubleLinkedListStack.peek()); // Output: 1.1

        GenericStackLinkedList<String> stringLinkedListStack = new GenericStackLinkedList<>();
        stringLinkedListStack.push("Hello");
        stringLinkedListStack.push("World");
        System.out.println(stringLinkedListStack.pop());  // Output: World
        System.out.println(stringLinkedListStack.peek()); // Output: Hello
}
}
const saveUserData = async (req, res, next) => {
  try {
    if (!Array.isArray(req.body.users)) {
      return res.status(400).json({ message: 'Invalid input format' });
    }

    const results = [];
    const errors = [];

    for (const user of req.body.users) {
      try {
        const saveUser = new saveuser({
          email: user.email,
          password: user.password,
        });

        const savedUser = await saveUser.save();
        const userID = savedUser._id;

        const saveDetail = new saveUserDetails({
          user_id: userID,
          name: user.name,
          phone: user.phone,
          country: user.country,
          file: user.file.filename,
        });

        const savedDetail = await saveDetail.save();

        results.push({
          status: 'success',
          user: savedUser,
          details: savedDetail,
        });
      } catch (error) {
        if (user.file && user.file.path && fs.existsSync(user.file.path)) {
          fs.unlinkSync(user.file.path);
        }
        if (error.name === 'ValidationError') {
          const validationError = {};
          for (const key in error.errors) {
            validationError[key] = error.errors[key].message;
          }
          errors.push({
            user: user,
            error: validationError,
          });
        } else {
          errors.push({
            user: user,
            error: 'Server Error',
          });
        }
      }
    }

    if (errors.length > 0) {
      return res.status(207).json({ results, errors });
    }

    res.status(200).json({ results });
  } catch (error) {
    res.status(500).json({
      message: 'Server Error',
    });
  }
};
//ReverseStringLambda
public class ReverseStringLambda {
    @FunctionalInterface
    interface StringReverser {
        String reverse(String str);
    }
    public static void main(String[] args) {
        StringReverser reverser = (str) -> new StringBuilder(str).reverse().toString();
        String example = "Hello, World!";
        String reversed = reverser.reverse(example);
        System.out.println("Original: " + example);
        System.out.println("Reversed: " + reversed);
    }
}
public class PiLambdaExpression{
    @FunctionalInterface
    interface PiValue{
        double getPi();
    }
    public static void main(String[] args) {
        PiValue pi = () -> Math.PI;
        double p= pi.getPi();
        System.out.println("The value of Pi is: " + p);
    }
}
//BoundedType
public class BoundedArithematic<T extends Number> {
    public double add(T a, T b) {
        return a.doubleValue() + b.doubleValue();
    }
    public double subtract(T a, T b) {
        return a.doubleValue() - b.doubleValue();
    }
    public double multiply(T a, T b) {
        return a.doubleValue() * b.doubleValue();
    }	
   public double divide(T a, T b) {
        if (b.doubleValue() == 0) {
            throw new ArithmeticException("Division by zero is not allowed.");
        }
        return a.doubleValue() / b.doubleValue();
    }
    public static void main(String[] args) {
        BoundedArithematic<Number> calculator = new BoundedArithematic<>();
        Integer a = 10;
        Integer b = 5;
        System.out.println("Addition: " + calculator.add(a, b));
        System.out.println("Subtraction: " + calculator.subtract(a, b));
        System.out.println("Multiplication: " + calculator.multiply(a, b));
        System.out.println("Division: " + calculator.divide(a, b));
    }
}

//Wildcard Arguments
public class MagicBox<T> {
    private T item;

    public void addItem(T item) {
        this.item = item;
        System.out.println("Added item to the magic box: " + item);
    }

    public T getItem() {
                return item;
    }

    public void processBox(MagicBox<? super Integer> box) {
        System.out.println("Items in the box are processed["+box.getItem()+"]"); 
    }

    public static void main(String[] args) {
        
        MagicBox<Integer> integerBox = new MagicBox<>();
        integerBox.addItem(23);
        		
		MagicBox<String> stringBox = new MagicBox<>();
        stringBox.addItem("Shreya");
        	
		
        MagicBox<Boolean> booleanBox = new MagicBox<>();
        booleanBox.addItem(false);
        
		MagicBox<Object> dobubleBox = new MagicBox<>();
        dobubleBox.addItem(23.43);
		
		integerBox.processBox(integerBox);
		dobubleBox.processBox(dobubleBox);
		
		
		
        
    }
}
class AVLNode {
    int key;
    int height;
    AVLNode left;
    AVLNode right;

    public AVLNode(int key) {
        this.key = key;
        this.height = 1;
    }
}

public class AVLTree {
    private AVLNode root;

    public AVLTree() {
        root = null;
    }

    // Insert a key into the AVL tree
    public void insert(int key) {
        root = insertRec(root, key);
    }

    // Helper method to recursively insert a key into the AVL tree
    private AVLNode insertRec(AVLNode node, int key) {
        if (node == null)
            return new AVLNode(key);

        if (key < node.key)
            node.left = insertRec(node.left, key);
        else if (key > node.key)
            node.right = insertRec(node.right, key);
        else // Duplicate keys are not allowed
            return node;

        // Update height of this node
        node.height = 1 + Math.max(height(node.left), height(node.right));

        // Get balance factor and perform rotations if needed
        int balance = getBalance(node);

        // Left Left Case
        if (balance > 1 && key < node.left.key)
            return rightRotate(node);

        // Right Right Case
        if (balance < -1 && key > node.right.key)
            return leftRotate(node);

        // Left Right Case
        if (balance > 1 && key > node.left.key) {
            node.left = leftRotate(node.left);
            return rightRotate(node);
        }

        // Right Left Case
        if (balance < -1 && key < node.right.key) {
            node.right = rightRotate(node.right);
            return leftRotate(node);
        }

        return node;
    }

    // Perform right rotation
    private AVLNode rightRotate(AVLNode y) {
        AVLNode x = y.left;
        AVLNode T2 = x.right;

        // Perform rotation
        x.right = y;
        y.left = T2;

        // Update heights
        y.height = Math.max(height(y.left), height(y.right)) + 1;
        x.height = Math.max(height(x.left), height(x.right)) + 1;

        return x;
    }

    // Perform left rotation
    private AVLNode leftRotate(AVLNode x) {
        AVLNode y = x.right;
        AVLNode T2 = y.left;

        // Perform rotation
        y.left = x;
        x.right = T2;

        // Update heights
        x.height = Math.max(height(x.left), height(x.right)) + 1;
        y.height = Math.max(height(y.left), height(y.right)) + 1;

        return y;
    }

    // Get height of a node
    private int height(AVLNode node) {
        if (node == null)
            return 0;
        return node.height;
    }

    // Get balance factor of a node
    private int getBalance(AVLNode node) {
        if (node == null)
            return 0;
        return height(node.left) - height(node.right);
    }

    // Find the inorder successor
    private AVLNode minValueNode(AVLNode node) {
        AVLNode current = node;
        while (current.left != null)
            current = current.left;
        return current;
    }

    // Delete a key from the AVL tree
    public void delete(int key) {
        root = deleteRec(root, key);
    }

    // Helper method to recursively delete a key from the AVL tree
    private AVLNode deleteRec(AVLNode root, int key) {
        if (root == null)
            return root;

        if (key < root.key)
            root.left = deleteRec(root.left, key);
        else if (key > root.key)
            root.right = deleteRec(root.right, key);
        else {
            // Node to be deleted found

            // Case 1: Node with one child or no child
            if (root.left == null || root.right == null) {
                AVLNode temp = null;
                if (root.left != null)
                    temp = root.left;
                else
                    temp = root.right;

                // No child case
                if (temp == null) {
                    temp = root;
                    root = null;
                } else // One child case
                    root = temp; // Copy the contents of the non-empty child

                temp = null;
            } else {
                // Case 2: Node with two children
                AVLNode temp = minValueNode(root.right);
                root.key = temp.key;
                root.right = deleteRec(root.right, temp.key);
            }
        }

        // If the tree had only one node then return
        if (root == null)
            return root;

        // Update height of the current node
        root.height = 1 + Math.max(height(root.left), height(root.right));

        // Get balance factor and perform rotations if needed
        int balance = getBalance(root);

        // Left Left Case
        if (balance > 1 && getBalance(root.left) >= 0)
            return rightRotate(root);

        // Left Right Case
        if (balance > 1 && getBalance(root.left) < 0) {
            root.left = leftRotate(root.left);
            return rightRotate(root);
        }

        // Right Right Case
        if (balance < -1 && getBalance(root.right) <= 0)
            return leftRotate(root);

        // Right Left Case
        if (balance < -1 && getBalance(root.right) > 0) {
            root.right = rightRotate(root.right);
            return leftRotate(root);
        }

        return root;
    }

    // Inorder traversal of the AVL tree
    public void inorder() {
        inorderRec(root);
        System.out.println();
    }

    // Helper method to recursively perform inorder traversal of the AVL tree
    private void inorderRec(AVLNode root) {
        if (root != null) {
            inorderRec(root.left);
            System.out.print(root.key + " ");
            inorderRec(root.right);
        }
    }

    public static void main(String[] args) {
        AVLTree tree = new AVLTree();

        // Insert elements into the AVL tree
        tree.insert(9);
        tree.insert(5);
        tree.insert(10);
        tree.insert(0);
        tree.insert(6);
        tree.insert(11);
        tree.insert(-1);
        tree.insert(1);
        tree.insert(2);

        // Inorder traversal of the AVL tree
        System.out.println("Inorder traversal of AVL tree:");
        tree.inorder();

        // Delete an element from the AVL tree
        int keyToDelete = 10;
        System.out.println("Deleting key " + keyToDelete + " from AVL tree");
        tree.delete(keyToDelete);

        // Inorder traversal after deletion
        System.out.println("Inorder traversal after deletion:");
        tree.inorder();
    }
}
//ArrayList
import java.util.ArrayList;
import java.util.Iterator;

public class ArrayListIteratorExample {
    public static void main(String[] args) {
        ArrayList<String> fruits = new ArrayList<>();
        fruits.add("Apple");
        fruits.add("Banana");
        fruits.add("Cherry");
        
        Iterator<String> iterator = fruits.iterator();
        
        System.out.println("Using Iterator to traverse through the ArrayList:");
        while (iterator.hasNext()) {
            String fruit = iterator.next();
            System.out.println(fruit);
        }
        
        System.out.println("\nUsing for-each loop to traverse through the ArrayList:");
        for (String fruit : fruits) {
            System.out.println(fruit);
        }
        
        iterator = fruits.iterator(); // Reset the iterator
        while (iterator.hasNext()) {
            String fruit = iterator.next();
            if (fruit.startsWith("B")) {
                iterator.remove(); // Remove elements that start with "B"
            }
        }
        
        System.out.println("\nArrayList after removal of elements that start with 'B':");
        for (String fruit : fruits) {
            System.out.println(fruit);
        }
    }
}

//LinkedList
import java.util.LinkedList;
import java.util.Iterator;

public class LinkedListIteratorExample {
    public static void main(String[] args) {
        LinkedList<String> fruits = new LinkedList<>();
        fruits.add("Apple");
        fruits.add("Banana");
        fruits.add("Cherry");
        
        Iterator<String> iterator = fruits.iterator();
        
        System.out.println("Using Iterator to traverse through the LinkedList:");
        while (iterator.hasNext()) {
            String fruit = iterator.next();
            System.out.println(fruit);
        }
        
        System.out.println("\nUsing for-each loop to traverse through the LinkedList:");
        for (String fruit : fruits) {
            System.out.println(fruit);
        }
        
        iterator = fruits.iterator(); // Reset the iterator
        while (iterator.hasNext()) {
            String fruit = iterator.next();
            if (fruit.startsWith("B")) {
                iterator.remove(); 
            }
        }
        
        System.out.println("\nLinkedList after removal of elements that start with 'B':");
        for (String fruit : fruits) {
            System.out.println(fruit);
        }
    }
}
class TreeNode {
    int key;
    TreeNode left;
    TreeNode right;

    public TreeNode(int key) {
        this.key = key;
        this.left = null;
        this.right = null;
    }
}

public class BinarySearchTree {
    private TreeNode root;

    public BinarySearchTree() {
        root = null;
    }

    // Insert a key into the BST
    public void insert(int key) {
        root = insertRec(root, key);
    }

    // Helper method to recursively insert a key into the BST
    private TreeNode insertRec(TreeNode root, int key) {
        if (root == null) {
            root = new TreeNode(key);
            return root;
        }

        if (key < root.key)
            root.left = insertRec(root.left, key);
        else if (key > root.key)
            root.right = insertRec(root.right, key);

        return root;
    }

    // Inorder traversal of the BST
    public void inorder() {
        inorderRec(root);
        System.out.println();
    }

    // Helper method to recursively perform inorder traversal of the BST
    private void inorderRec(TreeNode root) {
        if (root != null) {
            inorderRec(root.left);
            System.out.print(root.key + " ");
            inorderRec(root.right);
        }
    }

    // Delete a key from the BST
    public void delete(int key) {
        root = deleteRec(root, key);
    }

    // Helper method to recursively delete a key from the BST
    private TreeNode deleteRec(TreeNode root, int key) {
        if (root == null)
            return root;

        // Search for the key to be deleted
        if (key < root.key)
            root.left = deleteRec(root.left, key);
        else if (key > root.key)
            root.right = deleteRec(root.right, key);
        else {
            // Key found, delete this node

            // Case 1: Node with only one child or no child
            if (root.left == null)
                return root.right;
            else if (root.right == null)
                return root.left;

            // Case 2: Node with two children
            // Get the inorder successor (smallest in the right subtree)
            root.key = minValue(root.right);

            // Delete the inorder successor
            root.right = deleteRec(root.right, root.key);
        }

        return root;
    }

    // Helper method to find the inorder successor (smallest in the right subtree)
    private int minValue(TreeNode node) {
        int minValue = node.key;
        while (node.left != null) {
            minValue = node.left.key;
            node = node.left;
        }
        return minValue;
    }

    public static void main(String[] args) {
        BinarySearchTree tree = new BinarySearchTree();

        // Insert elements into the BST
        tree.insert(50);
        tree.insert(30);
        tree.insert(20);
        tree.insert(40);
        tree.insert(70);
        tree.insert(60);
        tree.insert(80);

        // Inorder traversal of the BST
        System.out.println("Inorder traversal of BST:");
        tree.inorder();

        // Delete an element from the BST
        int keyToDelete = 30;
        System.out.println("Deleting key " + keyToDelete + " from BST");
        tree.delete(keyToDelete);

        // Inorder traversal after deletion
        System.out.println("Inorder traversal after deletion:");
        tree.inorder();
    }
}
<html>
<body>
<form action = "sucess.html">
<h1><ul>Registration</hl>
<label>uname :</label>
<input type = "Text" id = "u1"><br>

password:<input type = "password" id="pr"><br>

email:<input type = "Text"><br>

Gender:<input type="radio" id="r1">male
       <input type="radio" id="r1">female
       <input type="radio" id="r1">none

state:
 <select>
 <option value = "TS">TS
 <option value = "AP">AP
 <option value = "TN">TN
 <option value = "BHR">BHR
 </select>

course:<input type="checkbox">java
       <input type="checkbox">se
       <input type="checkbox">wt
       textarea.min=70,max=1000
<button type:"submit"value="click.me"> 
<html>
<body>
<form action ="successfull.html">
<h1>Registration</h1>
<lable>username:<lable>
<input type="text"id=U1><br><br>
<lable>password:<lable>
<input type="password"id="pr"><br><br>
<lable>email:<lable>
<input type="text"id="pr"><br><br>
<lable>gender:<lable>
<input type="radio"id="R1">maless
<input type="radio"id="R2">female<br><br>
state:
<select><br>
<option value="TS">TS
<option value="AP">AP
</select><br>
course:<input type="checkbox">java
	<input type="checkbox">SE
	<input type="checkbox">WT
<lable>remark:<lable><br>
<input type="textarea"min=50><br>	
<button type:"submit">submit
void setup() 
     {  // initialize digital pin LED_BUILTIN as an output.           	
         pinMode(LED_BUILTIN, OUTPUT);
      }
void loop() {  
     digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on
            delay(1000);   // wait for a second 
     digitalWrite(LED_BUILTIN, LOW);   // turn the LED off
            delay(1000);   // wait for a second
}
import RPi.GPIO as GPIO
from time import sleep
GPIO.setwarnings(false)
GPIO.setmode(GPIO.BCM)
Blink_count=3
count=0
LEDPin=17
GPIO.setup(LEDPin,GPIO.OUT)
try:
	while count < Blink_count:
    	GPIO.output(LEDPin,False)
		print("LED OFF")
		sleep(1)
		count+=1
finally:
	GPIO.cleanup()
<html>
<body> 
<br><br>
<br>
<p align="center">
<b>SUCCESSFUL</b>
</html>
</body>
int trig=12;     // GPIO Pin D6
int echo=14;     //GPIO Pin D5
int time_microsec;
int time_ms;
int dist_cm;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(12,OUTPUT);
  pinMode(14,INPUT);

}

void loop() {
  // put your main code here, to run repeatedly:
digitalWrite(trig,LOW);
delayMicroseconds(2);
digitalWrite(trig,HIGH);
delayMicroseconds(10);
digitalWrite(trig,LOW);

//pulseIn gives time in micro seconds, 1Sec= 1000000 microseconds
time_microsec= pulseIn(echo,HIGH);
time_ms=time_microsec/1000;

dist_cm= (34*time_ms)/2;

Serial.print("Time to travel: ");
Serial.println(time_ms,1);
Serial.print("ms / ");
Serial.print("Distance: ");
Serial.print(dist_cm,1);
Serial.print("cm ");

delay(2000);
import RPi.GPIO as GPIO  
import time  
GPIO.setmode(GPIO.BCM)  
GPIO_TRIG = 11 
 GPIO_ECHO = 18 
GPIO.setup(GPIO_TRIG, GPIO.OUT) 
GPIO.setup(GPIO_ECHO, GPIO.IN)
GPIO.output(GPIO_TRIG, GPIO.LOW) 
 Time.sleep(2)  
GPIO.output(GPIO_TRIG, GPIO.HIGH) 
 Time.sleep(0.00001)  
GPIO.output(GPIO_TRIG, GPIO.LOW) 
 while GPIO.input(GPIO_ECHO)==0:  
  start_time = time.time()  
while GPIO.input(GPIO_ECHO)==1: 
 Bounce_back_time = time.time()  
 pulse_duration = Bounce_back_time - start_time 
 distance = round(pulse_duration * 17150, 2)  
print (f"Distance: {distance} cm")  
GPIO.cleanup()
#include <DHT.h>
#include <DHT_U.h>

#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN,DHTTYPE);

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.println(F("DHTxx test!"));
  dht.begin();

}

void loop() {
  // put your main code here, to run repeatedly:
  delay(2000);
  float h= dht.readHumidity();
  float t = dht.readTemperature();
  float f = dht.readTemperature(true);
  if(isnan(h)||isnan(t)||isnan(f))
  {
    Serial.println(F("Failed to read fromDHT sensor !"));
    return;
  }
  Serial.print(F("Humidity : "));
  Serial.print(h);
  Serial.print(F("% Temperature : "));
  Serial.print(t);
  Serial.print(F(" C : "));
  Serial.print(f);
  Serial.print(F(" F : "));
  Serial.println(" ");
  

}
$ git remote add origin https://github.com/OWNER/REPOSITORY.git
# Set a new remote

$ git remote -v
# Verify new remote
> origin  https://github.com/OWNER/REPOSITORY.git (fetch)
> origin  https://github.com/OWNER/REPOSITORY.git (push)
#include <stdio.h>

// Function to print the top part of the decorative box
void print_top() {
    printf("/\\/\\/\\/\\/\\\n");
}

// Function to print the bottom part of the decorative box
void print_bottom() {
    printf("\\/\\/\\/\\/\\/\n");
}

// Function to print the middle part of the decorative box
void print_middle(int how_many) {
    for (int i = 0; i < how_many; i++) {
        printf("\\        /\n");
        printf("/        \\\n");
    }
}

// Main function to demonstrate the functionality
int main() {
    int how_many;

    // Prompt the user for the number of middle parts
    printf("How many middle parts? \n");
    scanf("%d", &how_many);

    // Print the top part
    print_top();
    
    // Print the middle part specified number of times
    print_middle(how_many);
    
    // Print the bottom part
    print_bottom();
    
    return 0;
}
#include <stdio.h>

void print_ascii_rectangle(char symbol, int width, int height)
{
    for(int i =0;i<height;i++)
    {
        for(int j=0;j<width;j++)
        {
            printf("%c",symbol);
        }
        printf("\n");
    }
}

int main()
{
    char symbol;
    int width;
    int height;
    printf("Please enter an ASCII symbol:\n");
    scanf(" %c",&symbol);
    
    printf("Please enter the width:\n");
    scanf("%d",&width);
    printf("Please enter the height:\n");
    scanf("%d",&height);
    print_ascii_rectangle(symbol,width,height);
}
<div class="container text-center">
  <div class="row align-items-end">
    <div class="col">
      One of three columns
    </div>
    <div class="col">
      One of three columns
    </div>
    <div class="col">
      One of three columns
    </div>
  </div>
</div>
#include <stdio.h>

void print_quadratic(int a, int b, int c)
{
    if(a!=0)
    {
        printf("%dx^2 ",a);
    }
    if(b!=0)
    {
        if(b>0)
        {
            printf("+ %dx ",b);
        }
        else
        {
            printf("- %dx ",-b);
        }
    }
    if(c!=0)
    {
        if(c>0)
        {
            printf("+ %d ",c);
        }
        else
        {
            printf("- %d ",-c);
        }
    }
    
}

int main (void)
{
    printf("Enter a:\n");
    printf("Enter b:\n");
    printf("Enter c:\n");
    int a,b,c;
    
    scanf("%d%d%d",&a,&b,&c);
    print_quadratic(a,b,c);
    
}

vector<int> sieveOfEratosthenes(int n) {
    vector<bool> isPrime(n + 1, true);
    isPrime[0] = isPrime[1] = false; // 0 and 1 are not prime numbers

    for (int i = 2; i * i <= n; i++) {
        if (isPrime[i]) {
            for (int j = i * i; j <= n; j += i) {
                isPrime[j] = false;
            }
        }
    }

    std::vector<int> primes;
    for (int i = 2; i <= n; i++) {
        if (isPrime[i]) {
            primes.push_back(i);
        }
    }

    return primes;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        body, html {
            margin: 0;
            padding: 0;
            width: 100%;
            height: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
            background-color: black;
        }
        img {
            max-width: 100%;
            max-height: 100%;
        }
    </style>
    <title>Image Viewer</title>
</head>
<body>
    <img src="path_to_your_image.jpg" alt="Image">
</body>
</html>
import java.util.ArrayList;
import java.util.List;

class TreeNode<T extends Comparable<T>> {
    T value;
    TreeNode<T> left;
    TreeNode<T> right;

    TreeNode(T value) {
        this.value = value;
        left = null;
        right = null;
    }
}

public class BinarySearchTree<T extends Comparable<T>> {
    private TreeNode<T> root;

    // Method to insert a new value in the BST
    public void insert(T value) {
        root = insertRec(root, value);
    }

    private TreeNode<T> insertRec(TreeNode<T> root, T value) {
        if (root == null) {
            root = new TreeNode<>(value);
            return root;
        }
        if (value.compareTo(root.value) < 0) {
            root.left = insertRec(root.left, value);
        } else if (value.compareTo(root.value) > 0) {
            root.right = insertRec(root.right, value);
        }
        return root;
    }

    // Method for inorder traversal
    public void inorder() {
        List<T> result = new ArrayList<>();
        inorderRec(root, result);
        System.out.println("Inorder: " + result);
    }

    private void inorderRec(TreeNode<T> root, List<T> result) {
        if (root != null) {
            inorderRec(root.left, result);
            result.add(root.value);
            inorderRec(root.right, result);
        }
    }

    // Method for preorder traversal
    public void preorder() {
        List<T> result = new ArrayList<>();
        preorderRec(root, result);
        System.out.println("Preorder: " + result);
    }

    private void preorderRec(TreeNode<T> root, List<T> result) {
        if (root != null) {
            result.add(root.value);
            preorderRec(root.left, result);
            preorderRec(root.right, result);
        }
    }

    // Method for postorder traversal
    public void postorder() {
        List<T> result = new ArrayList<>();
        postorderRec(root, result);
        System.out.println("Postorder: " + result);
    }

    private void postorderRec(TreeNode<T> root, List<T> result) {
        if (root != null) {
            postorderRec(root.left, result);
            postorderRec(root.right, result);
            result.add(root.value);
        }
    }

    // Main method to test the BST
    public static void main(String[] args) {
        BinarySearchTree<Integer> bst = new BinarySearchTree<>();
        bst.insert(50);
        bst.insert(30);
        bst.insert(20);
        bst.insert(40);
        bst.insert(70);
        bst.insert(60);
        bst.insert(80);

        bst.inorder();   // Inorder traversal
        bst.preorder();  // Preorder traversal
        bst.postorder(); // Postorder traversal
    }
}
import java.util.ArrayList;
import java.util.List;

class TreeNode<T extends Comparable<T>> {
    T value;
    TreeNode<T> left;
    TreeNode<T> right;

    TreeNode(T value) {
        this.value = value;
        left = null;
        right = null;
    }
}

public class BinarySearchTree<T extends Comparable<T>> {
    private TreeNode<T> root;

    // Method to insert a new value in the BST
    public void insert(T value) {
        root = insertRec(root, value);
    }

    private TreeNode<T> insertRec(TreeNode<T> root, T value) {
        if (root == null) {
            root = new TreeNode<>(value);
            return root;
        }
        if (value.compareTo(root.value) < 0) {
            root.left = insertRec(root.left, value);
        } else if (value.compareTo(root.value) > 0) {
            root.right = insertRec(root.right, value);
        }
        return root;
    }

    // Method for inorder traversal
    public void inorder() {
        List<T> result = new ArrayList<>();
        inorderRec(root, result);
        System.out.println("Inorder: " + result);
    }

    private void inorderRec(TreeNode<T> root, List<T> result) {
        if (root != null) {
            inorderRec(root.left, result);
            result.add(root.value);
            inorderRec(root.right, result);
        }
    }

    // Method for preorder traversal
    public void preorder() {
        List<T> result = new ArrayList<>();
        preorderRec(root, result);
        System.out.println("Preorder: " + result);
    }

    private void preorderRec(TreeNode<T> root, List<T> result) {
        if (root != null) {
            result.add(root.value);
            preorderRec(root.left, result);
            preorderRec(root.right, result);
        }
    }

    // Method for postorder traversal
    public void postorder() {
        List<T> result = new ArrayList<>();
        postorderRec(root, result);
        System.out.println("Postorder: " + result);
    }

    private void postorderRec(TreeNode<T> root, List<T> result) {
        if (root != null) {
            postorderRec(root.left, result);
            postorderRec(root.right, result);
            result.add(root.value);
        }
    }

    // Main method to test the BST
    public static void main(String[] args) {
        BinarySearchTree<Integer> bst = new BinarySearchTree<>();
        bst.insert(50);
        bst.insert(30);
        bst.insert(20);
        bst.insert(40);
        bst.insert(70);
        bst.insert(60);
        bst.insert(80);

        bst.inorder();   // Inorder traversal
        bst.preorder();  // Preorder traversal
        bst.postorder(); // Postorder traversal
    }
}
declare 
   invalid_sal Exception;
   s employ.sal%type:=&sal;
begin 
   if (s<3000) then
     raise invalid_sal;
   else
     --insert into employ(sal) values(s);
     dbms_output.put_line('Record inserted');
   end if;
Exception
      when invalid_sal then
           dbms_output.put_line('sal greater ');
end;
/
CREATE TABLE empc (
    emp_id NUMBER PRIMARY KEY,
    name VARCHAR2(100),
    hire_date DATE
);

DECLARE
    CURSOR c IS
        SELECT empno, ename, hiredate
        FROM employee
        WHERE (SYSDATE - hiredate) / 365.25 >= 23;  
    emp_record c%ROWTYPE;
BEGIN
    OPEN c;
    LOOP
        FETCH c INTO emp_record;
        EXIT WHEN c%NOTFOUND;
        INSERT INTO empc (emp_id, name, hire_date)
        VALUES (emp_record.empno, emp_record.ename, emp_record.hiredate);
    END LOOP;
    CLOSE c;
    COMMIT;
EXCEPTION
    WHEN OTHERS THEN
        DBMS_OUTPUT.PUT_LINE('An error occurred: ');
      
END;
/
star

Sun Jun 09 2024 11:28:59 GMT+0000 (Coordinated Universal Time)

@meanaspotato #c #pointer

star

Sun Jun 09 2024 11:27:57 GMT+0000 (Coordinated Universal Time)

@meanaspotato #c

star

Sun Jun 09 2024 11:26:45 GMT+0000 (Coordinated Universal Time)

@meanaspotato #c

star

Sun Jun 09 2024 11:10:04 GMT+0000 (Coordinated Universal Time)

@meanaspotato #c

star

Sun Jun 09 2024 10:43:55 GMT+0000 (Coordinated Universal Time)

@odesign

star

Sun Jun 09 2024 10:37:51 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 10:29:01 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 10:24:07 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 10:23:11 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 10:21:43 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 10:19:16 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 10:17:11 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 10:15:19 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 10:09:15 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 09:59:59 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 09:58:26 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 09:50:27 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 09:48:54 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 09:45:52 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 09:42:49 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 09:40:12 GMT+0000 (Coordinated Universal Time)

@sid_balar

star

Sun Jun 09 2024 09:07:48 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 09:07:15 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 09:06:02 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 07:43:09 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 07:40:44 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 07:17:04 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 04:52:06 GMT+0000 (Coordinated Universal Time)

@user01

star

Sun Jun 09 2024 04:51:34 GMT+0000 (Coordinated Universal Time)

@user01

star

Sun Jun 09 2024 04:51:13 GMT+0000 (Coordinated Universal Time)

@user01

star

Sun Jun 09 2024 04:50:55 GMT+0000 (Coordinated Universal Time)

@user01

star

Sun Jun 09 2024 04:50:28 GMT+0000 (Coordinated Universal Time)

@user01

star

Sun Jun 09 2024 04:49:56 GMT+0000 (Coordinated Universal Time)

@user01

star

Sun Jun 09 2024 04:49:24 GMT+0000 (Coordinated Universal Time)

@user01

star

Sun Jun 09 2024 04:49:01 GMT+0000 (Coordinated Universal Time)

@user01

star

Sun Jun 09 2024 00:07:29 GMT+0000 (Coordinated Universal Time) https://docs.github.com/en/get-started/getting-started-with-git/managing-remote-repositories

@calazar23

star

Sat Jun 08 2024 23:59:25 GMT+0000 (Coordinated Universal Time) https://docs.github.com/en/repositories/creating-and-managing-repositories/transferring-a-repository

@calazar23

star

Sat Jun 08 2024 22:11:09 GMT+0000 (Coordinated Universal Time)

@meanaspotato #c

star

Sat Jun 08 2024 21:53:55 GMT+0000 (Coordinated Universal Time)

@meanaspotato #c

star

Sat Jun 08 2024 16:30:33 GMT+0000 (Coordinated Universal Time) https://getbootstrap.com/docs/5.3/layout/columns/

@CHIBUIKE

star

Sat Jun 08 2024 15:24:09 GMT+0000 (Coordinated Universal Time) https://nodejs.org/api/net.html#socketunref

@calazar23

star

Sat Jun 08 2024 11:26:05 GMT+0000 (Coordinated Universal Time)

@meanaspotato #c

star

Sat Jun 08 2024 07:49:35 GMT+0000 (Coordinated Universal Time)

@divay6677 ##c++

star

Sat Jun 08 2024 06:53:36 GMT+0000 (Coordinated Universal Time)

@Xcalsen1

star

Sat Jun 08 2024 06:03:29 GMT+0000 (Coordinated Universal Time) https://gunsbuyerusa.com/product-category/ak74-rifles-for-sale/

@ak74uforsale

star

Sat Jun 08 2024 06:02:56 GMT+0000 (Coordinated Universal Time) https://gunsbuyerusa.com/product/barwarus-bw-t33-bw-t4-bravo-rail-set/

@ak74uforsale

star

Sat Jun 08 2024 05:23:53 GMT+0000 (Coordinated Universal Time)

@signup

star

Sat Jun 08 2024 05:21:49 GMT+0000 (Coordinated Universal Time)

@signup

star

Sat Jun 08 2024 02:29:50 GMT+0000 (Coordinated Universal Time)

@signup

star

Sat Jun 08 2024 02:28:55 GMT+0000 (Coordinated Universal Time)

@signup

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension