C program to check whether a given string is palindrome or not

Write a C program to read a string and check whether it is a palindrome or not (without using library functions). Output the given string along with suitable message.Palindrome is a word, sentence, group of characters, or number, that remains same, when reversed.
For example: GADAG, 9009… Read more about C Programming Language .

/***********************************************************
* You can use all the programs on  www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
* 
*                                  Happy Coding
***********************************************************/

#include <stdio.h>
#include <conio.h>
#include <string.h>

void main()
{
 char string[25], revString[25]={''};
 int  i,length = 0, flag = 0;

 clrscr();

 fflush(stdin);

 printf("Enter a stringn");
 gets(string);

 for (i=0; string[i] != ''; i++) /*keep going through each */
 {                                 /*character of the string */
  length++;                     /*till its end */
 }

 for (i=length-1; i >= 0 ; i--)
 {
  revString[length-i-1] = string[i];
 }

 /*Compare the input string and its reverse. If both are equal
   then the input string is palindrome. Otherwise it is
   not a palindrome */

 for (i=0; i < length ; i++)
 {
  if (revString[i] == string[i])
   flag = 1;
  else
   flag = 0;
 }

 if (flag == 1)
  printf ("%s is a palindromen", string);
 else
  printf("%s is not a palindromen", string);

}   /*End of main()*/
Read more Similar C Programs
Searching in C

C Strings

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C program to find the transpose of a given Matrix.

Write a C program to read A (MxN), find the transpose of a given matrix and output both the input matrix and the transposed matrix.
Transpose of a matrix is the interchanging the rows and columns, If A is matrix of order(i*j), where i is the row and j is the column, then Transpose of A is A(j*i). Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/

*/

#include <stdio.h>
#include <conio.h>

void main()
{
int i,j,M,N;
int A[10][10], B[10][10];

int transpose(int A[][10], int r, int c); /*Function prototype*/

clrscr();

printf("Enter the order of matrix An");
scanf("%d %d", &M, &N);

printf("Enter the elements of matrixn");
for(i=0;i<M;i++)
{
for(j=0;j<N;j++)
{
scanf("%d",&A[i][j]);
}
}

printf("Matrix A isn");
for(i=0;i<M;i++)
{
for(j=0;j<N;j++)
{
printf("%3d",A[i][j]);
}
printf("n");
}

/* Finding Transpose of matrix*/
for(i=0;i<M;i++)
{
for(j=0;j<N;j++)
{
B[i][j] = A[j][i];
}
}

printf("Its Transpose isn");
for(i=0;i<M;i++)
{
for(j=0;j<N;j++)
{
printf("%3d",B[i][j]);
}
printf("n");
}

} /*End of main()*/
Read more Similar C Programs
Matrix Programs
Learn C Programming

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C Program to evaluate the given polynomial P(x)=AnXn + An-1Xn-1 + An-2Xn-2+… +A1X + A0, by reading its coefficents into an array.

Write a C program to evaluate the given polynomial P(x)=AnXn + An-1Xn-1 + An-2Xn-2+… +A1X + A0, by reading its coefficents into an array.A Polynomial is a mathematical expression involving a sum of powers in one or more variables multiplied by coefficients. Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/



#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#define MAXSIZE 10

voidmain()
{
int a[MAXSIZE];
int i, N,power;
float x, polySum;

clrscr();

printf("Enter the order of the polynomialn");
scanf("%d", &N);

printf("Enter the value of xn");
scanf("%f", &x);

/*Read the coefficients into an array*/

printf("Enter %d coefficientsn",N+1);
for (i=0;i <= N;i++)
{
scanf("%d",&a[i]);
}

polySum = a[0];

for (i=1;i<= N;i++)
{
polySum = polySum * x + a[i];
}

power = N;

/*power--;*/

printf("Given polynomial is:n");
for (i=0;i<= N;i++)
{
if (power < 0)
{
break;
}

/* printing proper polynomial function*/
if (a[i] > 0)
printf(" + ");
else if (a[i] < 0)
printf(" - ");
else
printf (" ");
printf("%dx^%d ",abs(a[i]),power--);

}

printf("nSum of the polynomial = %6.2fn",polySum);
}

Array In C Simple C ProgramsYou can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C Program To Find The Sum & Average

Example programs to solve the problems of Arrays in C.
C program to read N integers (zero, +ve and -ve) into an array A and to
a) Find the sum of negative numbers
b) Find the sum of positive numbers and
c) Find the average of all input numbers
Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/

#include <stdio.h>
#include <conio.h>
#define MAXSIZE 10

