Note 1
##### Take Note:

Take a note while surfing.

##### Note With Ink

Give your Note a Colorful Tag.

##### Easy to Access

Stay on same information and in Sync wherever you are.

Note 2
##### Take Note:

Organize your information,It may take Shape.

##### Easy to Access

Easy to pull up your content from anywhere anytime.

Note 3
##### Take Note:

Don't Let information to miss,Because it take shape

##### Note With Ink

Simple an Easy Way to take a note.

##### Easy to Access

Get the same in next visit.

Take Quiz (Monsoon) Beta Version !!
Do You have Qs. in your Mind ??? Ask it as Qs. or MCQs or create it as polling Live Now !!

291 / 348

Write a program to generate the next number (ex:143=1^2+4^2+3^2=26)repeat this sequence till you get 1 or 4.

Input : NA

Output : NA

|  Stack | | | |  Fresher
 No Discussion on this question yet!

Tags:Virtusa

292 / 348

Write a program to eliminate duplicates in a sorted array.

Input : NA

Output : NA

|  Array | | | |  Fresher
 
public class Duplicates
{
public int eliminateDuplicates(int a[], int n)
{
if (n == 0 || n == 1)   //if the array is empty or if it contains only 1 element.
return n;
int j = 0;
for (int i = 0; i < n-1; i++)
{
//If ith element is not equal to (i+1)th element, then store the ith element.
if (a[i] != a[i+1])
{
a[j++] = a[i];
}
}
a[j++] = a[n-1]; //Also storig the last element.
return j;
}
public static void main(String[] args)
{
Duplicates ob=new Duplicates();
int a[] = {1, 2, 2, 3, 4, 4, 4, 5, 5};    //sorted array
int n = a.length;
n = ob.eliminateDuplicates(a, n);
for (int i=0; i<n; i++)
System.out.print(a[i]+" ");
}
}



Tags:Virtusa

293 / 348

Write a recursive function to print 100 Fibonacci numbers.

Input : NA

Output : NA

|  Basics | | | |  Fresher
 
public class Fibonacci
{
static int a=0,b=1,c=0;
public void fibonacci(int num)
{
if(num>0)
{
c=a+b;
a=b;
b=c;
System.out.print(" "+c);
fibonacci(num-1);
}
}
public static void main(String args[])
{
Fibonacci ob=new Fibonacci();
int num=100;
System.out.print(a+" "+b);  //printing 0 and 1
ob.fibonacci(num-2);        //n-2 because 2 numbers are already printed
}
}



Tags:Virtusa

294 / 348

Write a program to Print the Pascal triangle.

Input : NA

Output : NA

|  Basics | | | |  Fresher
 
<pre><tt>#include<stdio.h>int main(){Â  int i,j,k,s=1,n=5;Â  for(i=0;i<n;i  )Â  {Â  Â  for(k=1;k<=n-i;k  )Â  Â  printf(" ");Â  Â  for(j=0;j<=i;j  )Â  Â  {Â  Â  Â  if(j==0||i==0)Â  Â  Â  Â  s=1;Â  Â  Â  elseÂ  Â  Â  Â  s=s*(i-j 1)/j;Â  Â  Â  printf("-",s);Â  Â  }Â  Â  printf("\n");Â  }}</tt></pre>


Tags:Virtusa

295 / 348

Write a program to print the angle between the pointers in the wall clock when time is taken as input.

Input : NA

Output : NA

|  Basics | | | |  Fresher
 No Discussion on this question yet!

Tags:Virtusa

296 / 348

Can trees be implemented using arrays? If so, write the program for same.

Input : NA

Output : NA

|  Trees | | | |  Fresher
 No Discussion on this question yet!

Tags:Virtusa

297 / 348

Write a Swapping program using XOR operation.

Input : NA

Output : NA

|  Basics | | | |  Fresher
 
import java.util.*;
public class SwapUsingXor
{
public static void main(String []args)
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter 2 numbers: ");
int a=sc.nextInt();
int b=sc.nextInt();
System.out.println("Before swapping a= "+a+" || b= "+b);
a=a^b;
b=a^b;
a=a^b;
System.out.println("After swapping a= "+a+" || b= "+b);
}
}


Tags:Virtusa

298 / 348

Write a program of Circular Queue.

Input : NA

Output : NA

|  Stack | | | |  Fresher
 No Discussion on this question yet!

Tags:Virtusa

299 / 348

Write a function which returns a sub string in the string 'Sigma' (character given) which starts with 'Alpha' and ends with 'Theta'.

Input : NA

Output : NA

|  Strings | | | |  Fresher
 
import java.util.*;
public class Substring
{
public static void main(String args[])
{
String str="";
Scanner sc=new Scanner(System.in);
System.out.println("Enter the string: ");
String sigma=sc.nextLine();
int len=sigma.length();
System.out.println("Enter the beginIndex: ");
int alpha=sc.nextInt();
System.out.println("Enter the endIndex: ");
int theta=sc.nextInt();
if((alpha>=0 && theta<=len) && (alpha<theta))
str=sigma.substring(alpha,theta);
System.out.println("Substring is: "+str);
}
}



Tags:Virtusa

300 / 348

Write a program to delete the duplicates in an array of student list.

Input : NA

Output : NA

|  Array | | | |  Fresher
 No Discussion on this question yet!