Here we’ll see how to write C program to find a digit of a specified position in a number. We’ll start the numbering from right side. The right most position would be 0. For example, 0-th digit of 2341238 is 8 and 3-rd digit is 1. Logic to Find N-th Digit of a Number Do … Continue reading “C Program to Get a Digit of Any Position of a Number”
Category: C
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”
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?”