Professional Documents
Culture Documents
first yeat record work
first yeat record work
#include<stdio.h>
#include<conio.h>
main()
{
int n,r,s=0;
clrscr();
printf(“\n enter n value ”);
scanf(“%d”,&n);
while(n!=0)
{
r=n%10;
s=s+r;
n=n/10;
}
printf(“\n sum of the digits is %d”,s);
getch();
}
/* prime or composite */
#include<stdio.h>
#include<conio.h>
main()
{
int n,c=0,i;
clrscr();
printf(“\n enter a Number ”);
scanf(“%d”,&n);
if(n>1)
{
for(i=0;i<=n;i++)
{
if(n%i==0)
{
c=c+1;
}
if(c==2)
{
printf(“\n given number is prime ”);
}
else
{
printf(“\n given number is composite ”);
}
}
}
else
{
printf(“\n given number is not a prime and composit”);
}
getch();
}
/* Armstrong or Not */
#include<stdio.h>
#include<conio.h>
main()
{
int n,r,s=0,k;
clrscr();
printf(“\n enter a Number ”);
scanf(“%d”,&n);
k=n;
while(n!=0)
{
r=n%10;
s=s+(r*r*r*);
n=n/10;
}
if(k= =s)
{
printf(“\n given Number is Armstrong ”);
}
else
{
printf(“\n given Number is Not Armstrong ”);
}
getch();
}
/* Factorial of Given Number */
#include<stdio.h>
#include<conio.h>
main()
{
int n,f=1;
clrscr();
printf(“\n enter a Number ”);
scanf(“%d”,&n);
for(i=0;i<=n;i++)
{
f=f*i;
}
printf(“\n factorial of given number is %d ”,f);
getch();
}
/* Fibonacci series */
#include<stdio.h>
#include<conio.h>
main()
{
int f1=0,f2=1,f3,c=2;
clrscr();
printf(“\t %d \t %d”,f1,f2);
while(c<=10)
{
f3=f1+f2;
printf(\t %d”,f3);
f1=f2;
f2=f3;
c++;
}
getch();
}
/* Function with arguments no return type */
#include<stdio.h>
#include<conio.h>
main()
{
int a,b;
clrscr();
printf(“\n enter a Value ”);
scanf(“%d”,&a);
printf(“\n enter b value ”);
scanf(“%d”,&b);
sum(a,b);
getch();
}
sum(int x,int y)
{
int z;
z=x+y;
Printf(“\n the sum is %d”,z);
}
/* Function with arguments with return type */
#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
clrscr();
printf(“\n enter a Value ”);
scanf(“%d”,&a);
printf(“\n enter b value ”);
scanf(“%d”,&b);
c=sum(a,b);
Printf(“\n the sum is %d”,c);
getch();
}
sum(int x,int y)
{
int z;
z=x+y;
return z;
}
/* Find biggest and smallest element using array */
#include<stdio.h>
#include<conio.h>
main()
{
int a[9],s,l,i;
clrscr();
printf(“\n enter elements to an array ”);
for(i=0;i<9;i++)
{
scanf(“%d”,&n);
}
s=a[0];
printf(“\n smallest element is \n”);
for(i=0;i<9;i++)
{
if(a[i]<s)
s=a[i];
}
printf(“%d”,s);
printf(“\n the biggest element is \n”);
l=a[0];
for(i=0;i<9;i++)
{
if(a[i]>l)
l=a[i];
}
printf(“%d”,l);
getch();
}
/* Matrix addition */
#include<stdio.h>
#include<conio.h>
main()
{
int a[10][10],b[10][10],c[10][10],r1,r2,c1,c2,i,j;
clrscr();
printf(“\n enter the row size of the first matrix ”);
scanf(“%d”,r1);
printf(“\n enter the column size of the first matrix ”);
scanf(“%d”,c1);
printf(“\n enter the elements into the first matrix ”);
for(i=0;i<r1;i++)
{
for(j=0;j<c1;j++)
{
Printf(“\n enter the A[%d][%d]:”,i,j);
Scanf(“%d”,&a[i][j]);
}
}
printf(“\n enter the row size of the second matrix ”);
scanf(“%d”,r2);
printf(“\n enter the column size of the second matrix ”);
scanf(“%d”,c2);
printf(“\n enter the elements into the second matrix ”);
for(i=0;i<r2;i++)
{
for(j=0;j<c2;j++)
{
printf(“\n enter the B[%d][%d]:”,i,j);
scanf(“%d”,&b[i][j]);
}
}
Printf(“\n the first matrix is \n”);
for(i=0;i<r1;i++)
{
for(j=0;j<c1;j++)
{
printf(“ %d”,a[i][j]);
}
printf(“\n”);
}
#include<stdio.h>
#include<conio.h>
main()
{
int a[10][10],b[10][10],c[10][10],r1,r2,c1,c2,i,j;
clrscr();
printf(“\n enter the row size of the first matrix ”);
scanf(“%d”,r1);
printf(“\n enter the column size of the first matrix ”);
scanf(“%d”,c1);
printf(“\n enter the elements into the first matrix ”);
for(i=0;i<r1;i++)
{
for(j=0;j<c1;j++)
{
Printf(“\n enter the A[%d][%d]:”,i,j);
Scanf(“%d”,&a[i][j]);
}
}
printf(“\n enter the row size of the second matrix ”);
scanf(“%d”,r2);
printf(“\n enter the column size of the second matrix ”);
scanf(“%d”,c2);
printf(“\n enter the elements into the second matrix ”);
for(i=0;i<r2;i++)
{
for(j=0;j<c2;j++)
{
printf(“\n enter the B[%d][%d]:”,i,j);
scanf(“%d”,&b[i][j]);
}
}
#include<stdio.h>
#include<conio.h>
main()
{
int a[10][10],b[10][10],c[10][10],r1,r2,c1,c2,i,j;
clrscr();
printf(“\n enter the row size of the first matrix ”);
scanf(“%d”,r1);
printf(“\n enter the column size of the first matrix ”);
scanf(“%d”,c1);
printf(“\n enter the elements into the first matrix ”);
for(i=0;i<r1;i++)
{
for(j=0;j<c1;j++)
{
Printf(“\n enter the A[%d][%d]:”,i,j);
Scanf(“%d”,&a[i][j]);
}
}
printf(“\n enter the row size of the second matrix ”);
scanf(“%d”,r2);
printf(“\n enter the column size of the second matrix ”);
scanf(“%d”,c2);
printf(“\n enter the elements into the second matrix ”);
for(i=0;i<r2;i++)
{
for(j=0;j<c2;j++)
{
printf(“\n enter the B[%d][%d]:”,i,j);
scanf(“%d”,&b[i][j]);
}
}
Printf(“\n the first matrix is \n”);
for(i=0;i<r1;i++)
{
for(j=0;j<c1;j++)
{
printf(“ %d”,a[i][j]);
}
printf(“\n”);
}
#include<stdio.h>
#include<conio.h>
main()
{
int a[10][10],r,c,i,j;
clrscr();
printf(“\n enter the row size of the matrix ”);
scanf(“%d”,r);
printf(“\n enter the column size of the matrix ”);
scanf(“%d”,c);
printf(“\n enter the elements into the matrix ”);
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
Printf(“\n enter the A[%d][%d]:”,i,j);
Scanf(“%d”,&a[i][j]);
}
}
Printf(“\n the matrix is \n”);
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
printf(“ %d”,a[i][j]);
}
printf(“\n”);
}
Printf(“\n the transpose matrix is \n”);
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
printf(“ %d”,a[j][i]);
}
printf(“\n”);
}
/*Reverse of a Number*/
#include<stdio.h>
#include<conio.h>
main()
{
int n,r,t=0;
clrscr();
printf(“\n enter a Number ”);
scanf(“%d”,&n);
while(n!=0)
{
r=n%10;
t=t*10+r;
n=n/10;
}
printf(“\n the reverse number is %d”,t);
gtch();
}
/*Duplication string*/
#include<stdio.h>
#include<conio.h>
main()
Char t1[20],*t2;
Clrscr();
Scanf(“%s”,&t1);
t2=strdup(t1);
getch();
}
/*Converting upper&lower string*/
#include<stdio.h>
#include<conio.h>
main()
Char t[20];
Clrscr();
Scanf(“%s”,&t);
getch();