Not Equal to Zero

The program must accept a number and print yes if it is NOT equal to zero. Else it must print no.

Example Input/Output 1:
Input:
0

Output:
no

Example Input/Output 2:
Input:
22

Output:
yes

Python

N = int(input())
if N != 0:
    print('yes')
else:
print('no')

Java

import java.util.*;
public class Hello {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        if (N != 0) {
            System.out.print("yes");
        } else {
            System.out.print("no");
        }
    }
}

C

#include <stdlib.h>
#include  <stdio.h>
int main()
{
    int N;
    scanf("%d",&N);
    if(N!=0)
    {
        printf("yes");
    }
    else
    {
        printf("no");
    }
}

C++

#include <iostream>
using namespace std;
int main()
{
    int N;
    cin >> N;
    if(N != 0)
    {
        cout << "yes";
    }
    else
    {
        cout << "no";
    }
    return 0;
}
Previous Article

Smallest of Two Numbers

Next Article

Print - 111 to 2

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *