Write a C program to print rhombus star pattern of N rows using for loop. How to print rhombus or parallelogram star pattern using for loop in C programming. Logic to print rhombus or parallelogram star pattern series in C program.
C program to print square or rectangle star pattern
Write a C program to print square star(*) pattern series of N rows. C program to print rectangle star(*) pattern in C of N rows and M columns. Logic to print square or rectangle star pattern of N rows in C programming.
C program to print all even numbers between 1 to n using while loop
Write a C program to enter any number from user and print all even numbers between 1 to n using while loop. C program to display even number in a given range using while loop. How to generate even numbers from 1 to n using while loop in C programming.
Example
Input
Input value of n: 10
Output
Even numbers between 1 to 10: 2, 4, 6, 8, 10
C program to print all natural numbers from 1 to n using while loop
Write a C program to enter any number from user and print all natural numbers from 1 to n using while loop. How to print all natural numbers from 1 to n using while loop in C programming.
Example
Input
Input upper limit to print natural numbers: 10
Output
Natural numbers from 1 to 10: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
C program to create calculator using switch case and functions
Write a C program to create menu driven calculator that performs basic arithmetic operations (add, subtract, multiply and divide) using switch case and functions. The calculator should input two numbers and an operator from user. It should perform operation according to the operator entered and must take input in given format.
<number 1> <operator> <number 2>
Input
5.2 - 3
Output
2.2
C program to find sum of prime numbers between 1 to n
Write a C program to find sum of all prime numbers between 1 to n using for loop. C program to generate sum of all primes between a given range. Logic to find sum of prime numbers in a given range.
Example
Input
Input upper limit: 10
Output
Sum of prime numbers between 1-10: 17
C program to find LCM of two numbers
Write a C program to input two numbers from user and find LCM (Lowest Common Multiple) using loop. How to find LCM of two given numbers in C programming. Logic to find LCM of two number in C program.
Example
Input
Input number1: 12 Input number2: 30
Output
LCM = 60
C program to find HCF (GCD) of two numbers
Write a C program input two numbers from user and find the HCF using for loop. How to find GCD of two given numbers using loops in C programming. Logic to find HCF of two number in C programming. Example Input Input first number: 12 Input second number: 30 Output HCF of 12 and 30: … Read more
C program to find prime factors of a number
Write a C program to input a number from user and find Prime factors of the given number using loop. C program to list all prime factors of a given number. Logic to find prime factors of a number in C programming.
Example
Input
Input any number: 10
Output
Prime factors of 10: 2, 5
Loop programming exercises and solutions in C
In programming, there exists situations when you need to repeat single or a group of statements till some condition is met. Such as – read all files of a directory, send mail to all employees one after another etc. These task in C programming is handled by looping statements.