C-Programs
Essay by Kill009 • September 13, 2011 • Study Guide • 357 Words (2 Pages) • 1,632 Views
#include<stdio.h>
#include<conio.h>
void main()
{
int n,s=0,m;
clrscr();
printf("enter any no");
scanf("%d",&n);
m=n;
while(n>0)
{
r=n%10;
s=s*10+r;
n=n/10;
}
if(m==n)
printf("the no is palindrome");
else
printf("no is not palindrome");
getch();
}
Write a C Program to join two strings? (eg. Input "hari" &"123"
output="hari123") ?
int main()
{
char str1[10], str2[10];
printf("Enter the first string = ");
scanf("%s", str1);
printf("Enter the second string = ");
scanf("%s", str2);
printf("Concatenation of two strings = %s", strcat(str1, str2));
return(0);
}
-Write a program to find highest of five numbers entered by user?
int main()
{
int i, a[5], max;
printf("Enter the 5 numbers = ");
for (i=0; i<5; i++)
scanf("%d", &a[i]);
max = a[0];
for (i=1; i<5; i++)
{
if (max < a[i])
{
max = a[i];
}
}
printf("nMaximum of 5 numbers = %d", max);
return(0);
}
-Enter a string & write a program to obtain reverse of string. Determine whether
the original and reverse strings are equal?
int main()
{
char orgstr[10], revstr[10];
int i;
printf("Enter a string = ");
scanf("%s", str);
strcpy(revstr, orgstr);
for (i=0; i {
char c = revstr[i];
revstr[i]
...
...