Posts

Showing posts from June, 2021

Bitwise operator in c program. Hacker rank problem.

  #include   < stdio.h > #include <string.h> #include <math.h> #include <stdlib.h> //Complete the following function. void calculate_the_maximum(int n, int k) {     int maxand =0;     int maxor =0;     int maxxor =0;     for(int i=1; i<=n; i++){         for (int j= i+1; j<=n; j++){             if(((i & j)> maxand) && ((i&j)<k)){                 maxand= i&j;             }               ...

For Loop Problem Solution in Hacker rank

  int   main ()   { int   a , b ;      int   n = 0 ;      string   intMap [ 9 ]=   { "one" ,   "two" , "three" , "four" , "five" , "six" , "seven" , "eight" , "nine" };           cin >> a >> b ;           if   (( a <= 9 )&&( b <= 9 )){           for ( n = a ; n <= b ; n ++){              cout   <<   intMap [ n - 1 ]<< endl ;            }   }      else   if   (( a <= 9 )&&( b > 9 )){               for ( n = a ; n <= 9 ; n ++){              cout << intMap [ n ...