Professional Documents
Culture Documents
void main()
{
int i,j,temp,n,a[25];
cout<<"Enter the no. of values less than 25"<<endl;
readln(n);
cout<<"Enter the array values"<<endl;
for(i=1;i<n;i++)
cin>>a[i];
for(i=1;i<n-1;i++)
for(j=i+1;j<n;j++)
if (a[i]>a[j])
{
temp:=a[i];
a[i]:=a[j];
a[j]:=temp;
}
cout<<"The ascending order is \n"
for i:=1 to n do
cout<<a[i];
getch();
}
#include<iostream.h>
#include<conio.h>
void main()
{
int a[10][10],b[10][10],c[10][10];
int m,n,i,j;
cout<<"Enter the order of matrix1\n";
cin>>m>>n;
cout<<"Enter the elements of matrix 1\n";
for(i=0;i<m;i++)
for(j=0;j<n;j++)
cin>>a[i][j];
cout<<"Enter the elements of matrix 2\n";
for(i=0;i<m;i++)
for(j=0;j<n;j++)
cin>>b[i][j];
for(i=0;i<m;i++)
for(j=0;j<n;j++)
c[i][j]=a[i][j]+b[i][j];
cout<<"The sum of two matrix is\n";
for(i=0;i<m;i++)
{
cout<<endl;
for(j=0;j<n;j++)
cout<<c[i][j];
}
getch();
}
#include<iostream.h>
#include<conio.h>
void main()
{
int n;
int fact(int);
clrscr();
cout<<"Enter an integer number\n";
cin>>n;
cout<<"factorial of"<<n<<" is "<<fact(n);
getch();
}
int fact(int m)
{
int i,j=1;
for(i=1;i<=m;i++)
j=j*i;
return(j);
}
/*Program to find whether the given number is prime or not using Function.*/
#include<iostream.h>
#include<conio.h>
int isprime(int n)
{
int i=2;
while(i<=n/2)
{
if(n%i==0)
return(0);
i=i+1;
}
return(1);
}
void main() // { Main program }
{
int i;
int isprime(int);
clrscr();
cout<<"Enter the number\n";
cin>>i;
if(isprime(i)==1)
cout<<"Given number is PRIME\n";
else
cout<<"NOT PRIME";
getch();
}