0% found this document useful (0 votes)
23 views51 pages

Computer Project - Pragya Gupta

The document is an assessment sheet for a project by Pragya Gupta, detailing acknowledgments and a series of programming tasks involving arrays and strings. It includes various programming exercises, such as calculating sums, averages, and searching techniques using linear and binary search. The document also provides sample code and variable descriptions for each task.

Uploaded by

Pradyumn Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views51 pages

Computer Project - Pragya Gupta

The document is an assessment sheet for a project by Pragya Gupta, detailing acknowledgments and a series of programming tasks involving arrays and strings. It includes various programming exercises, such as calculating sums, averages, and searching techniques using linear and binary search. The document also provides sample code and variable descriptions for each task.

Uploaded by

Pradyumn Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1

ASSESSMENT
SHEET

Name :- Pragya Gupta

Class :- X

Section :- B

Roll No :- 37

Internal Examiner Signature :-

External Examiner Signature :-


2

ACKNOWLEDGEME
NT
The success and final outcome of this project required a lot of
guidance and assistance from many people and I am
extremely privileged to have got this all along the completion
of my project. All that I have done is only due to such
supervision and assistance and I would not forget to thank
them.

I respect and thank Mr. Arun Kumar Sir, for providing me an


opportunity to do this project and giving us all support and
guidance which made me complete the project duly. I am
extremely thankful to him providing such a nice support and
guidance even after having his busy schedule managing the
corporate affairs.

I owe my deep gratitude to my project guide i.e. none other


than my friends, who took keen interest in my project work
and guided me all along, till the completion of my project
work by providing all the necessary information by developing
a good system.
3

I would not forget to remember my parents and siblings for


their encouragement and more over for their timely support
and guidance till the completion of this project.

At last I would also like to thank the examiner for taking pains
to go through this project and I would also welcome
suggestions for improvement.

- Pragya Gupta

INDEX
S. Cate Name of Pag
no gory Program e
No.
(s)
* Arrays
1 Write a program to enter
10 numbers in an array
and print the sum of all
even numbers.
4

2 Write a program to enter


10 numbers in an array
and print the sum of the
numbers at even
positions.
3 Write a program to enter
10 numbers in an array
and reverse the array
elements without using
another array.
4 Write a program to input
15 numbers in an Array
and find the average of
the odd numbers in the
inputed array.
5 Write a program to enter
10 numbers in an array
and search the given
number using linear
search technique.
6 Write a program to enter
10 numbers in an array
and search the given
number using binary
search technique.
7 Write a program to input
16 numbers in 4 rows and
4 columns of the Array of
size 5x5. Then find the
sum of each row and each
5

column and store the


result in the
corresponding rows and
columns of the Array and
then print the resulting
matrix.
* String
8 Write a program to accept
a String and convert the
String into UpperCase and
also count the number of
double letter sequence.
9 Write a program to input a
String and print the String
with UpperCase and
LowerCase letters
reversed.
10 Write a program to input a
String and count the
number of vowels in the
String.
11 Write a program to input
any String and convert the
String into Piglatin Form.
12 Write a program to input
any String and print only
the Palindrome words of
the String.
13 Write a program to input a
6

string in the provided


manner.
14 Write a program by
considering the following
statement to change 26 to
15, January to August,
Republic to Independence,
and finally print the
updated String, “January
26 is celebrated as the
Republic Day of India”.
* Primar
y
Progra
ms
15 Write a program to input
any number and print
whether it is a prime
number or not.
16 Write a program to print
the following Pattern
17 Write a program to print
the following Fibonacci
Series
18 Write a program to input
any number and check
whether it is automorphic
or not
19 Write a program to input
7

any age and check


whether the person is a
Senior Citizen or not.
20 Write a program to input
any number and check
whether it is a triple digit
number or not.

COMPUTER PROGRAMS
Arrays
7 Programs including Single Dimension
Array, Linear Search, Binary Search and
Double Dimension Array
8

Ques 1) Write a program to input 10 numbers in an


