Helpfulbox Now Offers Free POS Software for restaurants, kiosk, and any other retails business completely free used windows cashier system or as full blown POS. You will able to print to kitchen, display orders on the kitchen screen, manage inventory, employee, report, customer loyalty offers, employee management, delivery address track and much more, al for free.

How to sum the values using loops?

Date: Fri-Jun-17-2016-
Response
1

> sumfunction<-function(x){

+ sum<-0

+ for(i in 1:length(x))

+ {

+ sum<-sum+x[i]

+ }

+ sum

+ }

To check the function

> y<-1:20

> sumfunction(y)

[1] 210

Date: Sat-Jun-18-2016
Response
0

Loop Passes

In the examples you have seen so far involving for loops, the code being executed was independent of its place in the repetition. For example, consider a loop which prints the name "Dave" 50 times:

    for (i = 1; i <= 50; i++) {

document.write("Dave" + "
");

}

Since the write statement enclosed inside the for loop does exactly the same thing each of the 50 times it is executed, there is no point in distinguishing among the different executions. This is not always the case, however.

Inside a for loop, it is possible to access the loop variable. The first time that the code is executed the loop variable has value 1, the second time the loop code is executed it has value 2, and so on up to the final number of repetitions. We will often refer to each execution of the loop code as a pass through the loop. Thus, another way of describing the loop variable is to say that it stores the number of the current pass through the loop. To illustrate this, consider the following loop:

    for (i = 1; i <= 5; i++) {

document.write("Pass " + i + "
");

}

On the first pass through this loop, the loop variable i will have the value 1, so any reference to i inside the loop will refer to the value 1. In this case, the message "Pass 1" is displayed. On the second pass, the loop variable has the value 2, so "Pass 2" is displayed. This same pattern continues until the final pass, in which the loop variable has the value 5. The complete output of this loop is:
    Pass 1

Pass 2

Pass 3

Pass 4

Pass 5


[d] By: Guest
Date: Thu-Jan-5-2017
Response
What is 1 + 100



Helpfulbox Now Offers Free POS Software

for restaurants, kiosk, and any other retails business completely free. It can be used as windows cashier system or as full blown POS. You will able to print to kitchen, display orders on the kitchen screen, manage inventory, employee, report, customer loyalty offers, employee management, delivery address track and much more, all for free.

Just Updated::