Posts

DS_LAB- Exam NOTES

 EXP 1: C program to traverse an array #include < stdio.h > int main () {     int arr [ 5 ] = { 10 , 20 , 30 , 40 , 50 };  // Declare and initialize an array     int i ;     printf (" The elements of the array are: \n ");     for ( i = 0 ; i < 5 ; i ++ ) {         printf (" Element at index %d : %d \n ", i , arr [ i ]);     }     return 0 ; } Exp: 2 C program to insert an element into an array #include < stdio.h > int main () {     int arr [ 100 ], n , i , pos , value ;     // Get number of elements     printf (" Enter number of elements in array: ");     scanf (" %d ", & n );     // Get elements from user     printf (" Enter %d elements: \n ", n );     for ( i = 0 ; i < n ; i ++ ) {         scanf (" %d ", & arr [ i ]);     }     //...

WEB TECH lab

  < html > < head >     < title >Number in word</ title >     < script >         function convert () {             var num = document . forms [" frm1 "]. num . value ;             document . forms [" frm1 "]. words . value = "";             if ( isNaN ( num )) {                 alert (" Please enter a number ");             } else if ( num < 0 || num > 999 ) {                 alert (" Please enter a number between 0 and 999 ");             } else {                 var len = num .length;                 var words = "";                 for ( v...

DS LAB 3/21/2025

#include <stdio.h> #include <limits.h> #include <stdbool.h> #define V 5   int minKey ( int key [] , bool mstSet [] ) {     int min = INT_MAX , minIndex ;     for ( int v = 0 ; v < V ; v ++ ) {         if ( ! mstSet [ v ] && key [ v ] < min ) {             min = key [ v ], minIndex = v ;         }     }     return minIndex ; } void printMST ( int parent [] , int graph [ V ][ V ]) {     printf ( "Edge \t Weight \n " );     for ( int i = 1 ; i < V ; i ++ ) {         printf ( " %d - %d \t %d \n " , parent [ i ], i , graph [ i ][ parent [ i ]]);     } } void primMST ( int graph [ V ][ V ]) {     int parent [ V ];       int key [ V ];         bool mstSet [ V ];     for ( int i = 0 ; i < V ; i...

ds

  #include <stdio.h> #include <stdlib.h> // Define the structure for a node in the tree struct TreeNode {     int data;     struct TreeNode * left;     struct TreeNode * right; }; // Function to create a new node struct TreeNode * createNode ( int data ) {     struct TreeNode * newNode = ( struct TreeNode * ) malloc ( sizeof ( struct TreeNode));     newNode -> data = data;     newNode -> left = NULL ;     newNode -> right = NULL ;     return newNode; } // Function to insert a node in the tree (basic BST insert) struct TreeNode * insertNode ( struct TreeNode * root , int data ) {     if (root == NULL ) {         return createNode (data); // If the tree is empty, create the first node     }     if (data < root -> data ) {         root -> left = insertNode ( root -> lef...

DS LAB BSC(cs) 2nd SEM 2025

Queue Implementation Using Array #include <stdio.h> #include <stdlib.h> #define MAX 5 // maximum size of the queue // Define a Queue structure struct Queue {     int front , rear ;     int arr [ MAX ]; }; // Function to initialize the queue void initQueue ( struct Queue * q ) {     q -> front = - 1 ;     q -> rear = - 1 ; } // Check if the queue is empty int isEmpty ( struct Queue * q ) {     return ( q -> front == - 1 ); } // Check if the queue is full int isFull ( struct Queue * q ) {     return ( q -> rear == MAX - 1 ); } // Enqueue operation (add an element to the queue) void enqueue ( struct Queue * q , int value ) {     if ( isFull ( q )) {         printf ( "Queue is full! Cannot enqueue %d \n " , value );     } else {         if ( q -> front == - 1 ) { // If the queue is empty, initialize front ...

HTML WEB LAB BSC.(CS) 2nd SEM

Image
  <!-- 15.  Create the following table in HTML with Dummy Data:  --> < html >     < head >         < title > EXP.NO 15 </ title >     </ head >     < body >         < table Border = "10px" width = "500" >         < tr >             < th > Reg.NO </ th >             < th > Student Name </ th >             < th > Year </ th >             < th > Date of Admission </ th >         </ tr >               < tr >             < td > 202436706 </ td >             < td > Samprity </ td >           ...

Popular posts from this blog

C-Programming of Class 12

C-Program of Class 11