Monthly Archives: December 2022

Create Linux ls command C Program

Create Linux ls command C Program – Write a C program under Windows Operating System to create or simulate linux ls command.   Program code #include<stdio.h> #include<dirent.h> int main(int argc, char **argv) { DIR *dp; struct dirent *link; dp=opendir(argv[1]); printf(“\n contents of the directory %s are \n”, argv[1]); while((link=readdir(dp))!=0) printf(“%s\n”,link->d_name); closedir(dp); } Output contents of… Read More »

Loading

Using Linux System Calls Program Operating Systems Lab

Using Linux System Calls Program Operating Systems Lab – Write a C program Using Linux System Calls Program to create a child process using fork() system call. Display suitable message about parent process ID, child process or Error message if child process could not be created. Program Code using fork() getpid() and exit() #include<stdio.h> #include<unistd.h>… Read More »

Loading

SJF Scheduling Algorithm Program Operating System LAB

SJF Scheduling Algorithm Program – Operating System Practicals LAB. Write a C Program to input burst times of N processes and find the Waiting times and Turn around times using SJF – Shortest Job First Scheduling Method in Operating system. Program Code #include<stdio.h> int main() { int bt[20],p[20],wt[20],tat[20],i,j,n,total=0,pos,temp; float avg_wt,avg_tat; printf(“Enter number of process:”); scanf(“%d”,&n);… Read More »

Loading

FCFS Scheduling Algorithm Program in C++

FCFS Scheduling Algorithm Program in C++ : Write a C++ Program To Calculate Average Waiting Time and Average Turn Around Time using FCFS. Program Code: FCFS Scheduling Algorithm Program in C++ We shall use the loop concept and the use of arrays to solve this programming assignment. First of all we will define some variables… Read More »

Loading

Using Pointers Sort Array

Using Pointers Sort Array – Write a program in C Programming Language To input N numbers and arrange it in Ascending Order. Using Pointers Sort Array – C Source Code #include <stdio.h> void main() { int *ptr,a[100],i,j,temp,n; printf(“\n\n Using C Pointers : Sort an array using pointer :\n”); printf(“—————————————————-\n”); printf(” Enter the size of array… Read More »

Loading

Using Call by Reference Swap Numbers

Using Call by Reference Swap Numbers – Write a C program to swap two values by call by reference method of parameter passing. Program for Passing Parameters – Call By Reference #include <stdio.h> void swap2numbers(int *n1, int *n2); int main() { int num1,num2; printf(“\n\n Using C Pointers : Swap Numbers Using Call by Reference :\n”);… Read More »

Loading

Using Pointers Count Vowels

Using Pointers Count Vowels – Write a program in C Programming Language to count the number of vowels and consonants in a string using a pointer. Source Code for Program   #include <stdio.h> int main() { char str1[100],ch; char *ptr; int vcount=0,ccount=0; printf(“\n\n Using C Pointers : Count Vowels and Consonants :\n”); printf(“—————————————————–\n”); printf(” Enter… Read More »

Loading

Using Pointers Find String Length

Using Pointers Find String Length – Write a C Program to Find the length of the string using a pointer. C Program to Find the length of the string using a pointer Source Code Calculate Length of a String – C Pointers #include <stdio.h> int main() { char string1[50]; char *ptr; int length=0; printf(“\n\n Using… Read More »

Loading

Python GCD Recursive Function

Python GCD Recursive Function – Write a Python Program to find GCD of two numbers by recursion. Python GCD Recursive Function Python Program GCD of Two Numbers # Write a Python Program to find GCD # of two numbers using Recursion # define a recursive GCD function def recursive_gcd(a,b): if(b==0): return a else: return recursive_gcd(b,a%b)… Read More »

Loading

Python Power Recursive Function

Python Power Recursive Function – Write a Python program that uses recursion concept to calculate a number N raised to the power P.   Python Recursive Function Power # Write a Recursive Function power_recursive(n,p) # to calculate n raised to power p. # define function def power(n, p): if p == 0: return 1 else:… Read More »

Loading