Comp Programs
Comp Programs
CLASS :- XI – D
SUBJECT:- COMPUTER
ACKNOWLEDGMENT
I would like to express my special
thanks of gratitude to my
Computer teacher Siddharth sir as
well as our principal Manjit batra
who gave me the golden
opportunity to do this wonderful
project. Secondly, I would also like
to thank my parents and friends
who helped me a lot in finalizing
this project within the limited time
frame. Lastly, I like to thank all
my supporters who have
motivated me to fulfill their
project before the timeline.
INDEX
Sn. Topic Pg. no. remarks
1 Prg no 1 1
2 Prg no 2 2
3 Prg no 3 3
4 Prg no 4 4
5 Prg no 5 5
6 Prg no 6 6
7 Prg no 7 7
8 Prg no 8 8
9 Prg no 9 9
10 Prg no 10 10
Q-1 write a program to enter terms and make
Fibonacci series out of it.
import java.util.*;
class Fibonacci
{
int fibo(int n)
if(n<=1)
return (n);
else
return (fibo(n-1)+fibo(n-2));
int p;
System.out.println("Enter no of terms");
p=sc.nextInt();
int i;
System.out.print(obj1.fibo(i)+"\t");
void dectobin(int n)
if(n>0)
int k=n%2;
System.out.print(k);
dectobin(n/2);
System.out.println("Enter a number");
int p= sc.nextInt();
obj1.dectobin(p);
int a, b;
int c;
c=obj.a;
obj.a=obj.b;
obj.b=c;
obj1.a=3;
obj1.b=5;
swap(obj1);
int n;
n=sc.nextInt();
arr[i]=sc.nextInt();
pos=i;
small=arr[pos];
if(arr[j]<small)
small=arr[j];
pos=j;
temp=arr[i];
arr[i]=small;
arr[pos]=temp;
{ System.out.print(arr[i]+" \t");
} }
int arr[]={3,0,1,2,7,4};
int i, j, key;
key=arr[j];
i=j-1;
arr[i+1]=arr[i];
i--;
arr[i+1]=key;
System.out.print(arr[i]+"\t");
{ int mat1[][]={{3,5,1},{7,4,3},{0,3,1}};
int mat2[][]={{1,4,3},{0,2,5},{4,3,2}};
System.out.println("Matrix-1 is");
{ System.out.print(mat1[i][j]+" ");
System.out.println();
System.out.println("Matrix-2 is");
System.out.print(mat2[i][j]+" ");
System.out.println();
System.out.println("Matrix-2 is");
int c=mat1[i][j]+mat2[i][j];
System.out.print(c+" ");
c=0;
System.out.println();
System.out.println("Enter a sentence");
str=sc.nextLine();
StringBuffer s2;
while(token1.hasMoreTokens())
s1=token1.nextToken();
s2=new StringBuffer(s1);
s2=s2.reverse();
if(s1.equals(String.valueOf(s2)))
System.out.println(s1);
if(q==0)
return (p);
else
return (gcd(q,p%q));
int m, n;
m=sc.nextInt();
n=sc.nextInt();
class PalindromicPrime
int n;
int x=n;
if(n%i==0)
c++;
while(x>0)
p=x%10;
k=k*10+p;
x/=10;
System.out.println(n+"\t");
if (n == 1 || n == 7)
return true;
int sum = n, x = n;
while(sum > 9) {
sum = 0;
sum += d*d;
x/=10;
if (sum == 1)
return true;
x = sum;
if(sum == 7)
return true;
return false;
int n = 13;
if (isHappynumber(n))
else