Check whether the given number is buzz number or not

Here given code implementation process.

// C program for 
// Check whether the given number is buzz number or not
#include <stdio.h>

void isBuzzNo(int number)
{
	if (number % 7 == 0 || number % 10 == 7)
	{
		// When last digit is 7  
		// or number is divisible by 7
		printf(" Number %d is buzz number\n", number);
	}
	else
	{
		printf(" Number %d is not buzz number\n", number);
	}
}
int main(int argc, char
	const *argv[])
{
	// Test Cases
	isBuzzNo(126);
	isBuzzNo(123);
	isBuzzNo(2120);
	isBuzzNo(107);
	isBuzzNo(170);
	return 0;
}

input

 Number 126 is buzz number
 Number 123 is not buzz number
 Number 2120 is not buzz number
 Number 107 is buzz number
 Number 170 is not buzz number
/*
  Java Program for
  Check whether the given number is buzz number or not
*/
public class BuzzNumber
{
	public void isBuzzNo(int number)
	{
		if (number % 7 == 0 || number % 10 == 7)
		{
			// When last digit is 7  
			// or number is divisible by 7
			System.out.println(" Number " + number + " is buzz number");
		}
		else
		{
			System.out.println(" Number " + number + " is not buzz number");
		}
	}
	public static void main(String[] args)
	{
		BuzzNumber task = new BuzzNumber();
		// Test Cases
		task.isBuzzNo(126);
		task.isBuzzNo(123);
		task.isBuzzNo(2120);
		task.isBuzzNo(107);
		task.isBuzzNo(170);
	}
}

input

 Number 126 is buzz number
 Number 123 is not buzz number
 Number 2120 is not buzz number
 Number 107 is buzz number
 Number 170 is not buzz number
// Include header file
#include <iostream>

using namespace std;
/*
  C++ Program for
  Check whether the given number is buzz number or not
*/
class BuzzNumber
{
	public: void isBuzzNo(int number)
	{
		if (number % 7 == 0 || number % 10 == 7)
		{
			// When last digit is 7  
			// or number is divisible by 7
			cout << " Number " << number << " is buzz number" << endl;
		}
		else
		{
			cout << " Number " << number << " is not buzz number" << endl;
		}
	}
};
int main()
{
	BuzzNumber *task = new BuzzNumber();
	// Test Cases
	task->isBuzzNo(126);
	task->isBuzzNo(123);
	task->isBuzzNo(2120);
	task->isBuzzNo(107);
	task->isBuzzNo(170);
	return 0;
}

input

 Number 126 is buzz number
 Number 123 is not buzz number
 Number 2120 is not buzz number
 Number 107 is buzz number
 Number 170 is not buzz number
// Include namespace system
using System;
/*
  Csharp Program for
  Check whether the given number is buzz number or not
*/
public class BuzzNumber
{
	public void isBuzzNo(int number)
	{
		if (number % 7 == 0 || number % 10 == 7)
		{
			// When last digit is 7  
			// or number is divisible by 7
			Console.WriteLine(" Number " + number + " is buzz number");
		}
		else
		{
			Console.WriteLine(" Number " + number + " is not buzz number");
		}
	}
	public static void Main(String[] args)
	{
		BuzzNumber task = new BuzzNumber();
		// Test Cases
		task.isBuzzNo(126);
		task.isBuzzNo(123);
		task.isBuzzNo(2120);
		task.isBuzzNo(107);
		task.isBuzzNo(170);
	}
}

input

 Number 126 is buzz number
 Number 123 is not buzz number
 Number 2120 is not buzz number
 Number 107 is buzz number
 Number 170 is not buzz number
<?php
/*
  Php Program for
  Check whether the given number is buzz number or not
*/
class BuzzNumber
{
	public	function isBuzzNo($number)
	{
		if ($number % 7 == 0 || $number % 10 == 7)
		{
			// When last digit is 7  
			// or number is divisible by 7
			echo " Number ".$number.
			" is buzz number".
			"\n";
		}
		else
		{
			echo " Number ".$number.
			" is not buzz number".
			"\n";
		}
	}
}

function main()
{
	$task = new BuzzNumber();
	// Test Cases
	$task->isBuzzNo(126);
	$task->isBuzzNo(123);
	$task->isBuzzNo(2120);
	$task->isBuzzNo(107);
	$task->isBuzzNo(170);
}
main();

input

 Number 126 is buzz number
 Number 123 is not buzz number
 Number 2120 is not buzz number
 Number 107 is buzz number
 Number 170 is not buzz number
/*
  Node JS Program for
  Check whether the given number is buzz number or not
*/
class BuzzNumber
{
	isBuzzNo(number)
	{
		if (number % 7 == 0 || number % 10 == 7)
		{
			// When last digit is 7  
			// or number is divisible by 7
			console.log(" Number " + number + " is buzz number");
		}
		else
		{
			console.log(" Number " + number + " is not buzz number");
		}
	}
}

