## C Program to find whether a no is power of two

Given a positive integer, write a function to find if it is a power of two or not. Examples : Input : n = 4… Read More »

## Program to find whether a no is power of two

Given a positive integer, write a function to find if it is a power of two or not. Examples : Input : n = 4… Read More »

## Efficient way to multiply with 7

We can multiply a number by 7 using bitwise operator. First left shift the number by 3 bits (you will get 8n) then subtract the… Read More »

## Write a program to reverse digits of a number

Write a program to reverse digits of an integer. Examples : Input : num = 12345 Output : 54321 Input : num = 876 Output… Read More »

## Program to find parity

Parity: Parity of a number refers to whether it contains an odd or even number of 1-bits. The number has “odd parity”, if it contains… Read More »

## Write an Efficient Method to Check if a Number is Multiple of 3

The very first solution that comes to our mind is the one that we learned in school. If sum of digits in a number is… Read More »

## Majority Element

Write a function which takes an array and prints the majority element (if it exists), otherwise prints “No Majority Element”. A majority element in an… Read More »

## Given an array A[] and a number x, check for pair in A[] with sum as x

Write a program that, given an array A[] of n numbers and another number x, determines whether or not there exist two elements in S… Read More »

## Smallest power of 2 greater than or equal to n

Write a function that, for a given no n, finds a number p which is greater than or equal to n and is a smallest… Read More »

## Write a one line C function to round floating point numbers

Algorithm: roundNo(num) 1. If num is positive then add 0.5. 2. Else subtract 0.5. 3. Type cast the result to int and return. Example: num… Read More »

## Write a C program to print “Geeks for Geeks” without using a semicolon

First of all we have to understand how printf() function works. Prototype of printf() function is: int printf( const char *format , …) Parameter format:… Read More »

## Output of the Program | Pointer to a Constant or Constant Pointer?

Predict the output of the below program. filter_none edit close play_arrow link brightness_4 code int main() {     int x = 5;     int * const ptr… Read More »

## Output of the Program | Use Macros Carefully!

Predict the output of the below program filter_none edit close play_arrow link brightness_4 code #define square(x) x*x int main() {   int x;   x = 36/square(6);… Read More »

## Output of the program | Dereference, Reference, Dereference, Reference….

Predict the output of below program filter_none edit close play_arrow link brightness_4 code #include<stdio.h> int main() {  char *ptr = “geeksforgeeks”;  printf(“%c\n”, *&*&*ptr);      getchar();… Read More »

## A Program to check if strings are rotations of each other or not

Given a string s1 and a string s2, write a snippet to say whether s2 is a rotation of s1? (eg given s1 = ABCD… Read More »