Print numbers between 1 and 100 with a specific remainder
C Practice Exercise
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:

For more Practice: Solve these Related Problems:
- Write a C program to print all numbers between 1 and 100 that leave a remainder of 1 when divided by a user-specified divisor.
- Write a C program to display numbers between 1 and 100 that are congruent to a specified value modulo a given number.
- Write a C program to print all numbers between 1 and 100 that give a remainder of 4 when divided by a given integer.
- Write a C program to list numbers between 1 and 100 that are one less than a multiple of a user-provided number.
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 and Language Statistics
- Weekly Trends and Language Statistics