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;
}
Leave a Reply