Programming Foundation Part1 Rec

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 13

EX.

NO: INTRODUCTION TO LINUX OPERATING


DATE: SYSTEM
AND ITS FILE SYSTEMS
AIM:

To Study the Linux operating system and its file system.

Operating system:
An operating system (OS) is the program that, after being initially loaded into the
computer by a boot program, manages all of the other application programs in a
computer.

Types of operating system:

 Batch OS.
 Distributed OS.
 Multitasking OS.
 Network OS.
 Real-OS.
 Mobile OS

Functions of operating system:

1. Security –
The operating system uses password protection to protect user data and
similar other techniques. it also prevents unauthorized access to programs
and user data.

2. Control over system performance –


Monitors overall system health to help improve performance. records the
response time between service requests and system response to having a
complete view of the system health. This can help improve performance by
providing important information needed to troubleshoot problems.

3. Job accounting –
Operating system Keeps track of time and resources used by various tasks
and users, this information can be used to track resource usage for a
particular user or group of users.

4. Error detecting aids –


The operating system constantly monitors the system to detect errors and
avoid the malfunctioning of a computer system.
5. Coordination between other software and users –
Operating systems also coordinate and assign interpreters, compilers,
assemblers, and other software to the various users of the computer
systems.

6. Memory Management –
The operating system manages the Primary Memory or Main Memory. Main
memory is made up of a large array of bytes or words where each byte or
word is assigned a certain address. Main memory is fast storage and it can
be accessed directly by the CPU. For a program to be executed, it should be
first loaded in the main memory. An Operating System performs the
following activities for memory management:
It keeps track of primary memory, i.e., which bytes of memory are used by
which user program. The memory addresses that have already been
allocated and the memory addresses of the memory that has not yet been
used. In multiprogramming, the OS decides the order in which processes are
granted access to memory, and for how long. It Allocates the memory to a
process when the process requests it and deallocates the memory when the
process has terminated or is performing an I/O operation.

7. Processor Management –
In a multi-programming environment, the OS decides the order in which
processes have access to the processor, and how much processing time
each process has. This function of OS is called process scheduling. An
Operating System performs the following activities for processor
management.
Keeps track of the status of processes. The program which performs this
task is known as a traffic controller. Allocates the CPU that is a processor to
a process. De-allocates processor when a process is no more required.

8. Device Management –
An OS manages device communication via their respective drivers. It
performs the following activities for device management. Keeps track of all
devices connected to the system. designates a program responsible for
every device known as the Input/Output controller. Decides which process
gets access to a certain device and for how long. Allocates devices in an
effective and efficient way. Deallocates devices when they are no longer
required.

9. File Management –
A file system is organized into directories for efficient or easy navigation and
usage. These directories may contain other directories and other files. An
Operating System carries out the following file management activities. It
keeps track of where information is stored, user access settings and status
of every file, and more… These facilities are collectively known as the file
system.

Features of Operating Systems:


 Provides a platform for running applications.
 Handles memory management and CPU scheduling.
 Provides file system abstraction.
 Provides networking support.
 Provides security features.
 Provides user interface.
 Provides utilities and system services.
 Supports application development.

File system:
A file is a named collection of related information that is recorded on
secondary storage such as magnetic disks, magnetic tapes and optical
disks. In general, a file is a sequence of bits, bytes, lines or records whose
meaning is defined by the files creator and user.
The Structure of Linux os:

The Linux architecture is largely composed of elements such as the Kernel,


System Library, Hardware layer, System, and Shell functions.

Kernel: The kernel is one of the fundamental parts of an operating system. It is


responsible for each of the primary duties of the Linux OS. Each of the major
procedures of Linux is coordinated with hardware directly. The kernel is in charge
of creating an appropriate abstraction for concealing trivial hardware or
application strategies. The following kernel varieties are mentioned:

1. Monolithic Kernel
2. Micro kernels
3. Exo kernels
4. Hybrid kernels
System Libraries: A set of library functions may be specified as these functions.
These functions are implemented by the operating system and do not require
code access rights on the kernel modules.

System Utility Programs: A system utility program performs specific and


individual jobs.

Hardware layer: The hardware layer of Linux is made up of several peripheral


devices such as a CPU, HDD, and RAM.

Shell: Different operating systems are classified as graphical shells and


