C Exercises: Print all numbers between 1 to 100 which divided by a specified number and the remainder will be 3
C Basic Declarations and Expressions: Exercise-32 with Solution
Write a C program to print all numbers between 1 and 100 which are divided by a specified number and the remainder will be 3.
Pictorial Presentation:

C Code:
#include <stdio.h>
int main() {
int x, i; // Declare variables for user input and loop counter
printf("Input an integer: ");
scanf("%d", &x); // Prompt user for an integer
for(i = 1; i <= 100; i++) // Loop through numbers from 1 to 100
{
if((i%x) == 3) { // Check if the remainder of i divided by x is 3
printf("%d\n", i); // Print i if the condition is met
}
}
return 0;
}
Input data: 25
Sample Output:
Input an integer: 3 28 53 78
Flowchart:

C Programming Code Editor:
Previous: Write a C program to check a given integer is positive even, negative even, positive odd or negative odd. Print even if the number is 0.
Next: Write a C program that accepts some integers from the user and find the highest value and the input position.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join