Assignment 4 MCA
Assignment 4 MCA
LOOP
* A 1 1
0
** AB 22 12
12
*** ABC 333 123
345
**** ABCD 4444 1234
6789
***** A BCDE 55555 12345
ABCDEF
***** * ********* 1
ABCDE
**** *** * * * * ** * 121
ABCD
*** ***** ***** 12321
ABC
** ******* *** 1234321
AB
* ********* * 123454321
A
1 ***** * *****
*******
123 **** *** * *
*** ***
12345 *** ***** * *
** **
123 **** *** * *
* *
1 ***** * *****
1 ******
$ * * * * $ * * * $
1 1 *
* $ * * $ $ *
1 2 1 *
* $ * * $ *
1 3 3 1 *
* $ * * $ $ *
1 4 6 4 1 *
* * * * $ $ * * * $
1 5 10 10 5 1 ******
2. Pascal Triangle is something where each element (i, j) is the sum of (i-1,j) and (i-1,j-1)
element . Now create the Pascal triangle up to nth row with the help of FOR LOOP. Value of
n will be key board input.
3. Write a program to print the following pattern :
4. Write a program to print all the prime number between 1 to n using for loop, break and
continue. The value of n will be input from key board. N>=300. Also count the sum of all those
prime numbers and print the sum as well as numbers.
5. Write a program to print all the subset of 1, 2, 3 using for loop. Super set of a set containing n
element has 2^n element. Mean if n=3, superset contain 8 element. Those are null, 1, 2, 3, 1 2,
1 3, 2 3, 1 2 3. Print all the subset for a given value of n. N will be key board input.
6. Print all the Romanian number from 1 to n. N will be key board input. N>=10.
Romanian letters are I, II, III, IV, V, VI, VII, VIII, IX, X, XI, XII, XII, XIV and XV and so on.
7. Write a program to calculate the factorial of a number. Then calculate the sum of n terms of the
following series: 1/1! + 2/2! + 3/3! + ……. + n/n! . N will be key board input. N>=10. Factorial of
n= n*(n-1)*(n-2)*(n-3)*……….*1
8. Write a program to print all the ASCII values and their equivalent characters using while loop.
The ASCII values vary from 0 to 255. Then also fill the entire screen with the smiling face. The
ASCII value of smiling face 1.
9. Write a program to print all the Armstrong numbers between 1 and 500. If the sum of cubes of
each number is equal to the number itself, then the number is called an Armstrong number. For
example 153= 1^3 + 5^3+ 3^3.
10. Write a program to find the OCTAL, Hexadecimal and Binary forms of given decimal
number. For example Octal, Hexadecimal, Binary of Decimal number 10 are A, 12, 1010.
Decimal number should key board input.
11. The natural logarithm can be approximated by the following series.
(X-1)/x + 1/2(x-1/x)2 + ½(x-1/x)3 +……… + ½(x-1/x)n If x, n is input through key board, write a
program to calculate sum of first n terms of this series.
12. Write a class average program with the help of do - while Loop. Enter grade of n (n>10)
student from key board, calculate average grade and display it. If average grade is below 40 also
display year back message.