Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

C# Sharp Exercises: Check if a given positive number is a multiple of 3 or a multiple of 7

C# Sharp Basic: Exercise-33 with Solution

Write a C# program to check if a given positive number is a multiple of 3 or a multiple of 7.

C# Sharp Exercises: Check if a given positive number is a multiple of 3 or a multiple of 7

C# Sharp Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class Exercise33 {
  static void Main(string[] args)
        {
           Console.WriteLine("\nInput first integer:");  
           int x = Convert.ToInt32(Console.ReadLine());
           if (x > 0)
           {
              Console.WriteLine(x % 3 == 0 || x % 7 == 0);
           }
        }
}

Sample Output:

Input first integer:                                                   
15                                                                     
True

Flowchart:

Flowchart: C# Sharp Exercises - Check if a given positive number is a multiple of 3 or a multiple of 7

C# Sharp Code Editor:

Improve this sample solution and post your code through Disqus

Previous: Write a C# program to create a new string of four copies, taking last four characters from a given string. If the length of the given string is less than 4 return the original one.
Next: Write a C# program to check if a string starts with a specified word.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.