Saturday, 17 October 2015

Find attached your first assignment based on IF statement and FOR loop. Last question is however based on while loop. Try to complete the assignment before Monday. 

First Assignment based on IF statement and FOR loop.

1.               WAP to generate the following output
0 1
0 2
1 0
1 2
2 0
2 1
using multiple initialization and multiple increment decrement operations in ‘for’ loop.


2.                  Three numbers form a Pythagorean triple if the sum of squares of two numbers is equal to the square of the third. For example, 3, 5 and 4 form a Pythagorean triple, since 3*3 + 4*4 = 25 = 5*5 You are given three integers, a, b, and c. They need not be given in increasing order. If they form a Pythagorean triple, then print "yes", otherwise, print "no".

3.                  WAP to print division of a student based on marks of 3 subjects. Calculate percentage and then use this percentage to decide division of student. Program should use nested if-else statements.

4.                  You are given an input N, which is a positive integer. Write a program to find the sums of fourth powers of the first N numbers. (For ex. if you input 4, output should be the sum 14+24+34+44).

5.                  You are given a positive integer N. You have to print N rows as follows. The first row consists of one 0, the second row 2 zeroes, and so on, until the Nth row, which consists of N zeroes.

6.                  An Armstrong number is the one in which the sum of cubes of its digit is equal to the number itself. The program takes a number as input and output whether the given number is an Armstrong number or not. For example: (a) 371 is an Armstrong Number as 27+343+1=371 (b) 153 is an Armstrong Number (1+125+27=153) (c) 42 is not an Armstrong Number (64+8=72)

No comments:

Post a Comment