COMPUTER PROJECT
COMPUTER PROJECT
PROJECT
NAME-PRABHAV GUPTA
CLASS- 11
SECTION- J
ROLL NUMBER- 21
TYPE 1-NUMBER BASED
PROGRAM
PROGRAM 1
Topic:
A binary to decimal conversion
program converts a binary number
(base-2) into its equivalent decimal
number (base-10).
Algorithm:
1. Input a binary number as a string.
2. Initialize a variable decimal to 0.
3. For each digit in the binary
number (from right to left):
o If the digit is '1', update decimal
by adding 2^position (where
position starts from 0).
o Increase the position by 1.
4. Print the resulting decimal
number.
Program:
Output:
Variable Data Table
Output:
Variable Data Table:
Output:
Variable Data Table:
Variable Type Purpose
Stores the
siz Int size of the
e array
Array to
ar Int[] store input
r elements
Points to the
Left Int current left
element
during the
reversal
Points to the
Right Int current right
element
during the
reversal
Temporary
temp int variable to
help swap
elements
Program:
Output:
Variable Data Table:
Variable Type Purpose
rows Int Stores the
number of
rows in the
matrix
cols Int Stores the
number of
columns in
the matrix
matrix Int[][] Stores the
elements of
the input
matrix
transp Int[][] Stores the
transposed
ose matrix with
swapped
dimensions
Loop control
i, int variables for
j traversing the
2D arrays
TYPE 4-STRING PROGRAMS
PROGRAM 7
Topic:
This program checks if a given
string is a palindrome (i.e., it reads
the same forwards and backwards).
Algorithm:
1. Input a string.
2. Remove any non-alphabetic
characters and convert the
string to lowercase.
3. Initialize two pointers: one at
the start (left) and one at the
end (right) of the string.
4. Compare the characters at
left and right.
o If they match, move the
pointers towards the middle.
o If they don't match, the string
is not a palindrome.
5. If all characters match, the
string is a palindrome.
Program:
Output:
Variable Data Table:
Variable Type Purpose
Str String Stores the
cleaned,
lowercase
version of
the input
string
Left Int Points to the
current
leftmost
character
Right Int Points to the
current
rightmost
character
isPalindro boolean Tracks whether
me the string is
identified as a
palindrome
PROGRAM 8
Topic:
This program counts the number
of vowels and consonants in a
given string.
Algorithm:
1. Input a string.
2. Convert the string to
lowercase.
3. Initialize two counters:
vowels and consonants.
4. Traverse the string:
o If a character is a vowel (a,
e, i, o, u), increment the
vowels counter.
o If it's an alphabetic
character and not a vowel,
increment the consonants
counter.
5. Print the counts of vowels
and consonants.
Program:
Output: