The Eduladder is a community of students, teachers, and programmers just interested to make you pass any exams. So we help you to solve your academic and programming questions fast.
In eduladder you can Ask,Answer,Listen,Earn and Download Questions and Question papers.
Watch related videos of your favorite subject.
Connect with students from different parts of the world.
Apply or Post Jobs, Courses ,Internships and Volunteering opportunity. For FREE
See Our team
Wondering how we keep quality?
Got unsolved questions? Ask Questions


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

GE2115-Computer practice Laboratory Part-5

How to study this subject


41. Program to accept a string and check the given string is palindrome or not .
# include
# include
main( )
{
int i,lim,c,check=1;
char word[80];
clrscr( );
printf(“ enter a string”);
for(i=0;i<80 && ((word [i]= getchar())!=’\n’);i++);
 lim=i-1;
c=lim/2;
for(i=0;i<=0;i++,lim--)
if(word[i]!= word[lim])
 {
 check=0;
 break;
}
 if(check= =1)
printf(“the given string is palindrome “);
else
printf(“ not palindrome”);
getch( );
} 17
42.Program to accept values into 3 dimensional array and print .
# include
# include
main( )
{
int a[3][3],i,j;
clrscr( );
for(i=0;i<=2;i++)
for(j=0;j<=2;j++)
{
 printf(“ enter the value for a[%d][%d] :”,i,j);
scanf(“%d”,&a[i][j]);
}
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
 printf(“ %d:”,a[i][j]);
printf(‘\n”);
}
getch( );
}
43. Program to print upper triangle .
# include
# include
main( )
{
int a[4][4],i,j,c;
clrscr( );
printf(“ enter which no u want”);
scanf(“%d”,&c);
for(i=0;i<4;i++)
for(j=0;j<4;j++)
 if(i
a[i][j]=c;
else
a[i][j]=0;
for(i=0;i<4;i++)
for(j=0;j<4;j++)
{
printf(“ %d:”,a[i][j]);
printf(‘\n”);
}
getch( );
} 18
44. Program to accept two 3 dimensional array and store addition of those into arrays into the third
array .
# include
# include
main( )
{
int a[3][3],b[3][3],c[3][3],i,j;
clrscr( );
for(i=0;i<3;i++)
for(j=0;j<3;j++)
 {
 printf(“enter the two values for a[%d][%d] & b[%d][%d]”, i,j,i,j);
scanf(“%d%d”,&a[i][j],&b[i][j]);
}
 for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
 c[i][j]=a[i][j]+b[i][j];
printf(“%d”,c[i][j]);
}
printf(“\n”);
}
getch( );
}
45. Program to accept a string and find the length of the given string by using functions
# include
# include
int getline(char str[]);
main( )
{
char str[80];
int length;
clrscr( );
printf(“ enter a string”);
length=getline(str);
printf(“length of the given string is %d”,length);
getch ( );
}
int getline(char str[])
{
int i;
for(i=0;i<80&&((str[i]=getchar( ))!=’\n’); i++);
if(str[i]= =’\n’)
str[i]=’\0’;
return i;
} 19
46. Program to count the number of words, characters, alphabets, vowels, consonants and digit in a line
of text.
#include
#include
main( )
{
int noa=0,nob=0,noc=0,nov=0,now=0,noch=0,l,I;
char ch,s[100];
clrscr( );
printf(“enter 2 lines of text”);
gets(s);
l=strlen(s);
for(i=0;i<1;i++)
{
switch(s[i])
{
case ‘a’:
case ‘e’:
case ‘i’:
case ‘o’:
case ‘u’:
case ‘A’:
case ‘E’:
case ‘I’:
case ‘O’:
case ‘U’:
nov++;
break;
}
if(isalpha(s[i]))
noa++;
if(isdigit(s[i]))
nod++;
if(noa[i]==’ ‘) && (noa[i+1]!=’ ‘)
now++;
}
noch=l-nob;
noc=noa-nov;
printf(total no of words %d”,now);
printf(total no of characters(without blanks)%d”,noch);
printf(total no of characters(including blanks)%d”,l);
printf(total no of alphabets %d”,noa);
printf(total no of vowels %d”,nov);
printf(total no of characters %d”,noc);
printf(total no of digits %d”,nod);
getch( );
} 20
47. Program to accept two string and compare the strings are equal or not
# include
# include
int getline (char line[ ], int lim );
int strc(char str1[ ], char str2[] );
main( )
{
char str1[80],str2[80];
int comp;
clrscr( );
printf(“enter first string:”);
getline(str1,80);
printf(“enter second string:”);
getline(str2,80);
comp=strc(str1,str2);
if(comp>0)
printf(“first string is bigger”);
else
if(comp==0)
printf(“both the strings are equal”);
getch( );
}
int getline(char str[], int lin)
{
 int i;
for(i=0;i
if(str[i]=’\0’)
return i;
}
int strc(char str1[],char str2[])
{
 int i;
for(i=0;str1[i];i++)
if(str1[i]!=str2[i])
return str1[i]-str2[i];
return str1[i]-str2[i];
}
48. Program to sort the entered numbers using bubble sort.
# include
# include
main( )
{
int a[100],i,j,n,t;
clrscr( );
printf(“enter the array size”);
scanf(“%d”,&n);
for(i=1;i
scanf(“%d”,&a[i]);
for(i=1;i<=n;i++)
for(j=i+1;j
if(a[i]>a[j])
{
t=a[i]
a[i]=a[j];
a[j]=t;
}
printf(“the sorted elements are “);
for(i=1;i<=n;i++)
print(“%d”,a[i]);
getch( );
}
49. Program to read date,month, year and print the next day’s date,month,year.
# include
# include
main( )
{
 int month[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int d,m,y,nd,nm,ny,ndays;
clrscr( );
printf(“enter the date,month,year”);
scanf(“%d%d%d”,&d,&m,&y);
ndays=month[m-1];
if(m==2)
{
if(y%100==0)
{
if(y%400==0)
ndays=29;
}
else
if(y%4==0)
ndays=29;
}
nd=nd+1;
nm=m;
ny=y;
if(nd>ndays)
{
nd=1;
nm++;
}
if(nm>12)
{
nm=1;
ny++;
}
printf(“Given date is %d:%d:%d\n”,d,m,y);
printf(“next days date is %d:%d:%d”,nd,nm,ny);
getch( );
} 22
50. Program to interchange two values using pointers.
# include
# include
void interchange(int *x,int *y);
main( )
{
int a,b;
clrscr( );
printf(“enter values of a and b”);
scanf(“%d%d”,&a,&b);
interchange(&a,&b);
}
void interchange(x,y)
int *x,*y;
{
int t;
t=*x;
*x=*y;
*y=t;
printf(“%d=x, %d=y”,*x,*y);
getch( );
}

Add contents here


Official Notes


Add contents here


Notes from other sources


Add contents here


Model question papers


Add contents here


Previous year question papers


Add contents here


Useful links


Add contents here


Editors




You might like this video:Watch more here

Watch more videos from this user Here

Learn how to upload a video and start earning here