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

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


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

#include<stdio.h>
main()
{
int n,rn=0,d,k;
printf("enter the value of n");
scanf("%d",&n);
k=rn;
while(n>0)
{
d=n%10;
rn=(rn*10)+d;
n=n/10;
}
if(k==rn)
printf("it is a pallindrom");
else
printf("it is not a pallindrom");
}

OUTPUT:


enter the value of n
121
it is a pallindrom
enter the value of n
456
it is not a pallindrom

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


AIM:a pragram to test the given number is an armstrong number(or) not.PROGRAM:

#include<stdio.h>
main()
{
int i=1,n,sum=0,c,k;
printf("enter the value of n");
scanf("%d",&n);
k=n;
while(n>0)
{
d=n%10;
c=d*d*d;
sum=sum+c;
n=n/10;
}
if(sum==k)
printf("it is an armstrong number");
else
printf("it is not an armstrong number");
}

OUTPUT:


enter the value of n
153
it is an armstrong number
enter the value of n
23
it is not an armstrong number

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


AIM:A program to test the given number is perfect number (or) not.PROGRAM:

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

OUTPUT:


enter the value of n
6
it is a perfect number
enter the value of n
1
it is not a perfect number

WRITE A C-PROGRAM TO PRINT THE FIBANOCCI SERIES.

 AIM:A program to print the fibanocci series.
PROGRAM:


#include<stdio.h>
main()
{
int i,n,a=0,b=1,c;
printf("enter the value of n");
scanf("%d",&n);
while(i<=n)
{
c=a+b;
printf("%d",c);
a=b;
b=c;
}
printf("%d",c);
printf("the fibanocci series is%d\n");
}

OUTPUT:


enter the value of n
4
the fibanocci series is 0,1,2,3

WRITE A PROGRAM TO ENTER ANY ARITHEMATIC OPERATOR TO PRINT THE CONCERN RESULT. AIM:A program to enter any arithematic operator to print the concren result.


PROGRAM:

