You Are The Visitor Number

Sunday, May 18, 2008

/* Program to test whether given string is a palindrome */

This is an another Program to show check Palindrome , But this check Palindrome of a string instead of a number..

A string is any array of Characters. For example word "Arora " is a palindrome…..

/*"Author: Mitochondria Technologies Inc. "*/

/* Program to test whether given string is a palindrome */


 

#include<stdio.h>

#include<conio.h>

#include<string.h>

enum boolean{false,true};

enum boolean string_palindrome(char string[]);

void main()

{

char string [40];

clrscr();

printf("enter a string:");

scanf("%s",&string);

if (string_palindrome(string))

printf("string is a palindrome\n");

else

printf("string is not a palindrome\n");

getch();

}

enum boolean string_palindrome(char string[])

{

int left,right,len=strlen(string);

enum boolean matched=true;

if(len==0)

return true;

left=0;

right=len-1;

while(left<right && matched)

{

if (string[left]!=string[right])

matched=false;

else

{

left++;

right--;

}

}

return matched;

}

 

Saturday, May 17, 2008

/* Program to add two matrices */

Here is the program The student find most tough!!! Why?? Because it so lenghty. Again tough?? because it uses so many for loops many times first for filling of first matrices showing filled matrices & also one loop shows output matrix…

If you understand this program you can do anything in matrix algebra But you should also know mathematics!!! J
J
J
J


 

This program also helps you to understand the concept of arrays.. Now you try substraction by your own skills… till then wait for multiplication of matrices one>>>>


 

/* Program to add two matrices */

/*"Author: Mitochondria Technologies Inc.(Regd.)"*/


 

#include<stdio.h>

#include<conio.h>

void main()

{

int i,j,m,n,a[5][5],b[5][5],c[5][5];

clrscr();

printf("enter the no. of rows n columns:");

scanf("%d %d",&n,&m);

printf("enter matrix A:");

for(i=0;i<n;i++)

{

for(j=0;j<m;j++)

{

scanf("%d",&a[i][j]);

}

}

printf("\nMatrix A is inserted.");

printf("\n");

for(i=0;i<n;i++)

{

for(j=0;j<m;j++)

{

printf("%d",a[i][j]);

}

printf("\n");

}

printf("\nEnter matrix B:");

for(i=0;i<n;i++)

{

for(j=0;j<m;j++)

{

scanf("%d",&b[i][j]);

}

}

printf("\nMatrix B is inserted.");

printf("\n");

for(i=0;i<n;i++)

{

for(j=0;j<m;j++)

{

printf("%d",b[i][j]);

}

printf("\n");

}

printf("The Addition of two matrices is:\n");

for(i=0;i<n;i++)

{

for(j=0;j<m;j++)

{

c[i][j]=a[i][j]+b[i][j];

}

}

for(i=0;i<m;i++)

{

for(j=0;j<n;j++)

{

printf("%d\t",c[i][j]);

}

printf("\n");

}

getch();

}