GE2115 Computer practice Laboratory Part 9
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.
See Our team
Wondering how we keep quality?
Got unsolved questions?

Hey! Want to work with us? Our youtube channel See our Jd Want to apply? Do it today

### Use Me  ?

New searches

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

# How to study this subject

71. Program a structure which stores information about hotels which stores information about name,
grade, room change, no of rooms.
a) a) Print the hotels of given grade in order of roomchange.
b) b) Print the hotels with roomchange less than a given change.
#include
#include
main( )
{
struct hotel
{
char name[20];
char city[10];
int rc,nr;
};
struct hotel ht[20],t;
int i,n,j,c;
char gr;
clrscr( );
printf(“enter no. of hotels\n”);
scanf(“%d”,&n);
for(i=0;i
{
printf(“enter name of hotel \n”);
scanf(“%s”,&ht[i].name);
printf(“enter name of city \n”);
scanf(“%s”,&ht[i].city);
printf(“enter room charge \n”);
scanf(“%d”,&ht[i].rc);
printf(“enter no of rooms \n”);
scanf(“%d”,&ht[i].nr);
}
for(i=0;i
for(j=0;j
{
t=ht[j];
ht[j]=ht[j+i];
ht[j+1]=t;
} 33
printf(“enter a grade to print the hotels \n”);
gr=getche();
clrscr();
printf(“hotel name city grade roomcharge no of room”);
for(i=0;i
getch();
printf(“enter a room charge to print hotels less than given charge \n”);
scanf(“%d”,&c);
printf(“hotel name city grade roomcharge no of rooms”);
for(i=0;i
if(c<=ht[i].rc)
}
72. Program which does the below process after reading on odd no of integer.
a) a) Print them in given order.
b) b) Replace second elements by product of first and last element
c) c) Replace middle value by average of all elements.
d) d) Replace all ?ve no’s by zero’s.
#include
#include
main( )
{
int a[10],i,n,sum=0;
clrscr( );
printf(“enter the array sixe “);
scanf(“%d”,&n);
printf(“enter the elements”);
for(i=0;i
{
scanf(“%d”,&a[i]);
sum=sum+a[i];
}
printf(“The given arrays is: “);
for(i=0;i
printf(“%d”,a[i]);
a[2]=a[1]*a[n-1];
printf(“\n the given areay after replacing 2nd element is”);
for(i=0;i
printf(“%d”,a[i]);
a[(1+n/2)]=sum/n;
printf(“\n the given array after replacing middle element by average of all”);
for(i=0;i
if(a[i]<0)
a[i]=0;
printf(“\n given array after replacing ?ve values by zero”);
for(i=0;i
printf(“%d”,a[i]);
printf(“\n”);
getch();
} 34
73. Program to sort the entered elements using selection sort technique.
#include
#include
main( )
{
int a[100],i,n,j,t,min,pos;
clrscr();
printf(“enter the array size”);
scanf(“%d”,&n);
printf(“enter the elements”);
for(i=0;i
scanf(“%d”,&a[i]);
for(i=0;i
{
min=a[i];
pos=i;
for(j=0;j
if(min>a[j])
{
min=j;
pos=j;
}
t=a[i];
a[i]=a[pos];
a[pos]=t;
}
printf(“the sorted elements are”);
for(i=0;i
printf(“%2d”,a[i]);
getch( );
}
74. Program to find whether a number is divisible by ‘11’ or not without actual division.
#include
#include
#include
main( )
{
int a,b,n,evensum=0,oddsum=0,div;
clrscr( );
printf(“enter a number”);
scanf(“%d”,&n);
a=n;
b=n/10;
while(a>0)
{
oddsum=oddsum+(a%10);
a=a/10;
}
while(b>0) 35
{
evensum=evensum+(b%10);
b=b/10;
}
div=abs(evensum-oddsum);
if(div%11==0)
printf(“The number is divisible by 11”);
else
printf(“The number is not divisible by 11”);
getch();
}
75. Program to find maximum and minimum of entered ’n’ number using arrays.
#include
#include
main( )
{
int i,n,a[10],min,max;
clrscr( );
printf(“ enter how many number”);
scanf(“%d”,&n);
printf(“enter the elements”);
for(i=0;i
scanf(”%d”,&a[i]);
min=a[0];
for(i=0;i
if(min>a[i])
min=a[i];
printf(“minimum=%d”,min);
max=0;
for(i=0;i
if(max
max=a[i];
printf(“\n maximum=%d”,max);
getch( );
}
76. Program to print the following series until there sum exceeds 2.6 term value exceeds 1.5
x+x2/2!+x3/3!+------------.
#include
#include
main( )
{
float x,sum=0,prod=1;
int i;
clrscr( );
printf(“enter x value”);
scanf(“%f’,&x);
i=1;
while((sum<2.6)&&(prod<=1.5))
{
prod=prod*(x/i); 36
if(prod<=1.5)
sum=sum+prod;
if(sum>2.6)
{
sum=sum-prod;
break;
}
printf(“sum=;%f’,sum);
i++;
}
getch( );
}
77. Program to print a frequency distribution table for a class of 20-students in the following format.
The marks range form 1-25.
class intertval frequency
1-5 1-5 -
6-10 6-10 -
11-15 11-15 -
16-20 16-20 -
21-25 21-25 -
#include
#include
main( )
{
int a[20],i,n1=0,n2=0,n3=0,n4=0,n5=0;
clrscr();
printf(“enter the any 20 no of range(1-25));
for(i=1;i<=20;i++)
scanf(“%d”,&a[i]);
for(i=1;i<=20;i++)
if((a[i]>=1)&&(a[i]<6))
n1++;
else
if((a[i]>5)&&(a[i]<11))
n2++;
else
if((a[i]>10)&&(a[i]<16))
n3++;
else
if((a[i]>15)&&(a[i]<21))
n4++;
else
if((a[i]>20)&&(a[i]<26))
n5++;
printf(“class interval frequency”);
printf(“\n 1-5 %d”,n1);
printf(“\n 6-10 %d”,n2);
printf(“\n 11-15 %d”,n3);
printf(“\n 16-20 %d”,n4);
printf(“\n 21-25 %d”,n5);
getch();
} 37
78. Program to accept values into an array and print array in reverse and original format by using three
different functions.
#include
#include
void print_array(int y[]);
void rev_array(int z[]);
main()
{
int a[5];
clrscr();
printf_array(a);
rev_array(a);
getch( );
}
{
int i;
for(i=0;i<=4;i++)
{
printf(“enter values for a[%d]:”,i);
scanf(“%d”,&x[i]);
}
}
void print_array(int y[])
{
int i;
for(i=0;i<=4;i++)
printf(“%d”,y[i]);
}
void rev_array(int z[])
{
int i;
for(i=4;i>=0;i--)
printf(“\n%d”,z[i]);
}
79. Program to accept values into single dimensional array and print the array in reverse by using
pointers.
#include
#include
main( )
{
int a[5],*b,i;
clrscr( );
b=&a[0];
for(i=0;i<=4;i++)
{ 38
printf(“enter a value for a[%d];”.i);
scanf(“%d”,b);
b++;
}
b=&a[4];
for(i=0;i<=4;i++)
{
printf(“\n%d”,*b);
b-- ;
}
getch( );
}
80. Program to read a string and print the number of characters in each word of the string.
#include
#include
#include
main( )
{
char s[100];
int i,l,nc=0;
clrscr( );
printf(“enter the sting”);
gets(s);
l=strlen(s);
for(i=0;i
{
if(s[i]!=’ ‘)
{
nc=0;
while(s[i]!=’ ‘)
{
nc++;
printf(“%c”,s[i]);
i++;
if(s[i]=’\0’)
break;
}
printf(“\t\t %d”,nc);
printf(“\n”);
}
}
getch();
}