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.
Loop
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 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.
C program to print strong numbers between 1 to n
Write a C program to print Strong numbers between 1 to n. C program to print all strong numbers between a given range. Logic to print strong numbers in a given range in C program.
Example
Input
Input upper limit: 1000
Output
Strong numbers between 1-1000: 1, 2, 145
C program to check whether a number is Strong number or not
Write a C program to input number from user and check whether number is Strong number or not. How to check strong numbers using loop in C programming. Logic to check strong number in C programming.
Example
Input
Input number: 145
Output
145 is STRONG NUMBER