Algorithm: Start the programGet two numbers from userStored the numbers in num1 & num1If num1 is greater than num2 then num1 is maximum.Else num2 is greaterDisplay the maximum number in outputStop the program Program: #include <stdio.h>int main(){ int num1, num2; printf("Enter two numbers: "); scanf("%d%d", &num1, &num2); if(num1 > num2) { printf("%d is maximum", num1); … Continue reading Display Maximum number in c
c
C program for tower for hanoi
Algorithm: Start the programOnly one disk can be moved at a time.Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack i.e. a disk can only be moved if it is the uppermost disk on a stack.No disk may be placed on top of … Continue reading C program for tower for hanoi
Factorial of a Number Using Recursion
Algorithm: Start programAsk the user to enter an integer to find the factorialRead the integer and assign it to a variableFrom the value of the integer up to 1, multiply each digit and update the final valueThe final value at the end of all the multiplication till 1 is the factorialStop the program Program: #include<stdio.h>long … Continue reading Factorial of a Number Using Recursion
Round Robin Scheduling
Program: #include <stdio.h> int main() { int i,x=-1,k[10],m=0,n,t,s=0; int a[50],temp,b[50],p[10],bur[10],bur1[10]; int wat[10],tur[10],ttur=0,twat=0,j=0; float awat,atur; printf("Enter no. of process : "); scanf("%d", &n); for(i=0; i<n; i++) { printf("Burst time for process P%d : ", (i+1)); scanf("%d", &bur[i]); bur1[i] = bur[i]; } printf("Enter the time slice (in ms) : "); scanf("%d", &t); for(i=0; i<n; i++) { b[i] … Continue reading Round Robin Scheduling
Array Implementation of list ADT
ALGORITHM: Step1: Create nodes first, last; next, prev and cur then set the value as NULL.Step 2: Read the list operation type.Step 3: If operation type is create then process the following steps Allocate memory for node cur.Read data in cur's data area.Assign cur node as NULL.Assign first=last=cur. Step 4: If operation type is Insert … Continue reading Array Implementation of list ADT
ARRAY IMPLEMENTATION OF QUEUE ADT
ALGORITHM: 1. Define a array which stores queue elements.. 2. The operations on the queue are a. a)INSERT data into the queue b. b)DELETE data out of queue 3. INSERT DATA INTO queue a. Enter the data to be inserted into queue. b. If TOP is NULL i. The input data is the first node … Continue reading ARRAY IMPLEMENTATION OF QUEUE ADT
ARRAY IMPLEMENTATION OF STACK ADT
Algorithm: STEP 1: Define an array to store the element. STEP 2: Get the users’ choice. STEP 3: If the option is 1 perform creation operation and goto step4. If the option is 2 perform insertion operation and goto step5. If the option is 3 perform deletion operation and goto step6. If the option is … Continue reading ARRAY IMPLEMENTATION OF STACK ADT
Arithmetic operations in C programming
ALGORITHM: 1. Start 2. Declare variables 3. Read the Inputs . 4. Calculate Arithmetic operations(+,-,*,/,pow) for the input of two numbers. 5. Display the output of the calculations . 6. Stop PROGRAM: #include <stdio.h> #include <conio.h> int main(){ int firstNumber, secondNumber; int sum, difference, product; long square; float quotient; … Continue reading Arithmetic operations in C programming
C PROGRAM TO SORT THE NUMBERS BASED ON THE WEIGHT
ALGORITHM: 1. Start 2. Declare variables 3. Read the number of elements . 4. Get the individual elements. 5. Calculate the weight for each element by the conditions 5 if it is a perfect cube (pow) 4 if it is a multiple of 4 and divisible by 6 … Continue reading C PROGRAM TO SORT THE NUMBERS BASED ON THE WEIGHT
C PROGRAM TO FIND AVERAGE HEIGHT OF A PERSON
ALGORITHM: 1. Start 2. Declare variables 3. Read the total number of persons and their height. 4. Calculate avg=sum/n and find number of persons their h>avg. 5. Display the output of the calculations . 6. Stop PROGRAM: #include <stdio.h> #include <conio.h> void main() { int i,n,sum=0,count=0,height[100]; float avg; //Read … Continue reading C PROGRAM TO FIND AVERAGE HEIGHT OF A PERSON