The program must accept a string S as the input. The program must print the length of S as the output.
Boundary Condition(s):
1 <= Length of S <= 1000
Example Input/Output 1:
Input:
hello
Output:
5
Example Input/Output 2:
Input:
pineapple
Output:
9
Python
string = input()
print(len(string))
Java
import java.util.*;
public class Hello {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.next();
System.out.print(str.length());
}
}
C
#include <stdlib.h>
#include <stdio.h>
int main()
{
char str[1001];
scanf("%s", str);
printf("%d", strlen(str));
return 0;
}
C++
#include <iostream>
using namespace std;
int main()
{
string str;
cin >> str;
cout << str.length();
return 0;
}