array and find the sum of all even numbers.
import java.util.*;
class sum
{
public static void main()
{
int a[] = new int[10];
int i, s=0;
Scanner sc = new Scanner(System.in);
System.out.println(“Enter 10 Numbers”);
for( i=0 ; i<=9 ; i++ )
{
a[i] = sc.nextInt();
}
for( i=0 ; i<=9 ; i++ )
{
if( a[i] % 2 == 0 )
s = s + a[i];
}
System.out.println( “Sum of all the even numbers is” + s
);
}
9

INPUT:- a[] = { 2, 9, 32, 45, 39, 12, 24, 33, 37, 26 }


OUTPUT:- Sum of all the even numbers is 96

VARIABLE DESCRIPTION TABLE

S. VARI DESCRIPTION DATA


No. ABLE TPE
1 i Looping Variable Intege
r
2 s Variable for storing the sum of all even Intege
numbers from the inputed Array r
3 a[] Array for storing values Intege
r

Ques 2) Write a program to input 10 numbers in an


array and find the sum of all numbers at even position.
import java.util.*;
class sum2
{
public static void main()
10

{
int a[] = new int[10];
int i, s=0;
Scanner sc = new Scanner(System.in);
System.out.println(“Enter 10 numbers”);
for( i=0 ; i<=9 ; i++)
{
a[i] = sc.nextInt();
}
for( i=0 ; i<=9 ; i++)
{
if( a[i] % 2 != 0 )
s = s + a[i];
}
System.out.println( “Sum of numbers at even position
is”+ s );
}
}
INPUT:- a[] = { 2, 9, 32, 45, 39, 12, 24, 33, 37, 26}
OUTPUT:- Sum of the numbers at even position is---

VARIABLE DESCRIPTION TABLE


11

S. VARI DESCRIPTION DATA


No ABLE TYPE
1 i Looping Variable Intege
r
2 s Variable for storing the sum of numbers Intege
at even position of the inputed Array r
3 a[] Array for storing values Intege
r

Ques 3) Write a program to input 10 numbers in an


array and find the average of odd numbers.
import java.util.*;
class average
12

{
public static void main()
{
int a[] = new int[10];
int I, s=0, c=0;
double avg;
Scanner s = new Scanner(System.in);
System.out.println(“Enter 10 numbers”);
for(i=0 ; i<=9 ; i++)
{
a[i] = sc.nextInt();
}
for(i=0 ; i<=9 ; i++)
{
if (a[i] % 2!= 0)
{
s = s+a[i];
c++;
}
avg = s/c;
System.out.print(“The average of odd numbers of the
Array is”+avg”);
}
13

INPUT:- a[] = { 2, 9, 32, 45, 39, 12, 24, 33, 37, 26}
OUTPUT:- The average of the odd numbers of the Array is
32.6

VARIABLE DESCRIPTION TABLE

S. VARI DESCRIPTION DATA


No ABLE TYPE
1 i Looping Variable Intege
r
2 s Variable for calculating the sum of odd Intege
numbers of the inputed Array r
3 c Counting Variable Intege
r
4 avg Variable for calculating the average of Doubl
the inputed Array e
5 a[i] Array for storing values Intege
r
14

Ques 4) Write a program to enter 10 numbers in an


array and reverse the array elements without using
another array.
import java.util.*;
class reverse
{
public static void main()
{
int a[] = new int[10];
int i, j, t;
Scanner sc = new Scanner(System.in);
System.out.println(“Enter 10 numbers”);
for( i=0 ; i<=9 ; i++)
{
a[i] = sc.nextInt();
}
for(i=0 , j=9 ; i<=j ; i++ , j--)
{
t = a[i];
a[i] = a[j];
a[j] = t;
}
for(i=0 ; i<=9 ; i++)
15

{
System.out.print(“Reversed Array elements are” +
a[i]);
}
}
}

INPUT:- a[] = { 2, 9, 32, 45, 39, 12, 24, 33, 37, 26}
OUTPUT:- a[] = Reversed Array elements are 26, 37, 33, 24,
12, 39, 45, 32, 9, 2

VARIABLE DESCRIPTION TABLE

S. VARIA DESCRIPTION DAT


No BLE ATPE
1 i Looping Variable Integ
er
2 j Looping Variable Integ
er
3 t Temporary Variable for reversing the Integ
Array values er
4 a[] Array for storing values Integ
er
16

Ques 5) Write a program to enter 10 numbers in an


