C Program to Convert Decimal to Binary

We use numbers in our everyday life in decimal form. Decimal numbers have 10 symbols (0, 1, 2, 3, 4, 5, 6, 7, 8 and 9). These ten symbols are used to represent any decimal number. The example of decimal numbers are 897513709, 8790 etc. Decimal numbers are sometimes represented as (897513709)10 or (8790)10. On … Continue reading “C Program to Convert Decimal to Binary”

C Program to Check Whether a Number is Palindrome

Palindrome is a number or sequence of characters which reads same backward and forward. If we reverse a palindrome number, the reversed and original number will be same. The first C program checks whether a number is palindrome by reversing the number. The second program does the same thing without reversing the number. By reversing … Continue reading “C Program to Check Whether a Number is Palindrome”

Swap Two Variables without Using Third Variable

It is very trivial to swap two variables with the help of another one. Here we’ll see how to do the same thing without using the third variable. Solution 1: a=b+a; b=a-b; a=a-b; Explanation: Here the principle is simple, if you have one variable and the summation of two variables you want to swap then … Continue reading “Swap Two Variables without Using Third Variable”

C Program to Check Whether a Number Is Prime

Prime number is a natural number (integer) greater than 1 that doesn’t have any positive divisor other than 1 and itself. Here is the program to check whether a number is prime or not. #include <stdio.h> int CheckPrime(int n) { int i = 0; for(i=2; i<=n/2; ++i) { if(n%i == 0) { return 0; } … Continue reading “C Program to Check Whether a Number Is Prime”

How to Print 1 to 100 without using Loop in C programming?

Probably we all know how to write C program to print 1 to 100 using loop. We can have a quick look of the code snippet. void print_numbers() { int i = 0; for (i = 0; i < 100; i++) { printf(ā€œ %dā€, i+1); } } If we want to use while loop: void … Continue reading “How to Print 1 to 100 without using Loop in C programming?”

5
2
6
2
10
7