Posts

Programs Collections

 Write a macro to find smallest from two given numbers. #include <iostream> using namespace std; #define MIN(x,y) (x<y?x:y) int main() {     int x = 10, y =12, z = 34;     cout<<"Min ="<<MIN(x,MIN(y,z));     return 0; }
Image
  C Program to Check if a Given String is Palindrome // A function to check if a string str is palindrome void isPalindrome( char str[]) {      // Start from leftmost and rightmost corners of str      int l = 0;      int h = strlen (str) - 1;          // Keep comparing characters while they are same      while (h > l)      {          if (str[l++] != str[h--])          {              printf ( "%s is Not Palindrome" , str);              return ;          }      }      printf ( "%s is palindrome" , str); }     // Driver program to test above function int main() {      isPalindrome( "abba" );      isPalindrome( "abbccbba" );      isPalindrome( "geeks" );      return 0; } Recursive function to check if a string is palindrome // A recursive C++ program to  // check whether a given number // is palindrome or not #include <bits/stdc++.h> using namespace std;     // A recursive function that // check a str[s..e] is // palindro