Posts

Palindrome number

Q) Write a program to tell a given number is palindrome or not??(CODDED BY PRATIM MUKHERJEE) Ans)          #include <stdio.h> int main() {     int n, num, rev = 0;     /* Input a number from user */     printf("Enter any number to check palindrome: ");     scanf("%d", &n);     /* Copy original value to 'num' to 'n'*/     num = n;      /* Find reverse of n and store in rev */     while(n != 0)     {         rev = (rev * 10) + (n % 10);         n  /= 10;     }     /* Check if reverse is equal to 'num' or not */     if(rev == num)     {         printf("%d is palindrome.", num);     }     else     {         printf("%d is not palindrome.", num);     }     ret...

Fabonacci series

Q.Write a program to print Fibonacci series of given numbers.(CODDED BY PRATIM MUKHERJEE) Ans)          #include <stdio.h> int main() {   int n, first = 0, second = 1, next, c;   printf("Enter the number of terms\n");   scanf("%d", &n);   printf("First %d terms of Fibonacci series are:\n", n);   for (c = 0; c < n; c++)   {     if (c <= 1)       next = c;     else     {       next = first + second;       first = second;       second = next;     }     printf("%d\n", next);   }   return 0; } Input:6 Output:0 1 1 2 3 5