#include<stdio.h>
main()
{
int a,b;
char op;
printf("enter the values of a,b");
scanf("%d%d",&a,&b);
printf("enter arithematic operator");
scanf("%c",&op);
switch(op)
{
case '+':printf("a+b=%d",a+b);
               break;
case '-':printf("a-b+=%d",a-b);
             break;
case '*':printf("a*b=%d",a*b);
             break;
case '/':printf("a/b=%d",a/b);
             break;
default :printf("unknown arithematic operator");
}

OUTPUT:


enter the values of a,b
1,2
enter arithematic operator
'+'
1+2=3.

Friday, 6 July 2012

WRITE A C-PROGRAM TO TEST THE STUDENT IS FIRST CLASS (OR) SECOND CLASS (OR) THIRD CLASS(OR) FAIL. AIM:A program to test the student is passed with first class(or) second class(or) third class(or)the student is fail.


PROGRAM:

#include<stdio.h>
main()
{
int sno,m1,m2,m3,total;
printf("enter the values of sno,m1,m2,m3");
scanf("%d%d%d%d",&sno,&m1,&m2,&m3);
total=m1+m2+m3;
if((m1>=35)&&(m2>=35)&&(m3>=35)&&(total>=180))
printf("the student is passed with first class");
else
if((m1>35)&&(m2>35)&&(m3>=35)&&(total>=150)&&(total<=180))
printf("the student is passed with second class");
else
if((m1>=35)&&(m2>=35)&&(m3>=35)&&(total>=105)&&(total<=150))
printf("the student is passed with third class");
else
printf("the student is fail");
}

OUTPUT:

enter the values of sno,m1,m2,m3
408
78
60
50
the student is passed with first class

Monday, 16 April 2012

WRITE A C-PROGRAM TO FIND THE BIGGEST&SMALLEST NUMBER OF THE GIVEN MATRIX.

WRITE A C-PROGRAM TO FIND THE BIGGEST&SMALLEST NUMBER OF THE GIVEN MATRIX.
AIM:A program to find the biggest and smallest number of a given matrix.
PROGRAM:
#include<stdio.h>
main()
{
int a[10][10],i,j,m,n,big,small;
printf("enter the values of m,n");
scanf("%d%d",&m,&n);
printf("enter the elemnts of matrix a");
for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
big=a[0][0];
small=a[0][0];
for(i=0;i<m;i++)
for(j=0;j<n;j++)
if(a[i][j]>big)
big=a[i][j];
if(a[i][j]<small)
small=a[i][j];
printf("biggest element =%d",big);
printf("smallest element =%d",small);
}
OUTPUT:
enter the values of m,n
3,3
enter the elements of matrix a
1 2 3
3 4 5
5 6 7
biggest element 7
smallest element 1
WRITE A C-PROGRAM TO DEFINE A STRUCTURE WITH THE STUDENT NUMBER,NAME,M1,M2,M3 FIND THE RESULT OF DIFFERENT STUDENTS.

AIM:A program to find the result of different students using structures.
PROGRAM:
#include<stdio.h>
struct stu
{
int no,m1,m2,m3;
char name[20];
float ave;
}s[50];
main()
{
int i,n;
printf("enter the no.of students");
scanf("%d",&n);
for(i=0;i<=n;i++)
{
printf("enter the values of number,name,m1,m2,m3");
scanf("%d%s%d%d%d",s[i].no,s[i].name,s[i].m1,s[i].m2,s[i].m3);
s[i].avg=(s[i].m1+s[i].m2+s[i].m3)/3;
for(i=0;i<=n;i++)
{
if((s[i].m1>=35)&&(s[i].m2>=35)&&(s[i].m3>=35))
{
if((s[i].avg>=75)&&(s[i].avg<=100))
printf("distinction");
else
if((s[i].avg>=60)&&(s[i].avg<75))
printf("first class");
else
if((s[i].avg>=50)&&(s[i].avg<60))
printf("second class");
else
printf("third class");
}
else
printf("fail");
}
}
OUTPUT:
enter the values of no,name,m1,m2,m3
2,sneha,78,67,45
distinction

WRITE A C-PROGRAM TO FIND THE SUM OF ANY TWO NUMBERS USING RECURRSION.

WRITE A  C-PROGRAM TO FIND THE SUM OF ANY TWO NUMBERS USING RECURRSION.
AIM:A program to find the sum of any two number using recurrsion.
PROGRAM:
#include<stdio.h>
main()
{
int a,b,k;
printf("enter the values of a,b");
scanf("%d%d",&a,&b);
k=sum(a,b);
printf("sum=%d",k);
}
sum(a,b)
int a,b;
{
if(a==0)
return(b);
else
sum(--a,++b);
}
OUTPUT:
enter the values of a,b
30,20
sum=50

WRITE A C-PROGRAM TO FIND THE FACTORIAL VALUE USING RECURRSION

WRITE A C-PROGRAM TO FIND THE FACTORIAL VALUE USING RECURRSION
AIM:A program to find the factorial value using recurrsion
PROGRAM:
#include<stdio.h>
main()
{
int n,k;
printf("enter the value of n");
scanf("%d",&n);
k=fact(n);
printf("factorial value of a given number :%d",k);
}
fact(int m)
{
if(m==1)
return(1);
else
return(m*fact(m-1));
}
OUTPUT:
enter a number
4
factorial value of a given number: 24
enter a number
3
factorial value of a given number: 6

WRITE A C-PROGRAM TO FIND THE MULTIPLICATION OF TWO MATRICES OF SIZE M*P&P*N.

WRITE A C-PROGRAM TO FIND THE MULTIPLICATION OF TWO MATRICES OF SIZE M*P&P*N.
AIM:A program tofind the multiplication of the two matrices of size m*p,p*n.
PROGRAM:
#include<stdio.h>
main()
{
int a[10][10],b[10][10],c[10][10],i,j,k,m,n,p;
printf("enter the values of m,n,p");
scanf("%d%d%d",&m,&n,&p);
printf("enter the elements of matrix a");
for(i=0;i<m;i++)
for(j=0;j<p;j++)
scanf("%d",&a[i][j]);
printf("enter the elements of matrix b");
for(i=0;i<p;i++)
for(j=0;j<n;j++)
scanf("%d",&b[i][j]);
for(i=0;i<m;i++)
for(j=0;j<n;j++)
{
c[i][j]=0;
for(k=0;k<p;k++)
c[i][j]=c[i][j]+(a[i][k]*b[k][j]);
}
printf("the multiplication matrix is =%d",c[i][j]);
for(i=0;i<m;i++)
for(j=0;j<n;j++)
printf("%d",c[i][j]);
printf("\n");
}
}
OUTPUT:
enter the values of m,n,p
 2,2,2
enter the elements of matrix a
1 2 3 4
enter the elements of matrix b
1 0 0 1
the multiplication matrix is
1 2 3 4

WRITE A C-PROGRAM TO TEST THE GIVEN MATRIX IS SYMMETRIC (OR) NOT.

WRITE A C-PROGRAM TO TEST THE GIVEN MATRIX IS SYMMETRIC (OR) NOT.
AIM:A program to test the given matrix is symmetric (or) not
PROGRAM:
#include<stdio.h>
main()
{
int a[10][10],b[10][10],i,j,m,n;
printf("enter the values of m,n");
scanf("%d%d",&m,&n);
printf("enter the elements of matrix a");
for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf("%d",&a[i]][j]);
for(i=0;i<m;i++)
for(j=0;j<n;j++)
b[i][j]=a[j][i];
for(i=0;i<m;i++)
for(j=0;j<n;j++)
if(a[i][j]==b[i][j])
printf("it is a symmetric matrix");
else
printf("it is not a symmetric matrix");
}
OUTPUT:
enter the values of m,n
2,2
enter the elements of matrix a
1 3 2 5
it is a symmetric matrix