function main()
{
	var task = new BuzzNumber();
	// Test Cases
	task.isBuzzNo(126);
	task.isBuzzNo(123);
	task.isBuzzNo(2120);
	task.isBuzzNo(107);
	task.isBuzzNo(170);
}
main();

input

 Number 126 is buzz number
 Number 123 is not buzz number
 Number 2120 is not buzz number
 Number 107 is buzz number
 Number 170 is not buzz number
#  Python 3 Program for
#  Check whether the given number is buzz number or not
class BuzzNumber :
	def isBuzzNo(self, number) :
		if (number % 7 == 0 or number % 10 == 7) :
			#  When last digit is 7  
			#  or number is divisible by 7
			print(" Number", number ,"is buzz number")
		else :
			print(" Number", number ,"is not buzz number")
		
	

def main() :
	task = BuzzNumber()
	#  Test Cases
	task.isBuzzNo(126)
	task.isBuzzNo(123)
	task.isBuzzNo(2120)
	task.isBuzzNo(107)
	task.isBuzzNo(170)

if __name__ == "__main__": main()

input

 Number 126 is buzz number
 Number 123 is not buzz number
 Number 2120 is not buzz number
 Number 107 is buzz number
 Number 170 is not buzz number
#  Ruby Program for
#  Check whether the given number is buzz number or not
class BuzzNumber 
	def isBuzzNo(number) 
		if (number % 7 == 0 || number % 10 == 7) 
			#  When last digit is 7  
			#  or number is divisible by 7
			print(" Number ", number ," is buzz number", "\n")
		else 
			print(" Number ", number ," is not buzz number", "\n")
		end

	end

end

def main() 
	task = BuzzNumber.new()
	#  Test Cases
	task.isBuzzNo(126)
	task.isBuzzNo(123)
	task.isBuzzNo(2120)
	task.isBuzzNo(107)
	task.isBuzzNo(170)
end

main()

input

 Number 126 is buzz number
 Number 123 is not buzz number
 Number 2120 is not buzz number
 Number 107 is buzz number
 Number 170 is not buzz number
/*
  Scala Program for
  Check whether the given number is buzz number or not
*/
class BuzzNumber()
{
	def isBuzzNo(number: Int): Unit = {
		if (number % 7 == 0 || number % 10 == 7)
		{
			// When last digit is 7  
			// or number is divisible by 7
			println(" Number " + number + " is buzz number");
		}
		else
		{
			println(" Number " + number + " is not buzz number");
		}
	}
}
object Main
{
	def main(args: Array[String]): Unit = {
		var task: BuzzNumber = new BuzzNumber();
		// Test Cases
		task.isBuzzNo(126);
		task.isBuzzNo(123);
		task.isBuzzNo(2120);
		task.isBuzzNo(107);
		task.isBuzzNo(170);
	}
}

input

 Number 126 is buzz number
 Number 123 is not buzz number
 Number 2120 is not buzz number
 Number 107 is buzz number
 Number 170 is not buzz number
/*
  Swift 4 Program for
  Check whether the given number is buzz number or not
*/
class BuzzNumber
{
	func isBuzzNo(_ number: Int)
	{
		if (number % 7 == 0 || number % 10 == 7)
		{
			// When last digit is 7  
			// or number is divisible by 7
			print(" Number", number ,"is buzz number");
		}
		else
		{
			print(" Number", number ,"is not buzz number");
		}
	}
}
func main()
{
	let task: BuzzNumber = BuzzNumber();
	// Test Cases
	task.isBuzzNo(126);
	task.isBuzzNo(123);
	task.isBuzzNo(2120);
	task.isBuzzNo(107);
	task.isBuzzNo(170);
}
main();

input

 Number 126 is buzz number
 Number 123 is not buzz number
 Number 2120 is not buzz number
 Number 107 is buzz number
 Number 170 is not buzz number
/*
  Kotlin Program for
  Check whether the given number is buzz number or not
*/
class BuzzNumber
{
	fun isBuzzNo(number: Int): Unit
	{
		if (number % 7 == 0 || number % 10 == 7)
		{
			// When last digit is 7  
			// or number is divisible by 7
			println(" Number " + number + " is buzz number");
		}
		else
		{
			println(" Number " + number + " is not buzz number");
		}
	}
}
fun main(args: Array < String > ): Unit
{
	val task: BuzzNumber = BuzzNumber();
	// Test Cases
	task.isBuzzNo(126);
	task.isBuzzNo(123);
	task.isBuzzNo(2120);
	task.isBuzzNo(107);
	task.isBuzzNo(170);
}

input

 Number 126 is buzz number
 Number 123 is not buzz number
 Number 2120 is not buzz number
 Number 107 is buzz number
 Number 170 is not buzz number


Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

New Comment







© 2021, kalkicode.com, All rights reserved