40) Sample C Program to accept a string and print the reverse of the given string.
# include <stdio.h>
# include <conio.h>
main( )
{
int i, j;
char name[80];
clrscr( );
printf("Enter a string");
gets(name);
for(i = 0; i < 80 && ((name [i] = getchar()) != '\n'); i++);
if(name[i]= ='\n')
name[i]='\0';
for(j=i;j>=0;j--)
putchar(name[j]);
printf("Is the reverse of given string");
getch( );
}
41) Sample C Program to accept a string and check whether the given string is palindrome or not.
# include <stdio.h>
# include <conio.h>
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("The given string is not palindrome.");
getch( );
}
42) Sample C Program to accept values into 3 dimensional array and print.
# include <stdio.h>
# include <conio.h>
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( );
}
ALSO CHECK THESE C PROGRAMS:
- C Program to count the number of words, characters, alphabets, vowels, consonants and digit in a line of text.
- C Program to accept two string and compare the strings are equal or not.
- C Program to sort the entered numbers using bubble sort.
- C Program To Implement Minimum Spanning Tree Using Functions, Pointers & Structures.
- C Program To Implement 8 Queens Problem Using Arrays, Pointers & Functions.
- C Program To Implement Quick Sort Using Pointers, Functions & Arrays.
...Back To C Program Index.
Comments
Post a Comment
Please share your opinions and suggestions or your experience in the comments section. This way we can all help each other...
Experienced guys can share their resumes at admin@interview-made-easy.com