WRITE A C-PROGRAM TO PRINT THE UPPER TRIANGLE,LOWER TRIANGLE&DIAGONAL SUMS.

WRITE A C-PROGRAM TO PRINT THE UPPER TRIANGLE,LOWER TRIANGLE&DIAGONAL SUMS.
AIM:A program to find the upper triangle,lower triangle,diagonal sums.
PROGRAM:
#include<stdio.h>
main()
{
int a[10][10],i,j,m,n,usum=0,lsum=0,dsum=0;
printf("enter the values of m,n");
scanf("%d%d",&m,&n);
printf("enter the elements of matrix a");
for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
for(i=0;i<m;i++)
for(j=0;j<n;j++)
if(i<j)
usum=usum+a[i][j];
else
if(i>j)
lsum=lsum+a[i][j];
else
if(i==j)
dsum=dsum+a[i][j];
printf("upper triangle sum=%d",usum);
printf("lower triangle sum=%d",lsum);
printf("diagonal sum=%d",dsum);
}
OUTPUT:
enter the values of m,n
3,3
enter the elements of matrix a
3 4 5
1 2 3
4 3 2
uppre triangle sum=
lower triangle sum=
diagonal sum=

WRITE A C-PROGRAM TO FIND THE BIGGEST&SMALLEST NUMBER OF THE GIVEN MATRIX.

WRITE A C-PROGRAM TO FIND THE BIGGEST&SMALLEST NUMBER OF THE GIVEN MATRIX.
AIM:A program to find the biggest and smallest number of a given matrix.
PROGRAM:
#include<stdio.h>
main()
{
int a[10][10],i,j,m,n,big,small;
printf("enter the values of m,n");
scanf("%d%d",&m,&n);
printf("enter the elemnts of matrix a");
for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
big=a[0][0];
small=a[0][0];
for(i=0;i<m;i++)
for(j=0;j<n;j++)
if(a[i][j]>big)
big=a[i][j];
if(a[i][j]<small)
small=a[i][j];
printf("biggest element =%d",big);
printf("smallest element =%d",small);
}
OUTPUT:
enter the values of m,n
3,3
enter the elements of matrix a
1 2 3
3 4 5
5 6 7
biggest element 7
smallest element 1

WRITE A C-PROGRAM TO FIND THE TRACE OF A MATRIX OF SIZE M*N.

WRITE A C-PROGRAM TO FIND THE TRACE OF A MATRIX OF SIZE M*N.
AIM:A program to find the trace of a matrix of size m*n.
PROGRAM:
#include<stdio.h>
main()
{
int a[10][10],i,j,sum=0;
printf("enter the values of m,n");
scanf("%d%d",&m,&n);
printf("enter the elements of matrix a");
for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
for(i=0;i<m;i++)
for(j=0;j<n;j++)
if(i==j)
sum=sum+a[i][j];
printf("trace of a matrix=%d",sum);
}

OUTPUT:
enter the value of m,n
2,2
enter the elements of matrix a
1 2 3 4
trace of a matrix is

WRITE A C-PROGRAM TO FIND THE LOCATION OF THE REQUIRED ELEMENT.

 AIM:A program to find the location of the required element


PROGRAM:
#include<stdio.h>
main()
{
int i,n,a[100],m,x,f=0;
printf("enter the value of n");
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("enter the required element");
scanf("%d",&x);
for(i=0;i<n;i++)
{
if(a[i]==x)
{
m=i;
f++;
}
}
if(f==0)
printf("the required element is not found");
else
printf("the required element is found in the list and the position is%d",m);
}

OUTPUT:
enter the value of n
5
the required element is found in the list

WRITE A C-PROGRAM TO FIND THE STANDARD DEVIATION USING FUNCTIONS.

AIM:A program to find the standard deviation using functions.


PROGRAM:
#include<stdio.h>
main()
{
int n,x[100],s;
printf("enter the value of n");
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&x[i]);
s=pas(x,n);
printf("standard deviation=%f",s);
}
pas(x,n)
{
int x[100],n;
int sum=0,vsum=0,i,k;
{
float mean,sd;
for(i=0;i<n;i++)
sum=sum+x[i];
mean=sum/n;
for(i=0;i<n;i++)
vsum=vsum+(x[i]-mean*x[i]-mean);
k=vsum/n;
sd=sqrt(k);
return(sd);
}
}

OUTPUT:
enter the value of n

WRITE A C-PROGRAM TO FIND THE VOWELS,CONSONANTS,DIGITS,OTHERS IA A LINE.

AIM:A program to find the vowels,constants,digits,others in a sentence.


PROGRAM:
#include<stdio.h>
main()
char line[80],c;
int i=v0w=cons=digit=wides=words=others=0;
printf("enter any string");
scanf("%s",line);
while((c==tolower(line[i++]!='\o'))
{
if((c=='a')||(c=='e')||(c=='i')||(c=='o')||(c=='u'))
++v=w;
else
if((c>='a')&&(c<='z'))
++cons;
else
if((c>='o')&&(c<='9'))
++digit;
else
if(c==' ')
{
++wides;
++words;
while((line[i++]==' ')||(line[i++]=='\+'))
{
++wides;
i++;
}
}
else
++others;
}
++words;
printf("vowels=%d\n");
printf("consonants=%d\n");
printf("digits=%d\n");
printf("wides=%d\n");
printf("words=%d\n");
printf("others=%d\n");
scanf("%d",vowels);
scanf("%d",consonants);
scanf("%d",digits);
scanf("%d",wides);
scanf("%d",words);
scanf("%d",others);
}

OUTPUT:
enter any string
pas college 123
vowels=a,e,o,e=4
consonants=6
digits=3
wides=2
words=2
others=1

WRITE A C-PROGRAM TO CONCATINATE ANY THREE STRINGS.

AIM:A program to concatinate any three strings.


PROGRAM:
#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 functions


PROGRAM:
#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

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

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


PROGRAM:
#include<stdio.h>
main()
{
int n,rn=0,d,k;
printf("enter the value of n");
scanf("%d",&n);
k=rn;
while(n>0)
{
d=n%10;
rn=(rn*10)+d;
n=n/10;
}
if(k==rn)
printf("it is a pallindrom");
else
printf("it is not a pallindrom");
}

OUTPUT:
enter the value of n
121
it is a pallindrom
enter the value of n
456
it is not a pallindrom

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

