The runs scored by a batsman is passed as the input. The program must print if he has scored a Century or Half-Century.
Note: If the runs is from 50 to 99, it is Half-Century. Else if the runs is 100 or above it is Century. Also the value of runs will be greater than or equal to 50.
Example Input/Output 1:
Input:
55
Output:
Half-Century
Example Input/Output 2:
Input:
50
Output:
Half-Century
Example Input/Output 3:
Input:
102
Output:
Century
Python
runs = int(input())
if runs >= 50 and runs <= 99:
print('Half-Century')
elif runs >= 100:
print('Century')
Java
import java.util.*;
public class Hello {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int runs = sc.nextInt();
if (runs >= 50 && runs <= 99) {
System.out.print("Half-Century");
} else {
System.out.print("Century");
}
}
C
#include <stdlib.h>
#include <stdio.h>
int main()
{
int runs;
scanf("%d", &runs);
if(runs >= 50 && runs <= 99)
{
printf("Half-Century");
}
else if(runs >= 100)
{
printf("Century");
}
}
C++
#include <iostream>
using namespace std;
int main()
{
int runs;
cin >> runs;
if(runs >= 50 && runs <= 99)
{
cout << "Half-Century";
}
else if(runs >= 100)
{
cout << "Century";
}
return 0;
}
Leave a Reply