command-line shells. A graphical shell is an interface between the kernel and the
user. It provides kernel services, and it runs kernel operations. There are two
types of graphical shells, which differ in appearance. These operating systems
are divided into two categories, which are the graphical shells and command-line
shells.

The graphical line shells allow for graphical user interfaces, while the command
line shells enable for command line interfaces. As a result, both of these shells
operate. However, graphical user interfaces performed using the graphical line
shells are faster than those using the command line shells.
Result:

Thus, the Introduction to the Linux operating system was studied.


EX.NO: BASIC LINUX COMMANDS
DATE:

AIM:

To study the basic Linux commands –CoCal

COMMANDS:

 To display user-whoami
 Display date-date
 Current month calendar-cal
 Create new directory-mkdir fol
 Display present work directory-pwd
 List directory contents-ls
 Remove directory-rmdir fol
 Create a text file-cat>test.txt
 View contents of text file-cat text.txt
 Clear contents on the screen-clear
 Sort content-sort test.txt
 Display first 10 lines from file-head test.txt
 Display last 10 lines from file-talc test.txt
 Copy contents from 1 file to other-cp file.txt file2.txt
 Number the lines-nl xx.txt
 Concatenate 2 files-cat f1.txt f2.txt

Result:

Thus the basic Linux commands was studied.


EX.NO: TO FIND THE AREA OF THE SQUARE
DATE: USING C PROGRAMMING
AIM:

To find the area of the square using c programming.

ALGORITHM:
Step1: Start the program
Step2: Initialize the variables
Step3: Get the input from the user
Step4: Print the area of the square
Step5: end the program

PROGRAM:

#include<stdio.h>

int main(){

int a,area;

printf(“enter a:”);

scanf(“%d”,&a);

area=a*a

printf(“area of square:%d”,area);

return0;

OUTPUT: Enter a=5

Area of the square =25

RESULT:

Thus the area of square is obtained and the output was verified.

EX.NO: TO FIND THE AREA OF RECTANGLE


USING C PROGRAMMING

DATE:

AIM:

To find the area of the rectangle using c programming.

ALGORITHM:
Step1: Start the program
Step2: Initialize the variables
Step3: Get the input from the user
Step4: Print the area of the rectangle
Step5: end the program

PROGRAM:
#include <stdio.h>
int main()
{
int width=5;
int height=10;
int area=width*height;
printf("Area of the rectangle=%d",area);
return 0;
}
OUTPUT:

Area of the rectangle=50

RESULT:

Thus the area of rectangle is obtained and the output was verified.
EX.NO: TO FIND THE SQUARE ROOT OF A NUMBER
DATE: USING C PROGRAMMING

AIM:

To find the square root using c programming.

ALGORITHM:
Step1: Start the program
Step2: Initialize the variables
Step3: Get the input from the user
Step4: Print the square root of a number
Step5: end the program

PROGRAM:
#include <stdio.h>
#include <math.h>
int main ()
{

int x, res;
float y, res1;
double z, res2;
x = 289;
res = sqrt(x);
print f (" The square root of %d is: %d", x, res);

y = 12.25;
res1 = sqrt(y);
print f (" \n The square root of %.2f is: %.2f", y, res1);
z = 144.00;
res2 = sqrt(z);
printf (" \n The square root of %.2lf is: %.2lf", z, res2);
return 0;
}
OUTPUT:

The square root of 289 is: 17

The square root of 12.25 is: 3.50

The square root of 144.00 is: 12.00

RESULT:

Thus the square root of number is obtained and the output was verified.
EX.NO: CONDITIONAL STATEMENT TO CHECK IF THE GIVEN
NUMBER IS ODD OR EVEN
DATE:

AIM:

To check the given number is odd or even

ALGORITHM:
Step 1-Start the program.

Step 2- Read/input the number.

Step 3- if n%2==0 then the number is even.

Step 4- else number is odd

Step5-end the program

PROGRAM:

#include <stdio.h>

int main()
{
int n;

printf("Enter an integer\n");
scanf("%d", &n);

if (n%2 == 0)
printf("Even\n");
else
printf("Odd\n");

return 0;
}

OUTPUT:

Enter the integer:2


It is even.

RESULT:

Thus the given number is even ,and the output was verified

You might also like