Name - Khushal - Issrani Reg No 209302027 Sec E Lab 1
Name - Khushal - Issrani Reg No 209302027 Sec E Lab 1
Name - Khushal - Issrani Reg No 209302027 Sec E Lab 1
Reg no=209302027
Sec=E
LAB 1
Exercise 1
Code:
import java.util.Scanner;
if (n <= 1)
return n;
}
int number,i;
number=s.nextInt();
for(i=1;i<=number;i++){
System.out.println(num(i));
}
double total=0;
for(i=1;i<=number;i++){
total=total+num(i);
}
double avg=total/number;
}
Output
Exercise 2
Code:
public class exercise2 {
int sum = 0;
while (n != 0) {
}
return sum;
}
System.out.println(digit_sum(12345));
}
Output :
Exercise 3
Code:
public class HarmonicSum
{
int n = 50000;
System.out.println();
}
{
{
}
System.out.println();
return sum;
}
{
{
}
System.out.println();
return sum;
}
Output:
Exercise 4
Code:
import java.util.Scanner;
{
num=1;
flag=0;
{
num=num+1;
if (num % i == 0)
{
break;
}
}
if ( i == num)
flag = flag+1;
}
}
}
Output: