Java Program to demonstate for loop - HackerRank

 


// Program by Akash Tripathi (@proakash256) 
import java.io.*;
public class For_loop2
{
    public static void main(String[] argsthrows IOException
    {
        BufferedReader sc = new BufferedReader 
(new InputStreamReader(System.in));
        int t = Integer.parseInt(sc.readLine());
        int sum = 0 , d = 1;
        for(int i = 1i <= ti = i + 1)
        {
            int a = Integer.parseInt(sc.readLine());
            int b = Integer.parseInt(sc.readLine());
            int n = Integer.parseInt(sc.readLine());
            for(int j = 1j <= nj = j + 1)
            {
                for(int k = 1k <= jk = k + 1)
                {
                    sum = sum + (d * b);
                    d = d * 2;
                }
                System.out.printf("%d " , (sum + a));
                sum = 0;
                d = 1;
            }
            System.out.println();
        }
        sc.close();
    }
}


Comments