Input output sample - 06

Input Specification:
The input begins with a single positive integer n on a line by itself indicating the number of the cases. Each test case contains a line.This line consists by one or more words.

Output Specification:
For each test case output a single integer in a line which denotes the length of input string.

Sample Input:
2
Uva Online Judge
www.outsbook.com

Sample Output:
16
16


C Code:
#include <stdio.h>
#include <string.h>
#define size 1000

int main(){
   int length,cas;
   char inputStr[size];
   scanf("%d",&cas);
   getchar();  // For ignoring new line
   while(cas--){
       gets(inputStr);
       length = strlen(inputStr);
       printf("%d\n",length);
   }
   return 0;
}


C++ Code:
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

int main(){
   int length,cas;
   string inputStr;
   cin>>cas;
   getchar(); // For ignoring new line
   while(cas--){
       getline(cin,inputStr);
       length = inputStr.length();
       cout<<length<<endl;
   }
   return 0;
}


Java Code:
import java.util.*;

class Main{
   public static void main(String args[]){
       Scanner sc = new Scanner(System.in);
       int length,cas;
       String inputStr;
       cas = sc.nextInt();
       sc.nextLine(); // For ignoring new line
       while(cas>0){
           inputStr = sc.nextLine();
           length = inputStr.length();
           System.out.println(length);
           cas--;
       }
   }
}