C Programming Code Examples
C > For Loops and While Loops Code Examples
For Loop in C. First initialization happens and the counter variable gets initialized. Second step the condition is checked, where counter variable is tested for the given condition, if...
C Program to input a number from user and check whether given number is Armstrong number or not. Armstrong number is n-digit number that is equal to the sum of the nth...
C program input number and check number is Palindrome or not using Loop. Palindrome number is such number which when reversed is equal to the original number. 121, 12321,...
Program input a number and check whether the number is Perfect number or not. Perfect number is a positive integer which is equal to the sum of its proper positive divisors. So 6 is
Prime numbers are positive integers greater than 1 that is only divisible by 1 and self. For example: 2, 3, 5, 7, 11 etc... C program input number and check whether the number is...
How to check Strong Numbers using loop in C. What is Strong number? Strong number is a special number whose sum of factorial of digits is equal to the original number. 145 is
Program code input binary number from user & convert binary number to decimal number system. The Binary Number system is a base 2 number system and uses only 2 symbols to
C Program to input binary number from user and convert to hexadecimal number system. Binary Number System is a base 2 number system. Binary number system use only two
Program input binary number and convert to octal number system. To make things simple and sound, I have divided the logic in 2 easy steps. Group all binary bits to 3 digits starting
C Program Code input Decimal number from user and convert to binary number system. Decimal number system is a base 10 number system. Decimal number system uses only 10
C program input decimal number and convert to Hexadecimal number system. The Decimal number system is a base 10 number system. Decimal number system uses 10 symbols to...
C Program Code input decimal number and convert to octal number system. Decimal number system is a base 10 number system. Decimal number system uses 10 symbols to
Hexadecimal to Binary conversion is divided in 3 steps. Extract each hex digits separately. Find the Binary of each extracted Hex digit. Store the binary equivalent of extracted hex
C program to input hexadecimal number and convert it to Decimal number. Hexadecimal number system is a base 16 number system. It uses 16 symbols to represent all number i.e.
There is not any Easy and Direct conversion algorithm from hexadecimal to octal number. Convert the Hex number to Binary. Group the converted binary in groups of 3 bits. Write the
C program to input Octal number from user and convert to Binary number system. How to convert from Octal Number System to Binary number system in C. Octal number...
Program to input Octal number and convert to Decimal number. Octal number system is a base 8 number system. Octal number system uses 8 symbols to represent all its numbers...
C program to input octal number from user and convert to hexadecimal number system. Octal Number System is a base 8 number system. It uses 8 symbols to represent all its
Logic to find frequency of digits in a number. Input a number. Store it in some variable say j. Declare and initialize an array of size 10 to store frequency of each digit. Why declare...
C language program to input a number from user and count number of digits in the given integer using loop. First logic is the easiest and is the common to think. It uses loop to
C program input amount and print minimum number of notes (Rs. 500, 100, 50, 20, 10, 5, 2, 1) required for the amount. There any many optimal algorithms to solve given problem.
C program to input a number from user and find all factors of the given number using for loop. Factor of any number is whole number which exactly divides the number into whole
The Armstrong Number is a n-digit number that is equal to the sum of nth power of its digits. 407 = 4^3 + 0^3 + 7^3 = 407 is. Input upper limit to print Armstrong number from
Program to input a number and calculate its factorial using for loop. Factorial of a number n is product of all positive integers less than or equal to n. It is denoted as n!. ex. 5! = 120
C program to input a number from user and find first and last digit of number using loop. Before I explain logic to find first digit, let us first learn to find last digit of a number. Find
Program code input two numbers from user and find the HCF using for loop. HCF (Highest Common Factor) is the greatest number that divides exactly two or more numbers. HCF is
C program code input two numbers and find LCM (Lowest Common Multiple) using loop. Input two numbers from user. Store them in some variable say j1 and j2. Find maximum...
C program to input binary number from user and find ones complement of binary number using loop. What is Ones complement? Ones complement of a binary number is defined as
C program find Perfect numbers between 1 to n. Input Upper Limit to find Perfect numbers. Store it in a variable say end. Run a loop from 1 to end, increment 1 in each iteration. The...
C program to find power of a number using for loop. Input base and exponents from user. Store it in two variables say base and expo. Declare & initialize another variable to store
Factors of a number that are prime numbers are called as "Prime Factors" of that number. For example: 2 and 5 are the prime factors of 10. Logic to check prime factors of a number.
C program code input a number and calculate product of its digits. I have divided the logic to calculate product of digits in three steps. Extract last digit of the number. Multiply the
C program code to input a number from user and find reverse of the given number using for loop. Input number to find reverse. Store it in some variable say j. Declare & initialize...
Logic to find sum of digits of a given number in C programming. The main idea to find sum of digits can be divided in three steps. Extract last digit of the given number. Add extracted
C Program to input upper limit to find sum of even number. Store it in some variable say N. Initialize another variable to store sum with 0 say sum = 0. To find sum of even numbers we
C program to input a number and find sum of first & last digit of the number using for loop. Input a number from user and store it in some variable say j. Find last digit of given number
Program find the sum of all natural numbers between 1 to n. Input upper limit to find sum of natural numbers. Store it in some variable say N. Initialize another variable to store sum
C program find sum of all odd numbers from 1 to n using for loop. Input upper limit to find sum of odd numbers from user. Store it in a variable say N and initialize other variable to
C program to find sum of all prime numbers between 1 to n using for loop. Prime numbers are positive integers greater than 1 that has only two divisors 1 and the number itself. For
C Program to which calculates the number of integers divisible by 5 in the given range. This C program takes the range as input and finds the number of integers divisible by 5 in range.
C program code to input binary number from user and find twos complement of the binary number. Twos complement of N-bit number is defined as the complement with respect to
Page 1 Page 2 Page 3