Programming Foundation Part1 Rec
Programming Foundation Part1 Rec
Programming Foundation Part1 Rec
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.
Batch OS.
Distributed OS.
Multitasking OS.
Network OS.
Real-OS.
Mobile OS
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.
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.
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.
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:
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.
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:
AIM:
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:
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;
RESULT:
Thus the area of square is obtained and the output was verified.
DATE:
AIM:
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:
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:
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:
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:
ALGORITHM:
Step 1-Start 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:
RESULT:
Thus the given number is even ,and the output was verified