Class-12-Guidelines Regarding Computer Science Project
Class-12-Guidelines Regarding Computer Science Project
a) Program number
b) Problem description
c) Algorithm
d) Coding with necessary comments at some places.
e) Variable description
f) Output
The project should be submitted in the form of Spiral binding or in Strip file.
Signatures:
.................... ...................
Internal Examiner External Examiner
2
ACKNOWLEDGEMENT
-Your Name
3
INDEX
S.No. Program description in short Page No. Signature
1 Pascal’s Triangle 4
2
3
4
5
6
7
8
9
10
11
12
13
14
15
4
PROGRAM-1
a) Problem Description
Pascal’s triangle is a triangular array of binomial coefficients. Write a function that
takes an integer value n as input and prints first n lines of Pascal’s triangle.
Following are the first 6 rows of Pascal’s Triangle.
b) ALGORITHM
Steps to solve the problem:
c) Coding
/ java program for Pascal's Triangle
import java.io.*;
class PascalTriange {
public static void main (String[] args) {
int n = 5;
printPascal(n);
}
public static void printPascal(int n)
{
/ An auxiliary array to store generated pascal triangle values
int[][] arr = new int[n][n];
/ Iterate through every line and print integer(s) in it
for (int line = 0; line < n; line++)
{
/ Every line has number of integers equal to line
number for (int i = 0; i <= line; i++)
{
/ First and last values in every row are 1
if (line == i || i == 0) arr[line][i] = 1;
5
else // Other values are sum of values just above and left of above
arr[line][i] = arr[line-1][i-1] + arr[line-1][i];
System.out.print(arr[line][i]);
}
System.out.println();
}}}
d) Variable Description
e) Output