Practical File For FCP B
Practical File For FCP B
#include<conio.h>
#include<stdio.h>
main()
{
int a[10],i,j,t,k;
k=0;
printf(“enter ten numbers”);
for(i=0;i<10;i++)
{
if(t<a[i])
{
t=a[i];
k=i;
}
}
printf(“%d\t%d”,t,k);
getch();
}
PROGRAM-9
#include<conio.h>
#include<stdio.h>
main()
{
int a[10],i,j,t;
printf(“enter ten numbers”);
for(i=0;i<10;i++)
scanf(“%d”,&a[i]);
for(i=0;i<10;i++)
{
for(j=0;j<9;j++)
{
if(a[i]>a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
printf(“%d\t%d”,a[0],a[1]);
getch();
}
PROGRAM-10
#include<stdio.h>
#include<conio.h>
main()
{
int a[3][3],b[3][3],c[3][3],i,j;
printf(“enter the elements of first matrix”);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
scanf(“%d”,a[i][j]);
}
printf(“enter the elements of second matrix”);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
scanf(“enter the elements of second matrix”);
}
for(i=0;i<3;i++)
{
for(j=o;j<3;j++)
c[i][j]=a[i][j]+b[i][j];
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
printf(“%d\t”),c[i][j]);
printf(“\n”);
}
getch();
}
PROGRAM-11
#include<stdio.h>
#include<conio.h>
main()
{
int a[3][3],b[3][3],c[3][3],i,j,k;
printf(“enter the elements of first matrix”);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
scanf(“%d”,&a[i][j]);
}
printf(“enter elements of second matrix”);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
scanf(“%d”,&b[i][j]);
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
c[i][j]=0;
for(k=0;k<3;k++)
c[i][j]=c[i][j]+(a[i][k]*b[k][j]);
}}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
printf(“%d\t”,c[i][j]);
printf(“\n”);
}
getch();
}
PROGRAM-12
#include<conio.h>
#include<stdio.h>
main()
{
char a[10],b[10];
int i,j;
printf(“enter a string”);
scanf(“%s”,a);
printf(“enter another string”);
scanf(“%s”,b);
for(i=0;a[i]!=’\0’;i++);
for(j=0;b[j]!=’\0’;j++,i++)
a[i]=b[j];
printf(“%s”,a);
getch();
}
PROGRAM-13
#include<stdio.h>
#include<conio.h>
main()
{
char a[10];
int i,j,flag;
printf(“enter a string”);
scanf(“%s”,a);
for(j=0;a[j]!=’\0’;j++);
for(i=0,j--;i<j;i++,j--)
{
if(a[i]==a[j])
flag=1;
else
{
flag=0;
break;
}
}
if(flag==1)
printf(“string is pallindrom”);
else
printf(“string is not pallindrom”);
getch();
}
PROGRAM-14
#include<stdio.h>
#include<conio.h>
main()
{
char a[10],t;
int i,j;
printf(“enter a string”);
scanf(“%s”,a);
for(i=0;a[i]!=’\0’;i++);
for(j=0,i--;j<i;j++,i--)
{
t=a[i];
a[j]=a[i];
a[i]=t;
}
printf(“%s”,a);
getch();
}
PROGRAM-1
#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c,d,e,f;
printf(“enter the value of a”);
scanf(“%d”,&a);
printf(“enter the value of b”);
scanf(“%d”,&b);
c=a+b;
d=a-b;
e=a*b;
f=a/b;
printf(“\nthe sum is”);
printf(“%d”,c);
printf(“\nthe difference is”);
printf(“%d”,d);
printf(“\nthe product is”);
printf(“%d”,e);
printf(“\nthe division is”);
printf(“%d”,f);
getch();
}
PROGRAM-2
#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
printf(“enter the first number”);
scanf(“%d”,&a);
printf(“enter the second number”);
scanf(“%d”,&b);
c=a;
a=b;
b=c;
printf(“%d\t%d”,a,b);
getch();
}
PROGRAM-3
#include<stdio.h>
#include<conio.h>
main()
{
int a,b;
printf(“enter the first number”);
scanf(“%d”,&a);
printf(“enter the second number”);
scanf(“%d”,&b);
a=a+b;
b=a-b;
a=a-b;
printf(“%d\t%d”,a,b);
getch();
}
PROGRAM-4
#include<stdio.h>
#include<conio.h>
main()
{
int n;
printf(“enter a number”);
scanf(“%d”,&n);
if(n%2==0)
printf(“even number”);
else
printf(“odd number”);
getch();
}
PROGRAM-5
#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
printf(“enter three numbers”);
scanf(“%d%d%d”,&a,&b,&c);
if(a>b&&a>c)
{
printf(“%d”,a);
printf(“is greatest”);
}
else
if(b>a&&b>c)
{
printf(“%d”,b);
printf(“is greatest”);
}
else
{
printf(“%d”,c);
printf(“is greatest”);
}
getch();
}
PROGRAM-6
#include<stdio.h>
#include<conio.h>
main()
{
int sum,a,n;
sum=0;
printf(“enter the number”);
scanf(“%d”,&n);
while(n>0)
{
a=n%10;
n=n/10;
sum=sum+a;
}
printf(“%d”,sum);
getch();
}
PROGRAM-7
#include<stdio.h>
#include<conio.h>
main()
{
int n,a,sum;
sum=1;
printf(“enter the number”);
scanf(“%d”,&n”);
while(n>0)
{
sum=sum*n;
n--;
}
printf(“%d”,sum);
getch();
}
PROGRAM-1
OUTPUT
enter a stringtech
enter another stringnology
technology
PROGRAM-13
OUTPUT
enter a stringnitin
string is pallindrom
PROGRAM-14
OUTPUT
enter a stringyatin
nitay