void main()
{
int array[MAXSIZE];
int i, N, negsum=0, posum=0;
float total=0.0, averg;

clrscr();

printf ("Enter the value of Nn");
scanf("%d", &N);

printf("Enter %d numbers (-ve, +ve and zero)n", N);
for(i=0; i< N ; i++)
{
scanf("%d",&array[i]);
fflush(stdin);
}

printf("Input array elementsn");
for(i=0; i< N ; i++)
{
printf("%+3dn",array[i]);
}

/* Summing begins */
for(i=0; i< N ; i++)
{

if(array[i] < 0)
{
negsum = negsum + array[i];
}
else if(array[i] > 0)
{
posum = posum + array[i];
}
else if( array[i] == 0)
{
;
}
total = total + array[i] ;
}

averg = total / N;
printf("nSum of all negative numbers = %dn",negsum);
printf("Sum of all positive numbers = %dn", posum);
printf("nAverage of all input numbers = %.2fn", averg);

} /*End of main()*/
Read more Similar C Programs
Array In C

Simple C Programs

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C program to find the GCD and LCM of two integers

Write a C program to find the GCD and LCM of two integers output the results along with the given integers. Use Euclids’ algorithm to find the GCD and LCM.
Euclids’ algorithm uses the division algorithm which repeatedly divides starting from the two numbers we want to find the GCD of until we get a remainder of 0. Read more about C Programming Language .

/***********************************************************
* You can use all the programs on  www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
* 
*                                  Happy Coding
***********************************************************/

#include <stdio.h>
#include <conio.h>

void main()
{
 int  num1, num2, gcd, lcm, remainder, numerator, denominator;
 clrscr();

 printf("Enter two numbersn");
 scanf("%d %d", &num1,&num2);

 if (num1 > num2)
 {
  numerator = num1;
  denominator = num2;
 }
 else
 {
  numerator = num2;
  denominator = num1;
 }
 remainder = num1 % num2;
 while(remainder !=0)
 {
  numerator   = denominator;
  denominator = remainder;
  remainder   = numerator % denominator;
 }
 gcd = denominator;
 lcm = num1 * num2 / gcd;
 printf("GCD of %d and %d = %d n", num1,num2,gcd);
 printf("LCM of %d and %d = %d n", num1,num2,lcm);
}  /* End of main() */
Read more Similar C Programs

Data Structures

C Sorting

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C Program to find the number and sum of all integers from 100 to 200 which is divisible by 7

Example programs to solve the problems of Arrays in C.
C program to find the number and sum of all integers from 100to 200 which is divisible by 7. Read more about C Programming Language .

Read more Similar C Programs
Array In C

Simple C Programs

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C Program to read ten integers from the keyboards and print the sum of even and odd numbers.

Example programs to solve the problems of Arrays in C.
C Program to read ten integers from the keyboard and print the sum of even and odd numbers.Read more about C Programming Language .

Read more Similar C Programs
Array In C

Simple C Programs

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C Program to concatenate two strings

C Strings:
Write a function to concatenate two strings, write a program to read three Strings and use the function to concatenate them and print it.
String concatenation is the process of combining two or more strings to a single String. Here, we write the function for string concatenation, and passing the three strings to concatenate. Read more about C Programming Language .

Read more Similar C Programs
Searching in C

C Strings

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C Program to evaluate the following series. f(x)=x-x3/3! + x5/5!-x7/7!…..into given numbers of terms.

C program to evaluate the following series. f(x)=x-x3/3! + x5/5!-x7/7!………………….into given numbers of terms. Series is a ordered set of elements combined together by additional operator. Finite series contains number of defined elements, and infinite series contains infinite elements. Read more about C Programming Language .

Read more Similar C Programs
Searching in C

C Strings

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C Program to accept two integers for a co-ordinate point and determine its Quadrant.

C program to accept two integers for a co-ordinate point and determine its Quadrant. A Cartesian coordinate system specifies each point uniquely in a plane by a pair of numerical coordinates, which are the signed distances from the point to two fixed perpendicular directed lines, measured in the same unit of length.
The left to right (horizontal) direction is commonly called X-Axis.
The up to down (vertical) direction is commonly called Y-axis.
The X and Y axises divide the plane into four regions, called as the quadrant. Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/
#include<stdio.h>
int main()
{
int x,y;
printf("Enter the values for coordinates x and y\n");
scanf("%d%d",&x,&y);
if((x>=0) &&(y>=0))
{
printf("\n The co-ordinate (%d,%d) is in first Quardrant\n",x,y);
}
else if((x<0) &&(y<0))
{
printf("\n The co-ordinate (%d,%d) is in Third Quardrant\n",x,y);
}
else if((x>0) &&(y<0))
{
printf("\n The co-ordinate (%d,%d) is in Fourth Quardrant\n",x,y);
}
else {
printf("\n The co-ordinate (%d,%d) is in Second Quardrant\n",x,y);
}
return 0;
}
/* Author: Sandeepa Nadahalli */
view raw quadrant.c hosted with ❤ by GitHub

Read more Similar C Programs
Searching in C

C Strings

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com