Hey I'm only new to Javascript so bare with with me please, but I have to write code that will add a number say for example 1, to a set amount of numbers lets say 5, so for example the output of the program should be:
1+1=2
1+2=3
1+3=4
1+4=5
1+5=6.
I have programmed this in C however i am having problems doing this in Javascript, any help is greatly appreciated.
here is the code I have tried to write myself:
function main()
{
num1 ;
var b = number()
num2[0] = 1 ;
num2[1] = 2 ;
num2[3] = 3 ;
num2[4] = 4 ;
i ;
total ;
document.write("enter a value for num1", num1);
for (i=0;i<20;i++)
{
document.write("enter a value for num2]", num[2]);
total = num1+ num2[i] ;
total= num1+num2[i];
document.write("sum is equal to :", +total);
}
and the C code that works is :
//
// main.m
// Untitled
//
// Created by Adam Johnston on 01/05/2010.
// Copyright DIT 2010. All rights reserved.
//
#include <stdio.h>
int main()
{
int number1 ;
int number2[20] ;
int i ;
int total ;
printf("enter a number for value1\n");
scanf("%d",&number1);
for (i=0;i<20;i++)
{
printf("enter value 2\n");
scanf("%d", &number2[i]) ;
number1+ number2[i] ;
total= number1+number2[i];
printf("sum is equal to %d\n", total);
}
}