Posts

Showing posts from August, 2025

Bubble sort Algorithm in C

Bubble sort algorithm  The selected code implements the bubble sort algorithm. Here are the steps in algorithm form: Start with the array you want to sort. Set up a loop that will iterate through the entire array. Let's call this the outer loop . It ensures that we make enough passes to sort all the elements. Inside the outer loop, set up a second loop, the inner loop , that iterates from the beginning of the array up to the last unsorted element. Inside the inner loop, compare the current element with the element right next to it. If the current element is greater than the next one, swap their positions. Repeat steps 4 and 5 for every pair of adjacent elements in the inner loop. After one full pass of the inner loop, the largest unsorted element will have "bubbled up" to its correct position at the end of the array. The outer loop then repeats the process on the remaining unsorted portion of the array. Stop when the outer loop completes, and the entire array is sorted...

Shell Scripting Codes - Loops

 Shell Scripting-Loops Practice Questions  1.Write Shell Script to print 1 to 10 numbers  #!/bin/bash for (( i=1; i<=10; i++ )) do   echo $i done 2.Write shell script to print multiplication table of input number  #!/bin/bash echo "Enter the number for the multiplication table:" read num for (( i=1; i<=10; i++ )) do   product=$((num * i))   echo "$num x $i = $product" done  3.Write shell script to display the 25 to 1 numbers in reverse order  #!/bin/bash for (( i=25; i>=1; i-- )) do   echo $i done  

C Programming Practice Questions

Write a C program to find sum and average of three numbers.  Write a C program to generate prime numbers between 1 to n Write a C program to find the largest of three numbers using an if-else statement. Write a C program to check if a given year is a leap year. A leap year is divisible by 4, but not by 100, unless it is also divisible by 400. Write a C program to reverse a given integer number. For example, if the input is 123 , the output should be 321 . Write a C program to find the factorial of a given number using a for loop. Write a C program to determine if a given string is a palindrome. A palindrome is a word or phrase that reads the same forwards and backwards. Write a C program to find the sum of all elements in an array of integers. Write a C program to perform matrix addition for two 2x2 matrices. The program should take the elements of both matrices as input from the user and display the resulting matrix Write a C program to implement a simple calculator that perform...

Operating System Lab Task-2

  Linux Command Line Tasks System Information: Find out the name and version of the operating system you are running. Display the current date and time. Show your username and user ID. Find out which users are currently logged in. File and Directory Permissions: Create a new, empty file named test_script.sh . Change the permissions of test_script.sh so that it is executable only by the owner. Change the permissions of test_script.sh so that it is readable and writable by the owner, but has no permissions for the group or others. Recursively change the permissions of a directory and all its contents so that the owner has full read, write, and execute permissions, while the group and others have read and execute permissions only. Process Management: Display a list of all running processes on the system. Find a process by its name (e.g., bash or sshd ). Simulate a long-running process (e.g., a simple sleep command) in the background. Stop a process by its Process ID (PID). Forcefu...