Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Write a program to print the numbers from 1 to 100 on the screen. Skip those numbers which
- are divisible by 3 or 5 but not by both. */
- #include <stdio.h>
- int main()
- {
- for(int i = 1; i <= 100; i++)
- {
- if ((i % 3 == 0 || i % 5 == 0) && !(i % 3 == 0 && i % 5 == 0))
- {
- continue; // Skip numbers divisible by 3 or 5 but not both
- }
- printf("%d ", i);
- }
- printf("\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement