Odd and even numbers

Odd and even numbers in c

#include<stdio.h>
using namespace std;
void EvenOddCheck(int number);

int main() {
  EvenOddCheck(12);
  return 0;
}
void EvenOddCheck(int number)
{
  if(number%2==0)
  {
    printf("%d is an even number",number);
  }
  else
  {
    printf("%d is an odd number",number);
  }
}

Output

12 is an even number

Odd and even numbers in c++

#include <iostream>
using namespace std;
class Example
{
public:
   void EvenOddCheck(int number)
    {
     if(number%2==0)
     {
      cout<<number<<" is an even number";
     }
     else
     {
      cout<<number<<" is an odd number";
     }
    }
};
int main() 
{
  Example ex1;
  ex1.EvenOddCheck(11);
  return 0;
}

Output

11 is an odd number

Odd and even numbers in c#

using System;

namespace HelloWorld
{
  class Program
  {
    public void EvenOddCheck(int number)
    {
     if(number%2==0)
     {
      Console.WriteLine(number+" is an even number");
     }
     else
     {
      Console.WriteLine(number+" is an odd number");
     }
    }
    static void Main(string[] args)
    {
    
      Program p1=new Program();
      p1.EvenOddCheck(10);
    }
  }
}

Output

10 is an even number

Odd and even numbers in java

class Program
 {
   public void EvenOddCheck(int number)
   {
     if(number%2==0)
     {
      System.out.println(number+" is an even number");
     }
     else
     {
      System.out.println(number+" is an odd number");
     }
   }
  public static void main(String[] args) {
    Program p1=new Program();
    p1.EvenOddCheck(13);
  }
 }

Output

13 is an odd number

Write a comment


Name Email Message