ASSIGN 2 VALUES USING -> OPERATOR AND PRINT SUM USING CAT() IN R LANGUAGE
Total Pageviews
Tuesday, January 6, 2026
Tuesday, December 2, 2025
Realloc
#include <stdio.h>
#include <stdlib.h>
int main() {
int *ptr;
int n = 5,m;
printf("Enter number of values:\n");
scanf("%d",&n);
ptr = (int *)calloc(n, sizeof(int));
if (ptr == NULL) {
printf("Memory allocation failed!\n");
return 1;
}
printf("\n");
for (int i = 0; i < n; i++) {
ptr[i] = i *10+10;
}
printf("After assigning values:\n");
for (int i = 0; i <n ; i++) {
printf("%d ", ptr[i]);
}
printf("\n");
printf(" values with extra index:\n");
for (int i = 0; i <n +5; i++) {
printf("%d ", ptr[i]);
}
m=n+5;
ptr = (int *)calloc(m, sizeof(int));
printf("\n");
printf("After realloc values:\n");
for (int i = 0; i <m ; i++) {
printf("%d ", ptr[i]);
}
return 0;
}
Calloc and free
#include <stdio.h>
#include <stdlib.h>
int main() {
int *ptr;
int n = 5;
printf("Enter number of values:\n");
scanf("%d",&n);
ptr = (int *)calloc(n, sizeof(int));
if (ptr == NULL) {
printf("Memory allocation failed!\n");
return 1;
}
printf("\n");
for (int i = 0; i < n; i++) {
ptr[i] = i *10+10;
}
printf("After assigning values:\n");
for (int i = 0; i <n ; i++) {
printf("%d ", ptr[i]);
}
printf("\n");
printf(" values with extra index:\n");
for (int i = 0; i <n +5; i++) {
printf("%d ", ptr[i]);
}
free(ptr);
printf("\n");
printf("After free values:\n");
for (int i = 0; i <n ; i++) {
printf("%d ", ptr[i]);
}
return 0;
}
calloc 2
//calloc
#include <stdio.h>
#include <stdlib.h>
int main() {
int *ptr;
int n = 5;
printf("Enter number of values:\n");
scanf("%d",&n);
ptr = (int *)calloc(n, sizeof(int));
if (ptr == NULL) {
printf("Memory allocation failed!\n");
return 1;
}
printf("\n");
for (int i = 0; i < n; i++) {
ptr[i] = i *10+10;
}
printf("After assigning values:\n");
for (int i = 0; i < 10; i++) {
printf("%d ", ptr[i]);
}
printf("\n");
free(ptr);
ptr = NULL;
return 0;
}
Tuesday, November 25, 2025
Calloc
//calloc
#include <stdio.h>
#include <stdlib.h>
int main() {
int *ptr;
int n = 5;
printf("Enter number of values:\n");
scanf("%d",&n);
ptr = (int *)calloc(n, sizeof(int));
if (ptr == NULL) {
printf("Memory allocation failed!\n");
return 1;
}
printf("\n");
for (int i = 0; i < n; i++) {
ptr[i] = i *10+10;
}
printf("After assigning values:\n");
for (int i = 0; i < n; i++) {
printf("%d ", ptr[i]);
}
printf("\n");
free(ptr);
ptr = NULL;
return 0;
}
Malloc
#include <stdio.h>
#include <stdlib.h>
int main() {
int *ptr;
ptr = (int*) malloc(sizeof(int));
if (ptr == NULL) {
printf("Memory allocation failed!\n");
return 1;
}
printf("Memory successfully allocated using malloc.\n");
printf("enter a value.\n");
scanf("%d",ptr);
printf("value = %d ", *ptr);
printf("\n");
return 0;
}
Malloc and free
#include <stdio.h>
#include <stdlib.h>
int main() {
int *ptr;
ptr = (int*) malloc(sizeof(int));
if (ptr == NULL) {
printf("Memory allocation failed!\n");
return 1;
}
printf("Memory successfully allocated using malloc.\n");
printf("enter a value.\n");
scanf("%d",ptr);
printf("value = %d ", *ptr);
printf("\n");
free(ptr);
printf("after free ptr new value = %d ", *ptr);
return 0;
}
Dynamic memory allocation
1. Malloc - CLICK HERE
2.Free - CLICK HERE
3.Calloc - 1. CLICK HERE 2. CLICK HERE
4.Calloc AND Free - CLICK HERE
5.Realloc - CLICK HERE
Tuesday, March 25, 2025
Operating system examination set 1
1.
To access the services of operating system, the interface is provided by the ___________
a) System calls
b) API
c) Library
d) Assembly instructions
2.
What is the main function of the command interpreter?
a) to get and execute the next user-specified command
b) to provide the interface between the API and application program
c) to handle the files in operating system
d) none of the mentioned
3.
If a process fails, most operating system write the error information to a ______
a) log file
b) another running process
c) new file
d) none of the mentioned
4.
The systems which allow only one process execution at a time, are called __________
a) uniprogramming systems
b) uniprocessing systems
c) unitasking systems
d) none of the mentioned
5.
In operating system, each process has its own __________
a) address space and global variables
b) open files
c) pending alarms, signals and signal handlers
d) all of the mentioned
6.
In Unix, Which system call creates the new process?
a) fork
b) create
c) new
d) none of the mentioned
7.
A set of processes is deadlock if __________
a) each process is blocked and will remain so forever
b) each process is terminated
c) all processes are trying to kill each other
d) none of the mentioned
8. The number of processes completed per unit time is known as __________
a) Output
b) Throughput
c) Efficiency
d) Capacity
9.
What is the degree of multiprogramming?
a) the number of processes executed per unit time
b) the number of processes in the ready queue
c) the number of processes in the I/O queue
d) the number of processes in memory
10.Which of the following do not belong to queues for processes?
a) Job Queueb) PCB queue
c) Device Queue
d) Ready Queue
b) It is placed in a waiting queue
c) It is placed in the ready queue
d) It is placed in the Job queue
a) It selects processes which have to be brought into the ready queue
b) It selects processes which have to be executed next and allocates CPU
c) It selects processes which heave to remove from memory by swapping
d) None of the mentioned
b) It selects processes which have to be executed next and allocates CPU
c) It selects processes which heave to remove from memory by swapping
d) None of the mentioned
b) It selects which process has to be executed next and allocates CPU
c) It selects which process to remove from memory by swapping
d) None of the mentioned
b) The type of processes they schedule
c) The frequency of their execution
d) None of the mentioned
b) Ready state
c) Suspended state
d) Terminated state
b) the process state
c) memory-management information
d) context switch time
b) interrupt
c) scheduler
d) none of the mentioned
b) turnaround time
c) response time
d) throughput
b) CPU is allocated to the process with lowest priority
c) Equal priority processes can not be scheduled
d) None of the mentioned
b) round robin scheduling algorithm
c) priority scheduling algorithm
d) multilevel queue scheduling algorithm
b) CPU & I/O Burst
c) Memory & I/O Burst
d) OS & Memory Burst
b) the time of dispatching a process from running to ready state and keeping the CPU idle
c) the time to stop one process and start running another one
d) none of the mentioned
b) Preemptive scheduling
c) All of the mentioned
d) None of the mentioned
b) knowing the length of the next CPU request
c) it is too complex to understand
d) none of the mentioned
b) the inverse of the predicted next CPU burst
c) the current CPU burst
d) anything the user wants
b) keeping track of what pages are currently residing in memory
c) keeping track of how many times a given page is referenced
d) increasing the priority of jobs to ensure termination in a finite time
b) Wait queue
c) Ready queue
d) Aging
b) absolute address
c) logical address
d) none of the mentioned
b) a paging technique
c) a technique for overcoming external fragmentation
d) a technique for overcoming fatal error
b) equal to
c) greater than
d) none of the mentioned
b) at least one process
c) multiple processes at once
d) none of the mentioned
b) the CPU utilization
c) the memory size
d) all of the mentioned
b) processor to run the next process
c) free hole from a set of available holes
d) all of the mentioned
b) is not being used
c) is always used
d) none of the mentioned
b) larger memory space
c) smaller memory space
d) none of the mentioned
b) permit smaller processes to be allocated memory at last
c) permit larger processes to be allocated memory at last
d) all of the mentioned
b) must be done
c) must not be done
d) can be done
b) external fragmentation occurs
c) both internal and external fragmentation occurs
d) neither internal nor external fragmentation occurs
b) pages
c) backing store
d) none of the mentioned
b) pages
c) backing store
d) none of the mentioned
| Process | Arrival time | Burst time |
| P0 | 0 | 8 |
| P1 | 1 | 6 |
| p2 | 2 | 4 |
| p3 | 3 | 2 |
| p4 | 4 | 1 |
61. Calculate average waiting time using SRTF.

