(C programming Example for Beginners) C Program to Reverse a Number In this example, you will learn to reverse the number entered by the user. Reverse an Integer #include <stdio.h> int main(){ int n, rev = 0, remainder; printf(“Enter an integer: “); scanf(“%d”, &n); while (n != 0) { remainder = n % 10; rev …
(C programming Example for Beginners) C Program to Count Number of Digits in an Integer In this example, you will learn to count the number of digits in an integer entered by the user. This program takes an integer from the user and calculates the number of digits. For example: If the user enters 2319, …
(C programming Example for Beginners) C Program to Find LCM of two Numbers In this example, you will learn to calculate the LCM (Lowest common multiple) of two numbers entered by the user. The LCM of two integers n1 and n2 is the smallest positive integer that is perfectly divisible by both n1 and n2 (without a remainder). For example, the LCM of …
(C programming Example for Beginners) C Program to Find GCD of two Numbers Examples on different ways to calculate GCD of two integers (for both positive and negative integers) using loops and decision making statements. The HCF or GCD of two integers is the largest integer that can exactly divide both numbers (without a remainder). …
(C programming Example for Beginners) C Program to Find Factorial of a Number In this example, you will learn to calculate the factorial of a number entered by the user. The factorial of a positive number n is given by: factorial of n (n!)= 1 * 2 * 3 * 4….n The factorial of a negative number …
(C programming Example for Beginners) C Program to Calculate the Sum of Natural Numbers In this example, you will learn to calculate the sum of natural numbers entered by the user. The positive numbers 1, 2, 3… are known as natural numbers. The sum of natural numbers up to 10 is: sum = 1 + 2 + …
(C programming Example for Beginners) C Program to Check Whether a Character is an Alphabet or not In this example, you will learn to check whether a character entered by the user is an alphabet or not. In C programming, a character variable holds an ASCII value (an integer number between 0 and 127) rather …
(C programming Example for Beginners) C Program to Check Whether a Number is Positive or Negative In this example, you will learn to check whether a number (entered by the user) is negative or positive. This program takes a number from the user and checks whether that number is either positive or negative or zero. Check Positive or Negative Using …
(C programming Example for Beginners) C Program to Find the Largest Number Among Three Numbers In this example, you will learn to find the largest number among the three numbers entered by the user. Example 1: Using if Statement #include <stdio.h> int main(){ double n1, n2, n3; printf(“Enter three different numbers: “); scanf(“%lf %lf %lf”, …
(C programming Example for Beginners) C Program to Check Whether a Character is a Vowel or Consonant In this example, you will learn to check whether an alphabet entered by the user is a vowel or a consonant. The five letters A, E, I, O and U are called vowels. All other alphabets except these 5 vowels are called consonants. This …