3 और 5 से विभाज्य संख्याओं को प्रिंट करने के लिए, &&ऑपरेटर का उपयोग करें और दो शर्तों की जाँच करें -
f (num % 3 == 0 && num % 5 == 0) {} अगर ऊपर दी गई शर्त सही है, तो इसका मतलब यह होगा कि संख्या 3 और 5 से भी विभाज्य है।
निम्नलिखित पूरा कोड है -
उदाहरण
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Demo {
class MyApplication {
static void Main(string[] args) {
int num;
num = 15;
Console.WriteLine("Number: "+num);
// checking if the number is divisible by 3 and 5
if (num % 3 == 0 && num % 5 == 0) {
Console.WriteLine("Divisible by 3 and 5");
} else {
Console.WriteLine("Not divisible by 3 and 5");
}
Console.ReadLine();
}
}
} आउटपुट
Number: 15 Divisible by 3 and 5