package ankush;
public class ankush{
public static void main(String[] args) {
//
// What would be printed from the following Java code segment?
// int i;
// for(i=20;i>0;i-=2) {
// System.out.println(i);
// }
var x = 3;
var i = 0;
while (i < 3) {
x += 1;
i += 1;
}
println(x);
// for(int i=1; i<15; i=i+3)
//
// {
//
// System.out.print(i);
//
// }
// int space=3;
// int k=1;
//
// for(int i=1;i<=3;i++) {
// for(int j =3;j<=space;j++) {
// System.out.print("_");
// }
// System.out.println();
// }
// space--;
// for(int k=1;k<=(2*i)-1;k++)
//
}
}
//for(int i1=0;i1<=4;i1++) {
//System.out.println(i1);
// }
//for(int j1=0;j1<=4;j1++) {
// System.out.println(j1);
/*
int n, sumE = 0, sumO = 0;
Scanner p = new Scanner(System.in);
System.out.print("Enter the number of elements in array:");
n = p.nextInt();
int[] a = new int[n];
System.out.println("Enter the elements of the array:");
for(int i = 0; i < n; i++)
{
a[i] = p.nextInt();
}
for(int i = 0; i < n; i++)
{
if(a[i] % 2 == 0)
{
sumE = sumE + a[i];
}
else
{
sumO = sumO + a[i];
}
}
System.out.println("Sum of Even Numbers:"+sumE);
System.out.println("Sum of Odd Numbers:"+sumO);
*/
/*
Scanner a = new Scanner(System.in);
System.out.println("Enter a natural number");
int n = a.nextInt();
int i,sum=0;
for(i=0;i<=n;i++)
{
sum = sum+i;
}
System.out.println("Sum of "+n+" natural number = "+sum);
*/
No comments:
Post a Comment