- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Program to print all the numbers divisible by 3 and 5 in C++

In this tutorial, we will be discussing a program to print all the numbers divisible by 3 and 5 less than the given number.

For this we will be given with a number say N. Our task is to print all the numbers less than N which are divisible by both 3 and 5.

## Example

#include <iostream> using namespace std; //printing the numbers divisible by 3 and 5 void print_div(int N){ for (int num = 0; num < N; num++){ if (num % 3 == 0 && num % 5 == 0) cout << num << " "; } } int main(){ int N = 70; print_div(N); return 0; }

## Output

0 15 30 45 60

- Related Questions & Answers
- C# program to print all the numbers divisible by 3 and 5 for a given number
- Python program to print all the numbers divisible by 3 and 5 for a given number
- Python Program to Print all Numbers in a Range Divisible by a Given Number
- Golang Program to Print all Numbers in a Range Divisible by a Given Number
- Python Program to Print all Integers that are not Divisible by Either 2 or 3 and Lie between 1 and 50
- Golang Program to Find the Numbers which are Divisible by 7 and Multiple of 5 in a Given Range
- Golang Program to print all integers between a range that aren't divisible by either 2 or 3
- N digit numbers divisible by 5 formed from the M digits in C++
- Check if a large number is divisible by 2, 3 and 5 or not in C++
- Binary Prefix Divisible By 5 in Python
- Largest number with the given set of N digits that is divisible by 2, 3 and 5 in C++
- Count numbers which are divisible by all the numbers from 2 to 10 in C++
- Number of substrings divisible by 8 and not by 3 in C++
- Count of all even numbers in the range [L, R] whose sum of digits is divisible by 3 in C++
- Sum of the numbers up to N that are divisible by 2 or 5 in c programming

Advertisements