AIM:a pragram to test the given number is an armstrong number(or) not.

PROGRAM:
#include<stdio.h>
main()
{
int i=1,n,sum=0,c,k;
printf("enter the value of n");
scanf("%d",&n);
k=n;
while(n>0)
{
d=n%10;
c=d*d*d;
sum=sum+c;
n=n/10;
}
if(sum==k)
printf("it is an armstrong number");
else
printf("it is not an armstrong number");
}

OUTPUT:
enter the value of n
153
it is an armstrong number
enter the value of n
23
it is not an armstrong number

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

AIM:A program to test the given number is perfect number (or) not.
PROGRAM:
#include<stdio.h>
main()
{
int i,n,sum=0;
printf("enter the value of n");
scanf("%d",&n);
for(i=1;i<n-1;i++)
{
if(n%i==0)
sum=sum+i;
}
if(sum==n)
printf("it is a perfect number");
else
printf("it is not a perfect number");
}

OUTPUT:
enter the value of n
6
it is a perfect number
enter the value of n
1
it is not a perfect number

WRITE A C-PROGRAM TO PRINT THE FIBANOCCI SERIES.

AIM:A program to print the fibanocci series.
PROGRAM:
#include<stdio.h>
main()
{
int i,n,a=0,b=1,c;
printf("enter the value of n");
scanf("%d",&n);
while(i<=n)
{
c=a+b;
printf("%d",c);
a=b;
b=c;
}
printf("%d",c);
printf("the fibanocci series is%d\n");
}
OUTPUT:
enter the value of n
4
the fibanocci series is 0,1,2,3

WRITE A PROGRAM TO ENTER ANY ARITHEMATIC OPERATOR TO PRINT THE CONCERN RESULT.

AIM:A program to enter any arithematic operator to print the concren result.
PROGRAM:
#include<stdio.h>
main()
{
int a,b;
char op;
printf("enter the values of a,b");
scanf("%d%d",&a,&b);
printf("enter arithematic operator");
scanf("%c",&op);
switch(op)
{
case '+':printf("a+b=%d",a+b);
               break;
case '-':printf("a-b+=%d",a-b);
             break;
case '*':printf("a*b=%d",a*b);
             break;
case '/':printf("a/b=%d",a/b);
             break;
default :printf("unknown arithematic operator");
}
OUTPUT:enter the values of a,b
1,2
enter arithematic operator
'+'
1+2=3.

WRITE A C-PROGRAM TO TEST THE STUDENT IS FIRST CLASS (OR) SECOND CLASS (OR) THIRD CLASS(OR) FAIL.

AIM:A program to test the student is passed with first class(or) second class(or) third class(or)the student is fail.
PROGRAM:
#include<stdio.h>
main()
{
int sno,m1,m2,m3,total;
printf("enter the values of sno,m1,m2,m3");
scanf("%d%d%d%d",&sno,&m1,&m2,&m3);
total=m1+m2+m3;
if((m1>=35)&&(m2>=35)&&(m3>=35)&&(total>=180))
printf("the student is passed with first class");
else
if((m1>35)&&(m2>35)&&(m3>=35)&&(total>=150)&&(total<=180))
printf("the student is passed with second class");
else
if((m1>=35)&&(m2>=35)&&(m3>=35)&&(total>=105)&&(total<=150))
printf("the student is passed with third class");
else
printf("the student is fail");
}
OUTPUT:
enter the values of sno,m1,m2,m3
408
78
60
50
the student is passed with first class

WRITE A C-PROGRAM TO FIND THE BIGGEST NUMBER AMONG THREE NUMBERS.

AIM:A program to find the biggest number among three numbers.
PROGRAM:
#include<stdio.h>
main()
{
int a,b,c,big;
printf("enter the values of a,b,c");
scanf("%d%d%d",&a,&b,&c);
if((a>b)&&(a>c))
big=a;
else
if((b>a)&&(b>c))
big=b;
else
big=c;
printf("biggest number=%d",big);
}
OUTPUT:
enter the values of a,b,c
2,3,4
biggest number =4.