array and search the given number by linear search
technique.
import java.util.*;
class linear
{
public static void main()
{
int a[] = new int[10];
int i, n, f=0;
Scanner sc = new Scanner(System.in);
System.out.println(“Enter 10 numbers”);
for(i=0 ; i<=9 ; i++)
{
a[i] = sc.nextInt();
}
System.out.println(“Enter any number to be searched”);
n = sc.nextInt();
17

for(i=0 ; i<=9; i++)


{
if(n == a[i])
{
f = 1;
}
}
if(f == 1)
System.out.println(“Number exists and the position is” +
(i+1));
else
System.out.println(“Number does not exist”);
}
}

INPUT:- {2, 9, 32, 45, 39, 12, 24, 33, 37, 26}
Number to be searched 45
OUTPUT:- Number exists and the position is 4

VARIABLE DESCRIPTION TABLE

S. VARI DESCRIPTION DATA


No ABLE TYPE
18

1 i Looping Variable Intege


r
2 n Variable to enter the number for Intege
searching in the inputed array r
3 f Flag Variable Intege
r
4 a[] Array for storing values Intege
r

Ques 6) Write a program to enter 10 numbers in an


array in a specific order and search the given number
by Binary search technique.
import java.util.*;
class binary
{
public static void main()
{
Int a[] = new int[10];
int i, n, f=0, l=0, u=9, m;
Scanner sc = new Scanner(System.in);
System.out.println(“Enter 10 numbers in an array in
ascending order”);
for(i=0 ; i<=9 ; i++)
19

{
a[i] = sc.nextInt();
}
System.out.println(“Enter a number to be searched”);
n = sc.nextInt();
while(l<=u)
{
m = (l+u)/2;
if( n == a[m])
{
f=1;
break;
}
else
if( n>a[m])
l = m+1;
else
if( n<a[m] )
u = m-1;
}
if (f==1 )
System.out.println(“Number exists”);
else
20

System.out.println(“Number does not exist”);


}
}

INPUT:- {2, 9, 32, 45, 39, 12, 24, 33, 37, 26}
Number to be searched 2
OUTPUT:- Number exists

VARIABLE DESCRIPTION TABLE

S. VARI DESCRIPTION DATA


No ABLE TYPE
1 i Looping Variable Intege
r
2 n Variable to enter the number to be Intege
searched in the inputed Array r
3 f Flag Variable Intege
r
4 l Variable to enter the Lower Limit of the Intege
Array r
5 u Variable to enter the Upper Limit of the Intege
Array r
6 m Variable to find the Middle Term of the Intege
inputed Array r
7 a[] Array for storing values Intege
r
21

Ques 7) Write a program to input 16 numbers in 4 rows


and 4 columns in a matrix of 5x5. Then find the sum of
each row and each column and store the result in the
corresponding rows and columns and print the
resulting matrix.
import java.util.*;
class array
{
public static void main()
{
22

int a[][] = new int [5][5];


int i, j, s1 =0, s2=0 ; s3=0;
Scanner sc = new Scanner(System.in);
System.out.println(“Enter 16 numbers”);
for(i=0 ; i<=3; i++)
{
for(j=0 ; j<=3 ; j++)
{
a[i][j] = sc. nextInt();
}
}
for(i=0 ; i<=3 ; i++)
{
s1=0;
s2=0;
for(j=0 ; j<=3; j++)
{
s3 = s3+a[i][j];
s2 = s2+a[i][j];
s1 = s1+a[i][j];
}
a[i][j] = s2;
a[j][i] = s1;
23

}
for(i=0 ; i<=4 ; i++)
{
for(j=0 ; j<=4 ; j++)
System.out.print(“The resulting matrix is”+a[i][j]);
}
System.out.println();
}
}

VARIABLE DESCRIPTION TABLE

S. VARI DESCRIPTION DATA


No ABLE TYPE
1 i Looping Variable Intege
r
2 j Looping Variable Intege
r
3 s1 Variable for calculating and storing the Intege
sum of the inputed Array r
4 s2 Variable for calculating and storing the Intege
sum of the inputed Array r
5 s3 Variable for calculating and storing the Intege
sum of the inputed Array r
6 a[][] Array for storing values Intege
r
24

String
7 Programs including String Manipulation
25

Ques 8) Write a program to accept any string and


convert the string into uppercase also count the
number of double letter sequence.
class uppercase
{
public static void main(String x)
{
int I, l, c=0;
char ch1, ch2;
x = x.toUpperCase()
l = x.length();
for(i=0 ; i<=l-2 ; i++)
{
ch1 = x.charAt(i);
ch2 = x.charAt(i+1);
if(ch1==ch2)
c++;
}
System.out.println(“No. of double lettered sequence
is”+c);
}
}
INPUT:- collage
26

OUTPUT:- 1

VARIABLE DESCRIPTION TABLE

S. VARI DESCRIPTION DATA


No ABLE TYPE
1 x Variable to input a String String
2 i Looping Variable Intege
r
3 l Variable to find the length of the Intege
inputed String r
4 c Counting Variable Intege
r
5 ch1 Variable to extract the character of the Char
inputed String
6 ch2 Variable to extract the character of the Char
inputed String
27

Ques 9) Write a program to enter a String and print the


String with UpperCase and LowerCase letters reversed.
Class String
{
public static void main(String x)
{
int I, l;
char ch;
String y = “”;
l = x.length();
for(i=0 ; i<=l-1 ; i++)
{
ch = x.charAt(i);
if(Character.isLowerCase(ch))
ch = Character.toUpperCase(ch);
else
ch = Character.toLowerCase(ch);
y = y+ch;
}
y = y.trim();
System.out.print(“New String is”+y);
}
}
28

INPUT:- PRAGYA
OUTPUT:- pragya

VARIABLE DESCRIPTION TABLE

S. VARIA DESCRIPTION DATAT


No BLE YPE
1 x Variable to input a string String
2 i Looping Variable Integer
3 l Variable to find the length of the Integer
inputed String
4 ch Variable to extract character from the char
inputed String
5 y Variable to input and print the String
converted String
29

Ques 10) Write a program to input a String and count


the number of vowels in it.
class vowels
{
public static void main(String x)
{
int i, l, c=0;
char ch;
String y = “AEIOUaeiou”;
l = x.length();
for(i=o ; i<=l-1 ; i++)
{
ch = x.charAt(i);
if(y.indexOf(ch)!=-1)
c++
}
System.out.println(“Number of Vowels are”+c);
}
}

INPUT:- Hello My Name Is Pragya Gupta


30

OUTPUT:- Number of vowels are 9

VARIABLE DESCRIPTION TABLE

S. VARI DESCRIPTION DATA


No ABLE TYPE
1 x Variable to input a String String
2 i Looping Variable Intege
r
3 l Variable to find the length of the Intege
inputed String r
4 c Counting Variable Intege
r
5 ch Variable to extract characters from the char
inputed String
6 y String to check whether the inputed String
String consists of vowels or not
31

Ques 11) Write a program to input a string and convert


the String into Piglatin Form. (i.e. after converting the
String into UpperCase place the first vowel of the
original word as the start of the new word along with
the remaining alphabets. The alphabets present before
the vowel being shifted towars the end followed by
“AY”.)
class abc
{
public static void main(String x)
{
int i, l, p, s1, s2, s3;
char ch;
String y = “AEIOUaeiou”;
l = x.length();
x = x.toUpperCase();
for(i=o ; i<=l-1 ; i++)
{
ch = x.charAt(i);
if(y.indexOf(ch)! = -1)
32

{
p = i;
break;
}
}
s1= x.substring(0;p);
s2 = x.substring(p);
s3 = s2 + s1 + “AY”;
System.out.print(“Piglatin form of the inputed String
is” + s3);
}
}

INPUT:- Trouble
OUTPUT:- OUBLETRAY

