Thursday, November 22, 2012

Loop Assignment Answers

Loop Assignment Answers


1) Write a program to display numbers from 1 to 250.

2) Write a program to calculate the sum of all the numbers less than a given number n.
ex: output
Enter number : 3
6
Enter number : 5
15




3) Write a program to display “hello world” for every time we enter the character 'y' and stop the
program when we enter the character 'n'. For any other character program should not stop or
display anything.

4) Write a program to calculate the factorial value for a given number N.

5) Write a program to calculate number of possible combinations that we can have when we
selecting r number of elements from n number of different elements. This can be calculated by
calculating the value n!/(r!*(n-r)!).

No comments:

Post a Comment