Basic Functions of Operation System

The various functions of the operating system are as follows: 1. Process Management: A program does nothing unless its instructions are executed by a CPU. A process is a program in execution. A time-shared user program such as a compiler is a process. A word processing program being run by an individual user on a […]

Write a C program to read name and marks of n number of students from user and store them in a file. If the file previously exits, add the information of n students

#include <stdio.h> int main() { char name[50]; int marks, i,n; printf(“Enter number of students”); scanf(“%d”, &n); FILE *fptr; fptr=(fopen(“C:\\student.txt”,”a”)); if (fptr==NULL){ printf(“Error!”); exit(1); } for(i=0;i<n;++i) { printf(“For student%d\nEnter name: “,i+1); scanf(“%s”,name); printf(“Enter marks”); scanf(“%d”, &marks); fprintf(fptr, “\nName: %s\nMarks=%d\n”, name, marks); } fclose(fptr); Return 0; } The fclose function causes the stream pointed to be flushed […]

Program for multiplication of two matrices

#include <stdio.h> int main() { int a[10][10], b[10][10], result[10][10]; int i, j, k, r1, c1, r2, c2; // Input rows and columns for first matrix printf(“Enter rows and columns for first matrix: “); scanf(“%d %d”, &r1, &c1); // Input rows and columns for second matrix printf(“Enter rows and columns for second matrix: “); scanf(“%d %d”, […]

C Program to Print the Alternate Elements in an Array

#include <stdio.h> int main() { int arr[100], n, i; // Accept number of elements printf(“Enter the number of elements: “); scanf(“%d”, &n); // Accept array elements printf(“Enter %d elements:\n”, n); for (i = 0; i < n; i++) { scanf(“%d”, &arr[i]); } // Print alternate elements (0th, 2nd, 4th, …) printf(“Alternate elements in the array:\n”); […]