GE2115 Computer practice Laboratory Part 6

The Eduladder is a community of students, teachers, and programmers just interested to make you pass any exams. So we solve previous year question papers for you.
Watch related videos of your favorite subject.
Connect with students from different parts of the world.
See Our team
Wondering how we keep quality?
Got unsolved questions?

You are here:Open notes-->Anna-University-->GE2115-Computer-practice-Laboratory-Part-6

# How to study this subject

51. Program to print “PASCAL TRIANGLE”.
#include
#include
main()
{
int n,p=1,q,num,sp;
clrscr( );
printf(“enter the number of rows”);
scanf(“%d”,&n);
for(p=0;p<=n;p++)
{
for(sp=1;sp<=40-(3*p);sp++)
printf(“ “);
for(q=0;q
{
if((q==q)||(q==0))
num=1;
else
num=num*((q-q)+1)/q;
printf(“%2d”,num);
printf(“\n”);
}}
getch( );
} 23
52. Program to check whether a given number is perfect or not.
# include
# include
main( )
{
int i,n,s=0;
clrscr();
printf(“enter the number”);
scanf(“%d”,&n);
for(i=1;i
if(n%i==0)
s+=i;
if(s= =n)
printf(“the number is perfect no”);
else
printf(“the number is not perfect “);
getch( );
}
53. Program to check whether a given number is prime number.
# include
# include
main( )
{
int i,n,c=0;
clrscr( );
printf(“enter a number”);
scanf(“%d”,&n);
for(i=0;i<=n;i++)
if(n%i==0)
c++;
if(c==2)
printf(“given number is a prime number”);
else
printf(“given number is not prime number”);
getch( );
}
54. Program to read ‘n’ number and print them in matrix terms in all orders.
# include
# include
main( )
{
int i,n,c,p,q,r,k,a[20];
clrscr();
printf(“enter the array size”);
scanf(”%d”,&n);
printf(“enter the elements”);
for(i=1;i<=n;i++)
scanf(“%d”,&a[i]);
i=1;
while(i<=n) 24
{
if(n%i==0)
{
r=i;
c=n/i;
k=1;
for(p=1;p<=r;p++)
{
for(q=1;q<=c;q++)
printf(“%d”,a[k++])
printf(“\n”);
}
i++;
getch( );
}
55. Program to search an element using binary search
# include
# include
main( )
{
int a[100],i,n,x, mid, top, bot,c;
clrscr();
printf(“enter the array size;”);
scanf(“%d”,&n);
printf(“enter the array elements”);
for(i=1;i<=n;i++)
scanf(“%d”,&a[i]);
top=1;
bot=n;
c=0;
printf(“enter the element to searched”);
scanf(“%d”,&x);
while((top <=bot)&&(c==0))
{
mid=(top+bot)/2;
if(a[mid]
top=mid+1;
else
if(a[mid]>x)
bot=mid-1;
else
c=1;
}
if(c==1)
printf(“elements is at position;%d”,mid);
else
printf(“elements is not in list”);
getch( );
} 25
56. Program to accept two numbers and print the sum of given two numbers by using pointers
# include
# include
main( )
{
int a, b,c;
clrscr( );
a=10;
b=20;
c=*(&a)+*(&b);
printf(“%d”,c);
getch( );
}
57. Programs to multiply two Matrices
# include
# include
main( )
{
int a[10][10],b[10][10],c[10],[10],i,j,m,n,p,q,k;
clrscr( );
printf(“enter the size of first matrices”);
scanf(“%d%d’,&m,&n);
printf(“enter the size of second matrix”);
scanf(“%d%d’,&p,&q);
if(n==p)
{
printf(“enter first matrices elements”);
for(i=1;i
for(j=1;j
scanf(“%d”,&a[i][j]);
printf(“enter second matrix elements”);
for(i=1;i
for(j=1;j
scanf(“%d”,&b[i][j]);
for(i=1;i
for(j=1;j
{
c[i][j]=0;
for(k=1;k
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
printf(“the multiplication matrix is”);
for(i=1;i
{
for(j=1;j
print(“%2d”,c[i][j]);
printf(“\n”);
}
}
elseVasantha Kumar .V Lecturer CSE 26
printf(“multiplication is not possible”);
getch( );
}
58. Program to print prime number between 1-100
# include
# include
main( )
{
int i,n,c;
clrscr( );
for(n=1;n<=100;n++)
{
c=0;
for(i=1;i<=n;i++)
if(n%i==0)
c++;
if(c==2)
printf(“\n%d”,n);
}
getch( );
}
59. Program to accept a string and find the length of the string
# include
# include
main( )
{
char name[80];
int i;
clrscr( );
printf(“enter a string ;”);
for(i=0;i<80&&((name[i]=getchar( ))!=’\n’);i++);
printf(“%d is the size of string”,i);
getch( );
}
60. Program to fibanocci of matrix
# include
# include
# include
main( )
{
int a[10][10],i,j,m,n sum=0;
float norm;
clrscr( );
printf(‘enter the matrix size”);
scanf(“%d%d”,&m,&n);
printf(“enter the element of matrix”);
for(i=1;i<=m;i++)
for(j=1;j<=n;j++) 27
{
scanf(“%d”,&a[i][j]);
sum=sum+(a[i][j]*a[i][j])
}
norm=sqrt(sum);
printf(“norm=%f”,norm);
getch( );
}

# Previous year question papers

## Tool box

Edit this note | Upvote | Down vote | Questions

### Watch more videos from this user Here

Eduladder videos are community generated video contents which we deliver to you according to the content you are browsing.We are constantly working on video delivering algorithms in order to give you the best experiance as possible

Learn how to upload a video and start earning here