AKTU 1st Year Sem 1 Solved Paper 2017-18 | COMP. SYSTEM & C PROGRAMMING | Sec B - GeeksforGeeks

30 Jan, 2019
Paper download link: Paper | Sem 1 | 2017-18
Time: 3hrsTotal Marks: 100
Note:-
There are three sections. Section A carries 20 marks, Section B carries 30 marks and Section C carries 50 marks.
Attempt all questions. Marks are indicated against each question.
Assume suitable data wherever necessary.
What is digital computer? Draw block diagram of digital computer and explain each components of it.Digital Computer: A digital computer can be defined as a programmable machine which reads the binary data passed as instructions, processes this binary data, and displays a calculated digital output. Therefore, Digital computers are those that work on the digital data.Details of Functional Components of a Digital ComputerInput Unit :The input unit consists of input devices that are attached to the computer. These devices take input and convert it into binary language that the computer understands. Some of the common input devices are keyboard, mouse, joystick, scanner etc.Central Processing Unit (CPU0 : Once the information is entered into the computer by the input device, the processor processes it. The CPU is called the brain of the computer because it is the control center of the computer. It first fetches instructions from memory and then interprets them so as to know what is to be done. If required, data is fetched from memory or input device. Thereafter CPU executes or performs the required computation and then either stores the output or displays on the output device. The CPU has three main components which are responsible for different functions – Arithmetic Logic Unit (ALU), Control Unit (CU) and Memory registersArithmetic and Logic Unit (ALU) : The ALU, as its name suggests performs mathematical calculations and takes logical decisions. Arithmetic calculations include addition, subtraction, multiplication and division. Logical decisions involve comparison of two data items to see which one is larger or smaller or equal.Control Unit : The Control unit coordinates and controls the data flow in and out of CPU and also controls all the operations of ALU, memory registers and also input/output units. It is also responsible for carrying out all the instructions stored in the program. It decodes the fetched instruction, interprets it and sends control signals to input/output devices until the required operation is done properly by ALU and memory.Memory Registers : A register is a temporary unit of memory in the CPU. These are used to store the data which is directly used by the processor. Registers can be of different sizes(16 bit, 32 bit, 64 bit and so on) and each register inside the CPU has a specific function like storing data, storing an instruction, storing address of a location in memory etc. The user registers can be used by an assembly language programmer for storing operands, intermediate results etc. Accumulator (ACC) is the main register in the ALU and contains one of the operands of an operation to be performed in the ALU.Memory : Memory attached to the CPU is used for storage of data and instructions and is called internal memory The internal memory is divided into many storage locations, each of which can store data or instructions. Each memory location is of the same size and has an address. With the help of the address, the computer can read any memory location easily without having to search the entire memory. when a program is executed, it’s data is copied to the internal memory ans is stored in the memory till the end of the execution. The internal memory is also called the Primary memory or Main memory. This memory is also called as RAM, i.e. Random Access Memory. The time of access of data is independent of its location in memory, therefore this memory is also called Random Access memory (RAM). Read this for different types of RAMsOutput Unit : The output unit consists of output devices that are attached with the computer. It converts the binary data coming from CPU to human understandable form. The common output devices are monitor, printer, plotter etc.Wrtie a program to check the number is palindrome or not. The program should accept any arbitrary number typed by user.Program to check whether the number is Palindrome or not:// C program to check whether a number// is Palindrome or not.  #include <stdio.h>  /* Iterative function to reverse digits of num*/int reverseDigits(int num){    int rev_num = 0;    while (num > 0) {        rev_num = rev_num * 10 + num % 10;        num = num / 10;    }    return rev_num;}  /* Function to check if n is Palindrome*/int isPalindrome(int n){      // get the reverse of n    int rev_n = reverseDigits(n);      // Check if rev_n and n are same or not.    if (rev_n == n)        return 1;    else        return 0;}  /*Driver program to test reversDigits*/int main(){    int n;      // Read n from user    printf("Enter the number to checked: ");    scanf("%d", &n);      // Find if n is Palindrome and print    printf("Is %d a Palindrome number? -> %s\n", n,           isPalindrome(n) == 1 ? "true" : "false");      // Read n from user    printf("\nEnter the number to checked: ");    scanf("%d", &n);      // Find if n is Palindrome and print    printf("Is %d a Palindrome number? -> %s\n", n,           isPalindrome(n) == 1 ? "true" : "false");    return 0;}Output:Enter the number to checked: 4562
Is 4562 a Palindrome number? -> false

Enter the number to checked: 2002
Is 2002 a Palindrome number? -> true
What is Operating System? Explain various types of functions performed by an Operating System.The fundamental goal of a Computer System is to execute user programs and to make tasks easier. Various application programs along with hardware system are used to perform this work. Operating System is a software which manages and control the entire set of resources and effectively utilize every part of a computer.The figure shows how OS acts as a medium between hardware unit and application programs.Functions of an Operating SystemAn operating system has variety of functions to perform. Some of the prominent functions of an operating system can be broadly outlined as:Processor Management: This deals with management of the Central Processing Unit (CPU). The operating system takes care of the allotment of CPU time to different processes. When a process finishes its CPU processing after executing for the allotted time period, this is called scheduling. There are various type of scheduling techniques that are used by the operating systems:Shortest Job First(SJF): Process which need the shortest CPU time are scheduled first.Round Robin Scheduling: Each process is assigned a fixed CPU execution time in cyclic way.Priority Based scheduling (Non Preemptive): In this scheduling, processes are scheduled according to their priorities, i.e., highest priority process is schedule first. If priorities of two processes match, then schedule according to arrival timeDevice Management:The Operating System communicates with hardware and the attached devices and maintains a balance between them and the CPU. This is all the more important because the CPU processing speed is much higher than thatof I/O devices. In order to optimize the CPU time, the operating system employstwo techniques – Buffering and Spooling.Buffering:In this technique, input and output data is temporarily stored in Input Buffer and Output Buffer. Once the signal for input or output is sent to or from the CPU respectively, the operating system through the device controller moves the data from the input device to the input buffer and for the output device to the output buffer. In case of input, if the buffer is full, the operating system sends a signal to the program which processes the data stored in the buffer. When the buffer becomes empty, the program informs the operating system which reloads the buffer and the input operation continues.Spooling (Simultaneous Peripheral Operation on Line):This is a device management technique used for processing of different tasks on the same input/output device. When there are various users on a network sharing the same resource then it can be a possibility that more than one user might give it a command at the same point of time. So, the operating system temporarily stores the data of every user on the hard disk of the computer to which the resource is attached. The individual user need not wait for the execution process to be completed. Instead the operating system sends the data from the hard disk to the resource one by one.Example: printerMemory management:In a computer, both the CPU and the I/O devices interact with the memory. When a program needs to be executed it is loaded onto the main memory till the execution is completed. Thereafter that memory space is freed and is available for other programs. The common memory management techniques used by the operating system are Partitioning and Virtual Memory.Partitioning:The total memory is divided into various partitions of same size or different sizes. This helps to accommodate number of programs in the memory. The partition can be fixed i.e. remains same for all the programs in the memory or variable i.e. memory is allocated when a program is loaded on to the memory. The later approach causes less wastage of memory but in due course of time, it may become fragmented.Virtual Memory:This is a technique used by the operating systems which allow the user can load the programs which are larger than the main memory of the computer. In this technique the program is executed even if the complete program can not be loaded inside the main memory leading to efficient memory utilization.File Management:The operating System manages the files, folders and directory systems on a computer. Any data on a computer is stored in the form of files and the operating system keeps information about all of them using File Allocation Table (FAT). The FAT stores general information about files like filename, type (text or binary), size, starting address and access mode (sequential/indexed sequential/direct/relative). The file manager of the operating system helps to create, edit, copy, allocate memory to the files and also updates the FAT. The operating system also takes care that files are opened with proper access rights to read or edit them.What is Structured programming approach? Highlight the advantages and disadvantages of structured programming.Structured Programming Approach, as the word suggests, can be defined as a programming approach in which the program is made as a single structure. It means that the code will execute the instruction by instruction one after the other. It doesn’t support the possibility of jumping from one instruction to some other with help of any statement like GOTO, etc. Therefore, the instructions in this approach will be executed in a serial and structured manner. The languages that support Structured programming approach are:CC++JavaC#..etcOn the contrary, in the Assembly languages like Microprocessor 8085, etc, the statements do not get executed in a structured manner. It allows jump statements like GOTO. So the program flow might be random.The structured program mainly consists of three types of elements:Selection StatementsSequence StatementsIteration StatementsThe structured program consists of well structured and separated modules. But the entry and exit in a Structured program is a single-time event. It means that the program uses single-entry and single-exit elements. Therefore a structured program is well maintained, neat and clean program. This is the reason why the Structured Programming Approach is well accepted in the programming world.Advantages of Structured Programming Approach:Easier to read and understandUser FrindlyEasier to MaintainMainly problem based instead of being machine basedDevelopment is easier as it requires less effort and timeEasier to DebugMachine-Independent, mostly.Disadvantages of Structured Programming Approach:Since it is Machine-Independent, So it takes time to convert into machine code.The converted machine code is not the same as for assembly language.The program depends upon changeable factors like data-types. Therefore it needs to be updated with the need on the go.Usually the development in this approach takes longer time as it is language dependent. Whereas in the case of assembly language, the development takes lesser time as it is fixed for the machine.What do you mean by sorting? Write a program in C to sort the elements of a given array of N positive integers. Also give the flow chart for the same.A Sorting Algorithm is used to rearrange a given array or list elements according to a comparison operator on the elements. The comparison operator is used to decide the new order of element in the respective data structure.For example: The below list of characters is sorted in increasing order of their ASCII values. That is, the character with lesser ASCII value will be placed first than the character with higher ASCII value.Flowchart of the Selection Sort:Program in C to sort the elements of a given array of N positive integers:// C program to sort the elements// of a given array of N positive integers  #include <stdio.h>  void swap(int* xp, int* yp){    int temp = *xp;    *xp = *yp;    *yp = temp;}  void selectionSort(int arr[], int n){    int i, j, min_idx;      // One by one move boundary of unsorted subarray    for (i = 0; i < n - 1; i++) {        // Find the minimum element in unsorted array        min_idx = i;        for (j = i + 1; j < n; j++)            if (arr[j] < arr[min_idx])                min_idx = j;          // Swap the found minimum element with the first element        swap(&arr[min_idx], &arr[i]);    }}  /* Function to print an array */void printArray(int arr[], int size){    int i;    for (i = 0; i < size; i++)        printf("%d ", arr[i]);    printf("\n");}  // Driver program to test above functionsint main(){    int arr[] = { 64, 25, 12, 22, 11 };    int n = sizeof(arr) / sizeof(arr[0]);    selectionSort(arr, n);    printf("Sorted array: \n");    printArray(arr, n);    return 0;}
What is digital computer? Draw block diagram of digital computer and explain each components of it.Digital Computer: A digital computer can be defined as a programmable machine which reads the binary data passed as instructions, processes this binary data, and displays a calculated digital output. Therefore, Digital computers are those that work on the digital data.Details of Functional Components of a Digital ComputerInput Unit :The input unit consists of input devices that are attached to the computer. These devices take input and convert it into binary language that the computer understands. Some of the common input devices are keyboard, mouse, joystick, scanner etc.Central Processing Unit (CPU0 : Once the information is entered into the computer by the input device, the processor processes it. The CPU is called the brain of the computer because it is the control center of the computer. It first fetches instructions from memory and then interprets them so as to know what is to be done. If required, data is fetched from memory or input device. Thereafter CPU executes or performs the required computation and then either stores the output or displays on the output device. The CPU has three main components which are responsible for different functions – Arithmetic Logic Unit (ALU), Control Unit (CU) and Memory registersArithmetic and Logic Unit (ALU) : The ALU, as its name suggests performs mathematical calculations and takes logical decisions. Arithmetic calculations include addition, subtraction, multiplication and division. Logical decisions involve comparison of two data items to see which one is larger or smaller or equal.Control Unit : The Control unit coordinates and controls the data flow in and out of CPU and also controls all the operations of ALU, memory registers and also input/output units. It is also responsible for carrying out all the instructions stored in the program. It decodes the fetched instruction, interprets it and sends control signals to input/output devices until the required operation is done properly by ALU and memory.Memory Registers : A register is a temporary unit of memory in the CPU. These are used to store the data which is directly used by the processor. Registers can be of different sizes(16 bit, 32 bit, 64 bit and so on) and each register inside the CPU has a specific function like storing data, storing an instruction, storing address of a location in memory etc. The user registers can be used by an assembly language programmer for storing operands, intermediate results etc. Accumulator (ACC) is the main register in the ALU and contains one of the operands of an operation to be performed in the ALU.Memory : Memory attached to the CPU is used for storage of data and instructions and is called internal memory The internal memory is divided into many storage locations, each of which can store data or instructions. Each memory location is of the same size and has an address. With the help of the address, the computer can read any memory location easily without having to search the entire memory. when a program is executed, it’s data is copied to the internal memory ans is stored in the memory till the end of the execution. The internal memory is also called the Primary memory or Main memory. This memory is also called as RAM, i.e. Random Access Memory. The time of access of data is independent of its location in memory, therefore this memory is also called Random Access memory (RAM). Read this for different types of RAMsOutput Unit : The output unit consists of output devices that are attached with the computer. It converts the binary data coming from CPU to human understandable form. The common output devices are monitor, printer, plotter etc.
Details of Functional Components of a Digital Computer
Input Unit :The input unit consists of input devices that are attached to the computer. These devices take input and convert it into binary language that the computer understands. Some of the common input devices are keyboard, mouse, joystick, scanner etc.
Central Processing Unit (CPU0 : Once the information is entered into the computer by the input device, the processor processes it. The CPU is called the brain of the computer because it is the control center of the computer. It first fetches instructions from memory and then interprets them so as to know what is to be done. If required, data is fetched from memory or input device. Thereafter CPU executes or performs the required computation and then either stores the output or displays on the output device. The CPU has three main components which are responsible for different functions – Arithmetic Logic Unit (ALU), Control Unit (CU) and Memory registers
Arithmetic and Logic Unit (ALU) : The ALU, as its name suggests performs mathematical calculations and takes logical decisions. Arithmetic calculations include addition, subtraction, multiplication and division. Logical decisions involve comparison of two data items to see which one is larger or smaller or equal.
Control Unit : The Control unit coordinates and controls the data flow in and out of CPU and also controls all the operations of ALU, memory registers and also input/output units. It is also responsible for carrying out all the instructions stored in the program. It decodes the fetched instruction, interprets it and sends control signals to input/output devices until the required operation is done properly by ALU and memory.
Memory Registers : A register is a temporary unit of memory in the CPU. These are used to store the data which is directly used by the processor. Registers can be of different sizes(16 bit, 32 bit, 64 bit and so on) and each register inside the CPU has a specific function like storing data, storing an instruction, storing address of a location in memory etc. The user registers can be used by an assembly language programmer for storing operands, intermediate results etc. Accumulator (ACC) is the main register in the ALU and contains one of the operands of an operation to be performed in the ALU.
Memory : Memory attached to the CPU is used for storage of data and instructions and is called internal memory The internal memory is divided into many storage locations, each of which can store data or instructions. Each memory location is of the same size and has an address. With the help of the address, the computer can read any memory location easily without having to search the entire memory. when a program is executed, it’s data is copied to the internal memory ans is stored in the memory till the end of the execution. The internal memory is also called the Primary memory or Main memory. This memory is also called as RAM, i.e. Random Access Memory. The time of access of data is independent of its location in memory, therefore this memory is also called Random Access memory (RAM). Read this for different types of RAMs
Output Unit : The output unit consists of output devices that are attached with the computer. It converts the binary data coming from CPU to human understandable form. The common output devices are monitor, printer, plotter etc.
Wrtie a program to check the number is palindrome or not. The program should accept any arbitrary number typed by user.Program to check whether the number is Palindrome or not:// C program to check whether a number// is Palindrome or not.  #include <stdio.h>  /* Iterative function to reverse digits of num*/int reverseDigits(int num){    int rev_num = 0;    while (num > 0) {        rev_num = rev_num * 10 + num % 10;        num = num / 10;    }    return rev_num;}  /* Function to check if n is Palindrome*/int isPalindrome(int n){      // get the reverse of n    int rev_n = reverseDigits(n);      // Check if rev_n and n are same or not.    if (rev_n == n)        return 1;    else        return 0;}  /*Driver program to test reversDigits*/int main(){    int n;      // Read n from user    printf("Enter the number to checked: ");    scanf("%d", &n);      // Find if n is Palindrome and print    printf("Is %d a Palindrome number? -> %s\n", n,           isPalindrome(n) == 1 ? "true" : "false");      // Read n from user    printf("\nEnter the number to checked: ");    scanf("%d", &n);      // Find if n is Palindrome and print    printf("Is %d a Palindrome number? -> %s\n", n,           isPalindrome(n) == 1 ? "true" : "false");    return 0;}Output:Enter the number to checked: 4562
Is 4562 a Palindrome number? -> false

Enter the number to checked: 2002
Is 2002 a Palindrome number? -> true

// C program to check whether a number// is Palindrome or not.  #include <stdio.h>  /* Iterative function to reverse digits of num*/int reverseDigits(int num){    int rev_num = 0;    while (num > 0) {        rev_num = rev_num * 10 + num % 10;        num = num / 10;    }    return rev_num;}  /* Function to check if n is Palindrome*/int isPalindrome(int n){      // get the reverse of n    int rev_n = reverseDigits(n);      // Check if rev_n and n are same or not.    if (rev_n == n)        return 1;    else        return 0;}  /*Driver program to test reversDigits*/int main(){    int n;      // Read n from user    printf("Enter the number to checked: ");    scanf("%d", &n);      // Find if n is Palindrome and print    printf("Is %d a Palindrome number? -> %s\n", n,           isPalindrome(n) == 1 ? "true" : "false");      // Read n from user    printf("\nEnter the number to checked: ");    scanf("%d", &n);      // Find if n is Palindrome and print    printf("Is %d a Palindrome number? -> %s\n", n,           isPalindrome(n) == 1 ? "true" : "false");    return 0;}
Enter the number to checked: 4562
Is 4562 a Palindrome number? -> false

Enter the number to checked: 2002
Is 2002 a Palindrome number? -> true

What is Operating System? Explain various types of functions performed by an Operating System.The fundamental goal of a Computer System is to execute user programs and to make tasks easier. Various application programs along with hardware system are used to perform this work. Operating System is a software which manages and control the entire set of resources and effectively utilize every part of a computer.The figure shows how OS acts as a medium between hardware unit and application programs.Functions of an Operating SystemAn operating system has variety of functions to perform. Some of the prominent functions of an operating system can be broadly outlined as:Processor Management: This deals with management of the Central Processing Unit (CPU). The operating system takes care of the allotment of CPU time to different processes. When a process finishes its CPU processing after executing for the allotted time period, this is called scheduling. There are various type of scheduling techniques that are used by the operating systems:Shortest Job First(SJF): Process which need the shortest CPU time are scheduled first.Round Robin Scheduling: Each process is assigned a fixed CPU execution time in cyclic way.Priority Based scheduling (Non Preemptive): In this scheduling, processes are scheduled according to their priorities, i.e., highest priority process is schedule first. If priorities of two processes match, then schedule according to arrival timeDevice Management:The Operating System communicates with hardware and the attached devices and maintains a balance between them and the CPU. This is all the more important because the CPU processing speed is much higher than thatof I/O devices. In order to optimize the CPU time, the operating system employstwo techniques – Buffering and Spooling.Buffering:In this technique, input and output data is temporarily stored in Input Buffer and Output Buffer. Once the signal for input or output is sent to or from the CPU respectively, the operating system through the device controller moves the data from the input device to the input buffer and for the output device to the output buffer. In case of input, if the buffer is full, the operating system sends a signal to the program which processes the data stored in the buffer. When the buffer becomes empty, the program informs the operating system which reloads the buffer and the input operation continues.Spooling (Simultaneous Peripheral Operation on Line):This is a device management technique used for processing of different tasks on the same input/output device. When there are various users on a network sharing the same resource then it can be a possibility that more than one user might give it a command at the same point of time. So, the operating system temporarily stores the data of every user on the hard disk of the computer to which the resource is attached. The individual user need not wait for the execution process to be completed. Instead the operating system sends the data from the hard disk to the resource one by one.Example: printerMemory management:In a computer, both the CPU and the I/O devices interact with the memory. When a program needs to be executed it is loaded onto the main memory till the execution is completed. Thereafter that memory space is freed and is available for other programs. The common memory management techniques used by the operating system are Partitioning and Virtual Memory.Partitioning:The total memory is divided into various partitions of same size or different sizes. This helps to accommodate number of programs in the memory. The partition can be fixed i.e. remains same for all the programs in the memory or variable i.e. memory is allocated when a program is loaded on to the memory. The later approach causes less wastage of memory but in due course of time, it may become fragmented.Virtual Memory:This is a technique used by the operating systems which allow the user can load the programs which are larger than the main memory of the computer. In this technique the program is executed even if the complete program can not be loaded inside the main memory leading to efficient memory utilization.File Management:The operating System manages the files, folders and directory systems on a computer. Any data on a computer is stored in the form of files and the operating system keeps information about all of them using File Allocation Table (FAT). The FAT stores general information about files like filename, type (text or binary), size, starting address and access mode (sequential/indexed sequential/direct/relative). The file manager of the operating system helps to create, edit, copy, allocate memory to the files and also updates the FAT. The operating system also takes care that files are opened with proper access rights to read or edit them.
The figure shows how OS acts as a medium between hardware unit and application programs.
Functions of an Operating System
An operating system has variety of functions to perform. Some of the prominent functions of an operating system can be broadly outlined as:
Processor Management: This deals with management of the Central Processing Unit (CPU). The operating system takes care of the allotment of CPU time to different processes. When a process finishes its CPU processing after executing for the allotted time period, this is called scheduling. There are various type of scheduling techniques that are used by the operating systems:Shortest Job First(SJF): Process which need the shortest CPU time are scheduled first.Round Robin Scheduling: Each process is assigned a fixed CPU execution time in cyclic way.Priority Based scheduling (Non Preemptive): In this scheduling, processes are scheduled according to their priorities, i.e., highest priority process is schedule first. If priorities of two processes match, then schedule according to arrival time
Shortest Job First(SJF): Process which need the shortest CPU time are scheduled first.Round Robin Scheduling: Each process is assigned a fixed CPU execution time in cyclic way.Priority Based scheduling (Non Preemptive): In this scheduling, processes are scheduled according to their priorities, i.e., highest priority process is schedule first. If priorities of two processes match, then schedule according to arrival time
Shortest Job First(SJF): Process which need the shortest CPU time are scheduled first.
Round Robin Scheduling: Each process is assigned a fixed CPU execution time in cyclic way.
Priority Based scheduling (Non Preemptive): In this scheduling, processes are scheduled according to their priorities, i.e., highest priority process is schedule first. If priorities of two processes match, then schedule according to arrival time
Device Management:The Operating System communicates with hardware and the attached devices and maintains a balance between them and the CPU. This is all the more important because the CPU processing speed is much higher than thatof I/O devices. In order to optimize the CPU time, the operating system employstwo techniques – Buffering and Spooling.
Buffering:In this technique, input and output data is temporarily stored in Input Buffer and Output Buffer. Once the signal for input or output is sent to or from the CPU respectively, the operating system through the device controller moves the data from the input device to the input buffer and for the output device to the output buffer. In case of input, if the buffer is full, the operating system sends a signal to the program which processes the data stored in the buffer. When the buffer becomes empty, the program informs the operating system which reloads the buffer and the input operation continues.
Spooling (Simultaneous Peripheral Operation on Line):This is a device management technique used for processing of different tasks on the same input/output device. When there are various users on a network sharing the same resource then it can be a possibility that more than one user might give it a command at the same point of time. So, the operating system temporarily stores the data of every user on the hard disk of the computer to which the resource is attached. The individual user need not wait for the execution process to be completed. Instead the operating system sends the data from the hard disk to the resource one by one.Example: printer
Memory management:In a computer, both the CPU and the I/O devices interact with the memory. When a program needs to be executed it is loaded onto the main memory till the execution is completed. Thereafter that memory space is freed and is available for other programs. The common memory management techniques used by the operating system are Partitioning and Virtual Memory.
Partitioning:The total memory is divided into various partitions of same size or different sizes. This helps to accommodate number of programs in the memory. The partition can be fixed i.e. remains same for all the programs in the memory or variable i.e. memory is allocated when a program is loaded on to the memory. The later approach causes less wastage of memory but in due course of time, it may become fragmented.
Virtual Memory:This is a technique used by the operating systems which allow the user can load the programs which are larger than the main memory of the computer. In this technique the program is executed even if the complete program can not be loaded inside the main memory leading to efficient memory utilization.
File Management:The operating System manages the files, folders and directory systems on a computer. Any data on a computer is stored in the form of files and the operating system keeps information about all of them using File Allocation Table (FAT). The FAT stores general information about files like filename, type (text or binary), size, starting address and access mode (sequential/indexed sequential/direct/relative). The file manager of the operating system helps to create, edit, copy, allocate memory to the files and also updates the FAT. The operating system also takes care that files are opened with proper access rights to read or edit them.
What is Structured programming approach? Highlight the advantages and disadvantages of structured programming.Structured Programming Approach, as the word suggests, can be defined as a programming approach in which the program is made as a single structure. It means that the code will execute the instruction by instruction one after the other. It doesn’t support the possibility of jumping from one instruction to some other with help of any statement like GOTO, etc. Therefore, the instructions in this approach will be executed in a serial and structured manner. The languages that support Structured programming approach are:CC++JavaC#..etcOn the contrary, in the Assembly languages like Microprocessor 8085, etc, the statements do not get executed in a structured manner. It allows jump statements like GOTO. So the program flow might be random.The structured program mainly consists of three types of elements:Selection StatementsSequence StatementsIteration StatementsThe structured program consists of well structured and separated modules. But the entry and exit in a Structured program is a single-time event. It means that the program uses single-entry and single-exit elements. Therefore a structured program is well maintained, neat and clean program. This is the reason why the Structured Programming Approach is well accepted in the programming world.Advantages of Structured Programming Approach:Easier to read and understandUser FrindlyEasier to MaintainMainly problem based instead of being machine basedDevelopment is easier as it requires less effort and timeEasier to DebugMachine-Independent, mostly.Disadvantages of Structured Programming Approach:Since it is Machine-Independent, So it takes time to convert into machine code.The converted machine code is not the same as for assembly language.The program depends upon changeable factors like data-types. Therefore it needs to be updated with the need on the go.Usually the development in this approach takes longer time as it is language dependent. Whereas in the case of assembly language, the development takes lesser time as it is fixed for the machine.
C
C++
Java
C#..etc
..etc
On the contrary, in the Assembly languages like Microprocessor 8085, etc, the statements do not get executed in a structured manner. It allows jump statements like GOTO. So the program flow might be random.
The structured program mainly consists of three types of elements:
Selection Statements
Sequence Statements
Iteration Statements
The structured program consists of well structured and separated modules. But the entry and exit in a Structured program is a single-time event. It means that the program uses single-entry and single-exit elements. Therefore a structured program is well maintained, neat and clean program. This is the reason why the Structured Programming Approach is well accepted in the programming world.
Advantages of Structured Programming Approach:
Easier to read and understandUser FrindlyEasier to MaintainMainly problem based instead of being machine basedDevelopment is easier as it requires less effort and timeEasier to DebugMachine-Independent, mostly.
Easier to read and understand
User Frindly
Easier to Maintain
Mainly problem based instead of being machine based
Development is easier as it requires less effort and time
Easier to Debug
Machine-Independent, mostly.
Disadvantages of Structured Programming Approach:
Since it is Machine-Independent, So it takes time to convert into machine code.The converted machine code is not the same as for assembly language.The program depends upon changeable factors like data-types. Therefore it needs to be updated with the need on the go.Usually the development in this approach takes longer time as it is language dependent. Whereas in the case of assembly language, the development takes lesser time as it is fixed for the machine.
Since it is Machine-Independent, So it takes time to convert into machine code.
The converted machine code is not the same as for assembly language.
The program depends upon changeable factors like data-types. Therefore it needs to be updated with the need on the go.
Usually the development in this approach takes longer time as it is language dependent. Whereas in the case of assembly language, the development takes lesser time as it is fixed for the machine.
What do you mean by sorting? Write a program in C to sort the elements of a given array of N positive integers. Also give the flow chart for the same.A Sorting Algorithm is used to rearrange a given array or list elements according to a comparison operator on the elements. The comparison operator is used to decide the new order of element in the respective data structure.For example: The below list of characters is sorted in increasing order of their ASCII values. That is, the character with lesser ASCII value will be placed first than the character with higher ASCII value.Flowchart of the Selection Sort:Program in C to sort the elements of a given array of N positive integers:// C program to sort the elements// of a given array of N positive integers  #include <stdio.h>  void swap(int* xp, int* yp){    int temp = *xp;    *xp = *yp;    *yp = temp;}  void selectionSort(int arr[], int n){    int i, j, min_idx;      // One by one move boundary of unsorted subarray    for (i = 0; i < n - 1; i++) {        // Find the minimum element in unsorted array        min_idx = i;        for (j = i + 1; j < n; j++)            if (arr[j] < arr[min_idx])                min_idx = j;          // Swap the found minimum element with the first element        swap(&arr[min_idx], &arr[i]);    }}  /* Function to print an array */void printArray(int arr[], int size){    int i;    for (i = 0; i < size; i++)        printf("%d ", arr[i]);    printf("\n");}  // Driver program to test above functionsint main(){    int arr[] = { 64, 25, 12, 22, 11 };    int n = sizeof(arr) / sizeof(arr[0]);    selectionSort(arr, n);    printf("Sorted array: \n");    printArray(arr, n);    return 0;}
For example: The below list of characters is sorted in increasing order of their ASCII values. That is, the character with lesser ASCII value will be placed first than the character with higher ASCII value.
Flowchart of the Selection Sort:
Program in C to sort the elements of a given array of N positive integers:
// C program to sort the elements// of a given array of N positive integers  #include <stdio.h>  void swap(int* xp, int* yp){    int temp = *xp;    *xp = *yp;    *yp = temp;}  void selectionSort(int arr[], int n){    int i, j, min_idx;      // One by one move boundary of unsorted subarray    for (i = 0; i < n - 1; i++) {        // Find the minimum element in unsorted array        min_idx = i;        for (j = i + 1; j < n; j++)            if (arr[j] < arr[min_idx])                min_idx = j;          // Swap the found minimum element with the first element        swap(&arr[min_idx], &arr[i]);    }}  /* Function to print an array */void printArray(int arr[], int size){    int i;    for (i = 0; i < size; i++)        printf("%d ", arr[i]);    printf("\n");}  // Driver program to test above functionsint main(){    int arr[] = { 64, 25, 12, 22, 11 };    int n = sizeof(arr) / sizeof(arr[0]);    selectionSort(arr, n);    printf("Sorted array: \n");    printArray(arr, n);    return 0;}
AKTU-question-papers
Articles
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Tree Traversals (Inorder, Preorder and Postorder)
SQL | Join (Inner, Left, Right and Full Joins)
find command in Linux with examples
Analysis of Algorithms | Set 1 (Asymptotic Analysis)
Time Complexity and Space Complexity
Mutex vs Semaphore
Analysis of Algorithms | Set 3 (Asymptotic Notations)
Analysis of Algorithms | Set 2 (Worst, Average and Best Cases)
Understanding "extern" keyword in C
SQL | Views