Saturday 7 July 2018

intresting Programs

1) Print text within double quotes (” “).



// CPP program to print double quotes
#include
 
int main()
{
   std::cout << "\"Penchala\"";
   return 0;
}



2) To check if two numbers are equal without using arithmetic operators or comparison operators.

 int x = 10;
   int y = 10;
   if ( !(x ^ y) )
      printf(" x is equal to y ");
   else
      printf(" x is not equal to y ");
   return 0;
3) find Maximum and minimum of two numbers without using any loop or condition.
 int a = 15, b = 20;
   printf("max = %d\n", ((a + b) + abs(a - b)) / 2);
   printf("min = %d", ((a + b) - abs(a - b)) / 2);

4)
// C program to find if machine is little
// endian or big endian.
#include
int main()
{
   unsigned int n = 1;
   char *c = (char*)&n;
   if (*c)   
       printf("LITTLE ENDIAN");
   else
       printf("BIG ENDIAN");
   return 0;
}





No comments:

Post a Comment