Computer Science, asked by vikrammbhat, 1 year ago

write a javascript program to add 6 numbers using variables

Answers

Answered by tithi
3
class sum
{
public static void main(String args[])
{
int a,b,c,d,e,f,g;
a=Integer.parseInt(args[0]);
b=Integer.parseInt(args[1]);
c=Integer.parseInt(args[2]);
d=Integer.parseInt(args[3]);
e=Integer.parseInt(args[4]);
f=Integer.parseInt(args[5]);
g=a+b+c+d+e+f;
System.out.println(g);
}
}


tithi: pls mark this best...plzzzzzzz
Answered by Anonymous
3

Hi

// get all numbers from user

const num1 = parseInt(prompt('Please ener 1st number:'));

const num2 = parseInt(prompt('Please ener 2nd number:'));

const num3 = parseInt(prompt('Please ener 3rd number:'));

const num4 = parseInt(prompt('Please ener 4th number:'));

const num5 = parseInt(prompt('Please ener 5th number:'));

const num6 = parseInt(prompt('Please ener 6th number:'));

// calculate total

const total = num1 + num2 + num3 + num4 + num5 + num6;

// write the output

document.write(total);

Similar questions