VARIABLE DESCRIPTION TABLE

S.N VARIAB DESCRIPTION DATATY


o LE PE
1 x Variable to input a String String
2 i Looping Variable Integer
3 l Variable to find the length of the Integer
inputed String
33

4 pVariable to store the position of Integer


first vowel of the inputed String
5 ch Variable to extract character from Char
the inputed String
6 y Variable to enter a String a String String
consisting of vowels for checking
vowels from the inputed String
7 s1 Variable to add the extracted Integer
characters from the inputed String
8 s2 Variable to add the extracted Integer
characters from the inputed String
9 s3 Variable to add the extracted Integer
characters from the inputed String
and print the new Piglatin String
formed
Ques 12) Write a program to input a String and print
only the palindrome words of the String.
class palindrome
{
public static void main(String x)
{
int i, l;
char ch;
String y = “”, z = “”;
x = x+””;
l = x.length();
for(i=0 ; i<=l-1 ; i++)
{
34

ch = x.charAt(i);
if(ch!=’’)
{
y = y=ch;
z = ch+z;
}
else
{
y = y.trim();
z = z.trim();
if(y.equalsIgnoreCase(z))
System.out.println(“Palindrome words of the
String are”+y);
y = “”;
z = “”;
}
}
}

INPUT:- Madam can speak Malayalam


OUPUT:- Palindrome words of the String are Madam
Malayalam
35

VARIABLE DESCRIPTION TABLE

S. VARI DESCRIPTION DATA


No ABLE TYPE
1 x Variable for inputing the String String
2 i Looping Variable Intege
r
3 l Variable to find the length of the Intege
inputed String r
4 ch Variable for extracting character from char
the inputed String
5 y Variable for inputing the extracted String
String from the original String
6 z Variable for inputing the extracted String
String from the original String

Ques 13) Write a program to accept a name and print


the name in the following manner.
INPUT:- Rajeev Kumar Singh
OUTPUT:- RKS
class string
{
public static void main(String x)
{
int i, l;
36

char ch;
String x = “”; y = “”;
x = x+””;
l = x.length();
for(i=0 ; i<=l-1 ; i++)
{
ch = x.charAt(i);
if(ch!=’’)
y = y+ch;
else
{
z = z+y.charAt(1);
y = “”;
}
System.out.println(“New string is”+z);
}
}

INPUT:- Pragya Gupta


OUTPUT:- New String is PG

VARIABLE DESCRIPTION TABLE


37

S. VARI DESCRIPTION DATA


No ABLE TYPE
1 x Varible for inputing the String String
2 i Looping Variable Intege
r
3 l Variable for finding the length of the Intege
String r
4 ch Variable for extracting characters from Char
the inputed String
5 y Variable for inputing the extracted String
String from the inputed String
6 z Variable to print the extracted String String

Ques 14) Write a program by considering the following


statement to change 26 to 15, January to August,
Republic to Independence and finally print the updated
String. “January 26 is celebrated as the Republic Day
of India”.
class abc
{
public static void main()
38

{
int i, l;
char ch;
String x = “January 26 is celebrated as the Republic Day
of India”;
String y = “”, z = “’;
x = x+””;
l = x.length();
for(i=0 ; i<=l-1 ; i++)
{
ch = x.charAt(i);
if(ch!=’’)
y = y+ch;
else
{
y = y.trim();
if(y.equalsIgnoreCase(“January”));
y = “August”;
else
if(y.equalsIgnoreCase(“Republic”));
y = “Independence”;
else
if(y.equals(“26”));
39

y = “15”;
z = z+y+””;
y = “”;
}
}
System.out.println(“The updated String is” + z);
}
}

INPUT:- “January 26 is celebrated as the Republic Day of


India”
OUTPUT:- “August 15 is celebrated as the Independence Day
of India”

VARIABLE DESCRIPTION TABLE

S. VARI DESCRIPTION DATA


No ABLE TYPE
1 i Looping Variable Intege
r
2 l Variable to find the length of the String Intege
r
3 ch Variable to extract characters char
4 x Variable to enter the String provided String
5 y Variable used to replace the String String
6 z Variable used to print the updated String
40

