Loop Programs

1) WAP to print counting 1 to 10
set talk off
clear 
a=1
do while a<=10
?a
a=a+1
enddo

2) WAP to print counting 10 to 1

set talk off
clear 
a=10
do while a>=1
?a
a=a-1
enddo

3) WAP to print even numbers 1 to 10

set talk off
clear 
a=2
do while a<=10
?a
a=a+2
enddo

4) WAP to print odd numbers 1 to 10

set talk off
clear 
a=1
do while a<=10
?a
a=a+2
enddo


5) WAP to print sum of counting 1 to 10

set talk off
clear 
a=1
sum=0
do while a<=10
Sum=sum+a
?sum
a=a+1
enddo

6) WAP to print table of a number.

set talk off
clear 
a=1
input”Enter Any Number” to n
do while a<=10
r=n*a
?r
a=a+1
enddo

7) WAP to print factorial of a number.

set talk off
clear 
a=1
fact=1
input”Enter Any Number” to n
do while a<=n
fact=fact*a
?fact
a=a+1
enddo

for loop

1) WAP to print counting 1 to 10
 clear
for a=1 to 10
?a
endfor

2) WAP to print table of a number
 clear
input”Enter Any Number” to n
for a=1 to 10
r=n*a
?r
endfor