Static datatypes

 Static datatypes

Problem Description


Declare a protected static variable outside the main and increment the variavle inside a function which is called inside the main and the incremented value returned should be displayed as output.

Logic Test Case 1


Input (stdin)

5


Expected Output


6

Logic Test Case 2


Input (stdin)

7


Expected Output


8



Code Area


import java.io.*;
import java.util.Scanner;
public class TestClass {
public static void main(String[] args) { 
Scanner s=new Scanner(System.in);
       int a=s.nextInt();
       a=a+1;
       System.out.printf(""+a);
}
}

Post a comment

0 Comments