String
41

Primary
Programs
6 Programs including if else, pattern,
series, and general programs

Ques 15) Write a program to input a number and print


whether it is a prime number or not.
class prime
{
public static void main(int n)
{
int I, c=0;
for(i=1; i<=n; i++)
{
if(n%i==0)
c++;
}
if(c==2)
42

System.out.print(“Number is prime”);
else
System.out.print(“Number is not prime”);
}
}

INPUT:- 10
OUTPUT:- Number is not prime

VARIABLE DESCRIPTION TABLE

S. VARI DESCRIPTION DATA


No ABLE TYPE
1 n Variable to input number to check Intege
whether it is prime or not r
2 i Looping Variable Intege
r
3 c Counting Variable Intege
r
43

Ques 16) Write a program to display the following


pattern.
54321
5432
543
54
5
class pattern
{
Public static void main()
{
Int I, j;
For(i=1; i<=5; i++)
{
For(j=5; j>=1; j--)
{
44

System.out.print(j);
}
System.out.println();
}
}

VARIABLE DESCRIPTION TABLE

S. No VARIABLE DESCRIPTIO DATATYPE


N
1 i Looping Integer
Variable
2 j Looping Integer
Variable
45

Ques 17) Write a program to print the following


Fibonacci Series.
1, 2, 3, 5, 8, 13, _ _ _ _ _ _, 20 term
class fibonacci
{
public static void main()
{
int i, a=1, b=2, c;
System.out.print(a);
System.out.print(b);
for(i=1; i<=18: i++)
{
c = a+b;
46

System.out.print(c);
a=b;
b=c;
}
}
}

VARIABLE DESCRIPTION TABLE

S. VARI DESCRIPTION DATA


No ABLE TYPE
1 i Looping Variable Intege
r
2 a Variable for storing the first value of the Intege
series r
3 b Variable for storing the second value of Intege
the series r
4 c Variable for storing the sum of the two Intege
values and printing the succeeding r
value of the series
47

Ques 18) Write a program to input any number and


check whether the number is automorphic or not.
(Number should exist in the last of its square).
Class atomorphic
{
Public static void main(int n)
{
Int r, sq=n*n, p, c=0, a;
While(n!=0)
{
R=n%10;
48

N=n/10;
C++;
}
P = (int)Math.pow(10,c);
A = sq%p;
If(a==x)
System.out.print(“Number is Automorphic”);
Else
System.out.print(“Number is not Automorphic”);
}
}

INPUT:- 5
OUTPUT:- Number is Automorphic

VARIABLE DESCRIPTION TABLE

S. VARI DESCRIPTION DATA


No ABLE TYPE
1 n Variable to input any number to check Intege
whether it is automorphic or not r
2 sq Variable to store the square of the Intege
inputed number r
3 p Variable to calculate the power of the Intege
counted numbers r
49

4 c Counting Variable Intege


r
5 a Variable to store the number to check Intege
whether it is automorphic or not r
6 r Variable for extracting the remainder Intege
from the inputed number r

Ques 19) Write a program to enter any age and check


whether it is of a senior citizen or not.
class senior
{
public static void main(int age)
{
if(age>=60)
50

System.out.print(“Senior Citizen”);
else
System.out.print(“Not a Senior Citizen”);
}
}

INPUT:- 25
OUTPUT:- Not a Senior Citizen

VARIABLE DESCRIPTION TABLE

S. VARI DESCRIPTION DATA


No ABLE TYPE
1 int Variable to input age Intege
r

Ques 20) Write a program to input any number and


check it is a triple digit number or not.
Class triple
{
Public static void main(int n)
51

{
If(n>=100 && n<=999)
System.out.print(“Number is triple digit”);
Else
System.out.print(“Number is not triple digit”);
}
}

INPUT:- 1050
OUTPUT:- Number is not triple digit

VARIABLE DESCRIPTION TABLE

S. VARI DECRIPTION DATA


No ABLE TYPE
1 int Variable to input any number Intege
r

You might also like