GoogelAddUnit1

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