Input (Integer) | Printed Output (Commas are also important and there are no spaces in output) |
---|---|
3 | 1,3, |
8 | 1,2,4,8, |
24 | 1,2,3,4,6,8,12,24, |
class PrintFactorsOfNumber
{ public static void main(String s[])
{
printFactorsOfNumber(25);
}
public static void printFactorsOfNumber(int number)
{
//Write code here to print the factors of the given number.
}
}
Input | Output |
---|---|
7 |
2 + 4 + 6 = 12 |
15 |
2 + 4 + 6 + 8 + 10 + 12 + 14 = 56 |
class SumOfEvenNumbers
{ public static void main(String s[])
{
System.out.println("Sum of even numbers till 5 is " + sum_of_even_numbers(5));
}
public static int sum_of_even_numbers(int input)
{
int output = 0;
//Write code here to find the sum of even numbers till input and assign it to output
return output;
}
}
Input (String) | Printed Output |
---|---|
India | I |
campus | c |
class PrintFormation
{ public static void main(String s[])
{
printFormation("India");
}
public static void printFormation(String name)
{
//Write code here to print string pyramid using name. Use System.out.println or System.out.print for printing.
}
}
Input (Integer) | Printed Output |
---|---|
4 | 1 |
7 | 1 |
class PrintFormation
{ public static void main(String s[])
{
printFormation(5);
}
public static void printFormation(int size)
{
//Write code here to print the required formation depending upon the size. Use System.out.println or System.out.print for printing.
}
}
class FindMaxNumber
{ public static void main(String s[])
{
System.out.println("The maximum number in 3, 7 and 10 is " + maximum(3, 7, 10));
}
public static int maximum(int a, int b, int c)
{
int maximum = 0;
//Write code here to get the maximum value in a, b, c and assign it to result.
return maximum;
}
}