Académique Documents
Professionnel Documents
Culture Documents
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); }
{
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] = revstr[strlen(revstr)-i-1]; revstr[strlen(revstr)-i-1] = c; }
return(0); }
-Write a program to display Fibonacci series upto 70? int main() { int fibonacci(int n); int i; printf("Fibonacci Series upto 70 is :"); for (i=1; i<11; i++)
{
printf ("%d ", fibonacci(i)); } printf("\n"); return(0); }
int fibonacci(int n)
{ if (n == 1 n == 2) { return 1; } else
-Write a program to count number of words from a given sentence? int main() { char sentence[100]; int i, count = 0; printf("Enter a Sentence : \n"); gets(sentence); for (i=0; i {
if (isspace(sentence[i]))
{ count++; } } printf("Number of words in the sentence = %d", ++count); return(0);
int a, b; int temp; printf("Enter value of a & b = "); scanf("%d %d", &a, &b); temp = a; a = b; b = temp; printf("\nValues of after interchanging a & b\n"); printf("a = %d b = %d\n\n", a, b);
return(0);