GoogelAddUnit1

Friday 5 October 2012

How to Execute C Language Programs on UNIX Operating System.

 UNIX is MULTICS OS, i.e Multi user OS., Invented by Ken Thompson and Dennis Richie at AT & T  Bell telephone Elaborateness USA in the year 1972., Till there there is only one OS is the market ., i.e DOS.
The first version of UNIX was written in Machine Language., Afterwords it was rewritten in Assembly Language., later it moves into B language(BCPL)., after the invention of C Language by Thompson and Richie  UNIX OS was rewritten in C Language., presently available.

Basic Feature of UNIX OS.

- Unix is more flexible and can be installed on many different types of machines, including main-frame computers, supercomputers and micro-computers.
- Unix is more stable and does not go down as often as Windows does, therefore requires less administration and maintenance.
- Unix has greater built-in security and permissions features than Windows.
- Unix possesses much greater processing power than Windows.
- Unix is the leader in serving the Web. About 90% of the Internet relies on Unix operating systems running Apache, the world's most widely used Web server.
- Software upgrades from Microsoft often require the user to purchase new or more hardware or prerequisite software. That is not the case with Unix.
- It is a Multics user OS.
- It is a Multitasking OS.
- It provide primitives that build complex structures from smaller ones.
- It provide more security to user programs.
- It support different types of users.
- It support hierarchical file system.

Unix has a layered structure.
1.     Innermost layer is the hardware—CPU, memory, devices.
2.     The core components of OS is referred as the kernel(a central or essential part) in Unix. The kernel, interacts directly with the hardware and provides the services to the user programs. These user programs don't need to know anything about the hardware.
3.     Unix Shells: A shell acts as an interpreter between a user and the kernel. A user interacts with the kernel through a set of standard system calls(aka Unix commands or shell commands).

Unix is a multi-user, multi-tasking operating system. Many users can log on simultaneously, each running many programs. It is the kernel’s job to keep each process and user separate and to control accesses to system hardware including CPU, memory, disk, and other I/O devices.

Important  Features:

  Over 40 years of experience
·         Available for almost any hardware platform
·         Robust: made to keep on running
·         Secure and versatile
·         Scalable
       Many different dialects
·         Many proprietary systems: bundling and system specific implementation of commands/packages
·         Not user friendly, confusing for beginners
·         Proprietary hardware is expensive

The kernel
The kernel is the core of the UNIX operating system. Basically, the kernel is a large program with many modules that is loaded into memory when the machine is turned on, and it controls the allocation of hardware resources. The kernel knows what hardware resources are available (like the processor(s), the on-board memory, the disk drives, network interfaces, etc.), and it has the necessary programs(drivers) to talk to all the devices connected to it.

The standard utility programs
These programs include many programs ranging from simple utilities like cp, which copies files, to complex utilities, like the shell programs that allow you to issue a series of commands to the operating system.

The system configuration files
The system configuration files are read(used) by the kernel, and some of the standard utilities. Certain aspects of kernel and utilities can be controlled by changing the standard configuration files. In other words, they can be customized.
One example of a system configuration file is the filesystem table "fstab" , which tells the kernel where to find all the files on the disk drives. Another example is the system log configuration file "syslog.conf", which tells the kernel how to record the various kinds of events and errors it may encounter.

 Login: One thing to remember is Unix is case sensitive—including login name & password

·         Logout: Type either “^D”  or  “exit

·         Leave a shell: If you have changed a shell, to go back to a previous shell, type “exit”.

·         Identity: A user is identified by uid(user id) + gid(group id)—type id  to see your id—group id is used by administrator to assign access rights—typegroups to see all the groups you belong to.

Types of Users in Unix OS.

1.     Root User or System Administrator
2.     Ordinary User or Individual  User
3.     Group user or User Group

  All the above users login in from any terminal whether it is server or client.

Standard System Prompts to above Users.

1.     Root User or System Administrator is  # prompt.
2.     Ordinary User or Individual  User is $ prompt.
3.     Group user or User Group $ prompt.
  How to write a C Program on UNIX OS.
   $ vi file name (file name.c if it is a C Language Program)
      vi editor opens is Esc mode or Command mode., Press i changes Insert mode.
      Type the C Language program.
   for saving
   press Esc key :wq
   for compilation $ cc file name
   shows error list or successful compilation.
   if errors occur go to $ vi file name
   if program is compiled successfully for running
   $ a.out
   C Language Program result will be displayed.
  i.e Compilation of  C Language Programs on UNIX OS.








Sunday 8 July 2012

WRITE A C-PROGRAM TO CONCATINATE ANY THREE STRINGS.


AIM:A program to concatinate any three stringsPROGRAM:

#include<stdio.h>
main()
{
int i,j,k;
char a[20],b[20],c[20],d[20];
printf("enter the three strings");
scanf("%s%s%s",a,b,c);
for(i=0;a[i]!='\o';i++)
d[i]=a[i];
d[i]=' ';
for(j=0;b[j]!='\o';j++)
d[i+j+1]=b[j];
d[i+j+1]=' ';
for(k=0;c[k]!='\o';k++)
d[i+j+k+2]=c[k];
d[i+j+k+2]='\o';
printf("the new string is%d",d);
}

OUTPUT:

enter the three strings

the new string is

WRITE A C-PROGRAM TO TEST THE GIVEN STRING IS PALLIDROM (OR) NOT.


AIM:A program to test the given string is pallindrom (or) not.
PROGRAM:

#include<stdio.h>
main()
{
char a[30],c;
int i,j,l,f=0;
printf("enter any string");
scanf("%s",a);
for(l=0;a[l]!='\o';l++)
printf("%d",l);
for(i=0,j=l-1;i<l/2;i++,j--)
{
if(a[i]==a[j])
f=1;
}
if(f==1)
printf("it is a pallindrom");
else
printf("it is not a pallindrom");
}

OUTPUT:


enter any string
madam
it is a pallindrom
enter any string
sudha
it is not a pallindrom

WRITE A C-PROGRAM TO TEST THE GIVEN NUMBER IS PRIME NUMBER (OR) NOT USING FUNCTIONS.


AIM:Aprogram to test the given number is prime number (or) not using functionsPROGRAM:

#include<stdio.h>
main()
{
int n,k;
printf("enter the value of n");
scanf("%d",&n);
pas(n);
if(k==n)
printf("it is a prime number");
else
printf("it is not a prime number");
}
pas(n)
{
int n,k;
int i=1;
{
while(i<=n)
{
if(n%i==0)
i++;
k++;
}
}
}

OUTPUT:

enter the value of n
7
it is a prime number
enter the value of n
6
it is not a prime number