- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion

# C/C++ Program to check whether it is possible to make the divisible by 3 number using all digits in an array?

To check whether a number is divisible by 3, we add all the digits of the number and then calculate that the sum is divisible by 3 or not. In this problem, there is an array of integers arr[], and we have to check if a number formed with these number is divisible by 3. If the number formed is divisible then print *‘yes’* else print *‘no’*

Input: arr[] = {45, 51, 90} Output: Yes

## Explanation

construct a number which is divisible by 3, for example, 945510.

So the answer will be Yes Find the remainder of the sum when divided by 3 true if the remainder is 0.

## Example

#include <stdio.h> int main() { int arr[] = { 45, 51, 90 }; int n =3; int rem = 0; for (int i = 0; i < n; i++) { rem = (rem + arr[i]) % 3; } if (rem==0) printf("Yes\n"); else printf("No\n"); return 0; }

- Related Articles
- C/C++ Program to check whether it is possible to make a divisible by 3 number using all digits in an array?
- Python Program to check whether it is possible to make a divisible by 3 number using all digits in an array
- Java Program to check whether it is possible to make a divisible by 3 number using all digits in an array
- Possible to make a divisible by 3 number using all digits in an array in C++
- Number of digits to be removed to make a number divisible by 3 in C++
- C Program to check if a number is divisible by sum of its digits
- C Program to check if a number is divisible by any of its digits
- C# Program to find whether the Number is Divisible by 2
- C Program to Check if all digits of a number divide it
- C++ program to check whether it is possible to finish all the tasks or not from given dependencies
- How to find whether the Number is Divisible by 2 using C#?
- Check whether it is possible to make both arrays equal by modifying a single element in Python
- Check whether 974 is divisible by 3 or not.
- Find an array element such that all elements are divisible by it using c++
- PHP program to check if all digits of a number divide it

Advertisements