venkataramana


{ City } srikakulam
< Country > india
* Profession * student
User No # 35971
Total Questions Posted # 0
Total Answers Posted # 2

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 4
Users Marked my Answers as Wrong # 0
Questions / { venkataramana }
Questions Answers Category Views Company eMail




Answers / { venkataramana }

Question { Intel, 3737 }

1. Duplicate the even numbers. -1

Sample I/O

Array1:- 4,2,24,3,22

Updated Array:- 4,4,2,2,24,24,3,22,22
2. Reverse the array in a region - 1

Sample I/O

Array1:- 4,2,24,3,22,41,21

Enter Region:- 2,5

Update Array:-4,41,22,3,24,2,21


3. Store first the even digits in an array and then odd
digits in same array -2

Sample I/O

Array1:- 4,2,24,3,22,41,21

Array 2:- 4,2,2,4,2,2,4,2,3,1,1
4. Store the count of the digits in all numbers in an array
and print the count. -2

Sample I/O

Array1:- 4,2,9,3,7,41,28

Array 2:- 0,1,1,1,2,0,0,1,1,1

1-1;2-1;3-1;4-2;7-1;8-1;9-1
5. Store all palindrome numbers in to another array -2

Sample I/O

Array1:- 4,22,9,313,7,141,28

Array 2:- 4,22,9,313,141


6. Arrange the array in such a way that odd numbers come
first and then even numbers -1

Sample I/O

Array1:- 4,22,9,313,7,141,28

Update Array1:- 9,313,7,141,4,22,28
7. Store into another array by inserting it in the right
place - 2

Sample I/O

Array1:- 4,22,9,313,7,141,28

Array2:- 4 /4,22 /4,9,22 /4,9,22 ,313 /4,7,9,22 ,313
/4,7,9,22 ,141,313 /

4,7,9,22,28 ,141,313
8. Merge two sorted arrays in a sorted fashion - 3

Sample I/O

Array 1:- 3,6,7,9,11,16

Array 2:- 1,2,5,7,20

Array 3:- 1,2,3,5,6,7,9,11,16,20

9. Upadte the array so that an array element is followed by
its revere - 1

Sample I/O

Array 1:- 13,63,74,9,11,16

Updated Array 1:- 13,31,63,36,74,47,9,9,11,11,16,16

10.Spread the digits of the array in the same array. -1

Sample I/O

Array 1:- 13,63,74,9,11,16

Updated Array 1:-1,3,6,3,74,9,1,1,1,6

11.Shift the boundary of array to have only 2 digit numbers.

Sample I/O

Array 1:- 139,643,74,9,101,126

Updated Array 1:- 13,96,43,74,91,11,26

12.Print the largest occuring digit in an array of N numbers.

Sample I/O

Array 1:- 13,63,74,9,11,16

1 occurs most.


Answer

1///Program to Duplicate the even numbers
#include
using namespace std;
main()
{
int n,i,j;
cout<<"How many numbers do u want to enter:";
cin>>n;
int a[2*n];
if(n>0)
{
cout<<"Enter the numbers:";
for(i=0;i cin>>a[i];
cout<<"\n The original array is :";
for(i=0;i cout<<"\t"< for(i=0;i<=n;i++)
{
if(a[i]%2==0)
{
n++;
for(j=n;j>i;j--)
{
a[j]=a[j-1];
}

i++;
a[i]=a[i-1];
}
}
cout<<"\n The updated array is:";
for(i=0;i {
cout<<"\t"< }
}
else
cout<<"\n Invalid entry";
}
2.// Program to Reverse the array in the region
#include
using namespace std;
main()
{
int n,i,x,y,t;
cout<<"How many numbers do u want to enter:";
cin>>n;
int a[n];
if(n>0)
{
cout<<"Enter the numbers:";
for(i=1;i<=n;i++)
cin>>a[i];
cout<<"Enter the positions for which the
array to be reversed from left to right:";
cin>>x>>y;
cout<<"\n the original array is:";
for(i=0;i cout< if(x>y)
{
t=x;
x=y;
y=t;
}
if(x<1 || y>n)
cout<<"\n Invalid entry";
else
{
for(i=1;i {
cout<<"\t"< }
for(i=y;i>=x;i--)
{
cout<<"\t"< }
for(i=y+1;i<=n;i++)
{
cout<<"\t"< }
}
}

else
cout<<"\n Invalid entry";
}

//Reverse the array in the region
#include
using namespace std;
main()
{
int n,i,x,y,t;
cout<<"How many numbers do u want to enter:";
cin>>n;
int a[n];
if(n>0)
{
cout<<"Enter the numbers:";
for(i=1;i<=n;i++)
cin>>a[i];
cout<<"Enter the positions for which the
array to be reversed from left to right:";
cin>>x>>y;
cout<<"\n the original array is:";
for(i=0;i cout< if(x>y)
{
t=x;
x=y;
y=t;
}
if(x<1 || y>n)
cout<<"\n Invalid entry";
else
{
for(i=1;i {
cout<<"\t"< }
for(i=y;i>=x;i--)
{
cout<<"\t"< }
for(i=y+1;i<=n;i++)
{
cout<<"\t"< }
}
}

else
cout<<"\n Invalid entry";
}
3.//Store the count of the digits in all numbers in an array
and print the count
#include
using namespace std;
main()
{
int
n,i,d,count0=0,count1=0,count2=0,count3=0,count4=0,count5=0,count6=0,count7=0,count8=0,count9=0;
cout<<"How many numbers do u want to enter:";
cin>>n;
int a[n];
int count[10];
if(n>0)
{
cout<<"\n Enter the numbers:\n";
for(i=0;i cin>>a[i];
cout<<"\n The original array is:";
for(i=0;i cout<<"\t"< for(i=0;i {

while(a[i]!=0)
{

d=a[i]%10;
if(d==0)
count0++;
if(d==1)
count1++;
if(d==2)
count2++;
if(d==3)
count3++;
if(d==4)
count4++;
if(d==5)
count5++;
if(d==6)
count6++;
if(d==7)
count7++;
if(d==8)
count8++;
if(d==9)
count9++;
a[i]=a[i]/10;
}
}
count[0]=count0;
count[1]=count1;
count[2]=count2;
count[3]=count3;
count[4]=count4;
count[5]=count5;
count[6]=count6;
count[7]=count7;
count[8]=count8;
count[9]=count9;
for(i=0;i<10;i++)
{
if(count[i]!=0)
cout<<"\n "< }


}
else
cout<<"\n Invalid entry";
}

4. ///Print the largest occuring digit in an array of n numbers
#include
using namespace std;
main()
{
int
n,i,j,d,t,count0=0,count1=0,count2=0,count3=0,count4=0,count5=0,count6=0,count7=0,count8=0,count9=0;
cout<<"\n Enter the size of the array:";
cin>>n;
int a[n];
int b[10];
int e[10];
if(n>0)
{
cout<<"\n Enter the elements into the array:";
for(i=0;i cin>>a[i];
for(i=0;i {
while(a[i]!=0)
{
d=a[i]%10;
if(d==0)
count0++;
if(d==1)
count1++;
if(d==2)
count2++;
if(d==3)
count3++;
if(d==4)
count4++;
if(d==5)
count5++;
if(d==6)
count6++;
if(d==7)
count7++;
if(d==8)
count8++;
if(d==9)
count9++;
a[i]=a[i]/10;
}
}
b[0]=count0;
b[1]=count1;
b[2]=count2;
b[3]=count3;
b[4]=count4;
b[5]=count5;
b[6]=count6;
b[7]=count7;
b[8]=count8;
b[9]=count9;
for(i=0;i<10;i++)
{
e[i]=b[i];
}
for(i=0;i<10;i++)
{
for(j=i;j<10;j++)
{
if(b[i] {
t=b[i];
b[i]=b[j];
b[j]=t;
}
}
}
for(i=0;i<10;i++)
{
if(e[i]==b[0])
cout<<"\n The largest occuring digit is:"< }
}
else
cout<<"\n Invalid entry";
}

5.//Arrange the array insuch a way that odd numbers come
first and then the even numbers
#include
using namespace std;
main()
{
int n,i,j,t,k;
cout<<"\n Enter the size of the array:";
cin>>n;
int a[n];
if(n>0)

{
cout<<"\n Enter the elements into the array:";
for(i=0;i cin>>a[i];
cout<<"\n The original array is:";
for(i=0;i cout<<"\t"< for(i=0;i {
if(a[i]%2==0)
{
for(j=i+1;j {

if(a[j]%2!=0)
{
t=a[j];
a[j]=a[i];
a[i]=t;
i++;
break;
}
for(k=i;k>0;k--)
{
a[k]=a[k-1];
}


}

}

}
cout<<"\n the updated array is:";
for(i=0;i cout<<"\t"< }
else
cout<<"\n Invalid entry";
}
6.//Spread the digits of the array in the same array
#include
using namespace std;
main()
{
int n,i,j;
cout<<"\n Enter the size of the array:";
cin>>n;
int a[n];
if(n>0)
{
cout<<"\n Enter the numbers into the array:";
for(i=0;i cin>>a[i];
cout<<"\n The original array is:";
for(i=0;i cout<<"\t"< for(i=0;i {
if(a[i]<0)
a[i]=a[i]*-1;
if(a[i]<10)
continue;
while(a[i]>9)
{
n++;
r=a[i]%10;
for(j=n-1;j>i;j--)
{
a[j]=a[j-1];
}
a[i+1]=r;
a[i]=a[i]/10;
}
}
cout<<"\n the updated array is:";
for(i=0;i {
cout<<"\t"< }
}
else
cout<<"\n Invalid entry";
}

7.//Update the array so that an array element is followed by
its reverse
#include
using namespace std;
main()
{
int n,i,p,rev,d,j;
cout<<"\n Enter the size of the array:";
cin>>n;
int a[2*n];
if(n>0)
{
cout<<"\n Enter the numbers into the array:";
for(i=0;i cin>>a[i];
cout<<"\n The original array is:";
for(i=0;i cout<<"\t"< for(i=0;i {

rev=0;
p=a[i];
while(p!=0)
{

d=p%10;
rev=(rev*10)+d;
p=p/10;
}
for(j=n;j>i;j--)
{
a[j]=a[j-1];
}
n++;
i++;
a[i]=rev;
}
cout<<"\n The updated array is:";
for(i=0;i {
cout<<"\t"< }
}
else
cout<<"\n Invalid entry";
}
8.//Store all palindrome numbers into another array
#include
using namespace std;
main()
{
int n,i,j,rev,r,num,m,count=0;
cout<<"How many numbers do u want to enter:";
cin>>n;
int a[n];
int b[n];
if(n>0)
{
cout<<"\n Enter the numbers:\n";
for(i=0;i cin>>a[i];
cout<<"\n The original array is:";
for(i=0;i
cout<<"\t"< cout<<"\n The updated array is:";
for(i=0;i {
rev=0;
num=a[i];
while(a[i]!=0)
{
r=a[i]%10;
rev=(rev*10)+r;
a[i]=a[i]/10;
}
if(num==rev)
{
b[count]=num;
count++;
}
}

for(j=0;j cout<<"\t"<
}
else
cout<<"\n Invalid entry";
}
9.//Merge two stored array in a sorted fashion
#include
using namespace std;
main()
{
int arr1[20],arr2[20],arr3[40],arr[40],temp;
int i,j,k,t;
int max1,max2;
cout<<"Enter number of elements in the list 1:";
cin>>max1;
cout<<"\n Take the elements in sorted order:\n";
for(i=0;i {
cout<<"Enter element"<<" "< cin>>arr1[i];
}

cout<<"\n Enter number of elements in the list 2:";
cin>>max2;
cout<<"\n Take the elements in sorted order:\n";
for(j=0;j {
cout<<"Enter element"<<" "< cin>>arr2[j];
}

i=0;
j=0;
k=0;
while((i {
if(arr1[i] arr3[k++]=arr1[i++];
else
arr3[k++]=arr2[j++];


}
while(i arr3[k++]=arr1[i++];
while(j arr3[k++]=arr2[j++];

cout<<"\n List 1:";
for(i=0;i cout<<"\t"< cout<<"\n List 2:";
for(j=0;j cout<<"\t"< cout<<"\n Merged list:";
for(k=0;k<(i+j);k++)
{
for(t=0;t<(i+j);t++)
{
if(arr3[k] {
temp=arr3[k];
arr3[k]=arr3[t];
arr3[t]=temp;
}
}
}
for(t=0;t<(i+j);t++)
{
if(arr3[t]!=arr3[t+1])

cout<<"\t"<
}
cout<<"\n";
}











Is This Answer Correct ?    2 Yes 0 No

Question { Intel, 3737 }

1. Duplicate the even numbers. -1

Sample I/O

Array1:- 4,2,24,3,22

Updated Array:- 4,4,2,2,24,24,3,22,22
2. Reverse the array in a region - 1

Sample I/O

Array1:- 4,2,24,3,22,41,21

Enter Region:- 2,5

Update Array:-4,41,22,3,24,2,21


3. Store first the even digits in an array and then odd
digits in same array -2

Sample I/O

Array1:- 4,2,24,3,22,41,21

Array 2:- 4,2,2,4,2,2,4,2,3,1,1
4. Store the count of the digits in all numbers in an array
and print the count. -2

Sample I/O

Array1:- 4,2,9,3,7,41,28

Array 2:- 0,1,1,1,2,0,0,1,1,1

1-1;2-1;3-1;4-2;7-1;8-1;9-1
5. Store all palindrome numbers in to another array -2

Sample I/O

Array1:- 4,22,9,313,7,141,28

Array 2:- 4,22,9,313,141


6. Arrange the array in such a way that odd numbers come
first and then even numbers -1

Sample I/O

Array1:- 4,22,9,313,7,141,28

Update Array1:- 9,313,7,141,4,22,28
7. Store into another array by inserting it in the right
place - 2

Sample I/O

Array1:- 4,22,9,313,7,141,28

Array2:- 4 /4,22 /4,9,22 /4,9,22 ,313 /4,7,9,22 ,313
/4,7,9,22 ,141,313 /

4,7,9,22,28 ,141,313
8. Merge two sorted arrays in a sorted fashion - 3

Sample I/O

Array 1:- 3,6,7,9,11,16

Array 2:- 1,2,5,7,20

Array 3:- 1,2,3,5,6,7,9,11,16,20

9. Upadte the array so that an array element is followed by
its revere - 1

Sample I/O

Array 1:- 13,63,74,9,11,16

Updated Array 1:- 13,31,63,36,74,47,9,9,11,11,16,16

10.Spread the digits of the array in the same array. -1

Sample I/O

Array 1:- 13,63,74,9,11,16

Updated Array 1:-1,3,6,3,74,9,1,1,1,6

11.Shift the boundary of array to have only 2 digit numbers.

Sample I/O

Array 1:- 139,643,74,9,101,126

Updated Array 1:- 13,96,43,74,91,11,26

12.Print the largest occuring digit in an array of N numbers.

Sample I/O

Array 1:- 13,63,74,9,11,16

1 occurs most.


Answer

1///Program to Duplicate the even numbers
#include
using namespace std;
main()
{
int n,i,j;
cout<<"How many numbers do u want to enter:";
cin>>n;
int a[2*n];
if(n>0)
{
cout<<"Enter the numbers:";
for(i=0;i cin>>a[i];
cout<<"\n The original array is :";
for(i=0;i cout<<"\t"< for(i=0;i<=n;i++)
{
if(a[i]%2==0)
{
n++;
for(j=n;j>i;j--)
{
a[j]=a[j-1];
}

i++;
a[i]=a[i-1];
}
}
cout<<"\n The updated array is:";
for(i=0;i {
cout<<"\t"< }
}
else
cout<<"\n Invalid entry";
}
2.// Program to Reverse the array in the region
#include
using namespace std;
main()
{
int n,i,x,y,t;
cout<<"How many numbers do u want to enter:";
cin>>n;
int a[n];
if(n>0)
{
cout<<"Enter the numbers:";
for(i=1;i<=n;i++)
cin>>a[i];
cout<<"Enter the positions for which the
array to be reversed from left to right:";
cin>>x>>y;
cout<<"\n the original array is:";
for(i=0;i cout< if(x>y)
{
t=x;
x=y;
y=t;
}
if(x<1 || y>n)
cout<<"\n Invalid entry";
else
{
for(i=1;i {
cout<<"\t"< }
for(i=y;i>=x;i--)
{
cout<<"\t"< }
for(i=y+1;i<=n;i++)
{
cout<<"\t"< }
}
}

else
cout<<"\n Invalid entry";
}

//Reverse the array in the region
#include
using namespace std;
main()
{
int n,i,x,y,t;
cout<<"How many numbers do u want to enter:";
cin>>n;
int a[n];
if(n>0)
{
cout<<"Enter the numbers:";
for(i=1;i<=n;i++)
cin>>a[i];
cout<<"Enter the positions for which the
array to be reversed from left to right:";
cin>>x>>y;
cout<<"\n the original array is:";
for(i=0;i cout< if(x>y)
{
t=x;
x=y;
y=t;
}
if(x<1 || y>n)
cout<<"\n Invalid entry";
else
{
for(i=1;i {
cout<<"\t"< }
for(i=y;i>=x;i--)
{
cout<<"\t"< }
for(i=y+1;i<=n;i++)
{
cout<<"\t"< }
}
}

else
cout<<"\n Invalid entry";
}
3.//Store the count of the digits in all numbers in an array
and print the count
#include
using namespace std;
main()
{
int
n,i,d,count0=0,count1=0,count2=0,count3=0,count4=0,count5=0,count6=0,count7=0,count8=0,count9=0;
cout<<"How many numbers do u want to enter:";
cin>>n;
int a[n];
int count[10];
if(n>0)
{
cout<<"\n Enter the numbers:\n";
for(i=0;i cin>>a[i];
cout<<"\n The original array is:";
for(i=0;i cout<<"\t"< for(i=0;i {

while(a[i]!=0)
{

d=a[i]%10;
if(d==0)
count0++;
if(d==1)
count1++;
if(d==2)
count2++;
if(d==3)
count3++;
if(d==4)
count4++;
if(d==5)
count5++;
if(d==6)
count6++;
if(d==7)
count7++;
if(d==8)
count8++;
if(d==9)
count9++;
a[i]=a[i]/10;
}
}
count[0]=count0;
count[1]=count1;
count[2]=count2;
count[3]=count3;
count[4]=count4;
count[5]=count5;
count[6]=count6;
count[7]=count7;
count[8]=count8;
count[9]=count9;
for(i=0;i<10;i++)
{
if(count[i]!=0)
cout<<"\n "< }


}
else
cout<<"\n Invalid entry";
}

4. ///Print the largest occuring digit in an array of n numbers
#include
using namespace std;
main()
{
int
n,i,j,d,t,count0=0,count1=0,count2=0,count3=0,count4=0,count5=0,count6=0,count7=0,count8=0,count9=0;
cout<<"\n Enter the size of the array:";
cin>>n;
int a[n];
int b[10];
int e[10];
if(n>0)
{
cout<<"\n Enter the elements into the array:";
for(i=0;i cin>>a[i];
for(i=0;i {
while(a[i]!=0)
{
d=a[i]%10;
if(d==0)
count0++;
if(d==1)
count1++;
if(d==2)
count2++;
if(d==3)
count3++;
if(d==4)
count4++;
if(d==5)
count5++;
if(d==6)
count6++;
if(d==7)
count7++;
if(d==8)
count8++;
if(d==9)
count9++;
a[i]=a[i]/10;
}
}
b[0]=count0;
b[1]=count1;
b[2]=count2;
b[3]=count3;
b[4]=count4;
b[5]=count5;
b[6]=count6;
b[7]=count7;
b[8]=count8;
b[9]=count9;
for(i=0;i<10;i++)
{
e[i]=b[i];
}
for(i=0;i<10;i++)
{
for(j=i;j<10;j++)
{
if(b[i] {
t=b[i];
b[i]=b[j];
b[j]=t;
}
}
}
for(i=0;i<10;i++)
{
if(e[i]==b[0])
cout<<"\n The largest occuring digit is:"< }
}
else
cout<<"\n Invalid entry";
}

5.//Arrange the array insuch a way that odd numbers come
first and then the even numbers
#include
using namespace std;
main()
{
int n,i,j,t,k;
cout<<"\n Enter the size of the array:";
cin>>n;
int a[n];
if(n>0)

{
cout<<"\n Enter the elements into the array:";
for(i=0;i cin>>a[i];
cout<<"\n The original array is:";
for(i=0;i cout<<"\t"< for(i=0;i {
if(a[i]%2==0)
{
for(j=i+1;j {

if(a[j]%2!=0)
{
t=a[j];
a[j]=a[i];
a[i]=t;
i++;
break;
}
for(k=i;k>0;k--)
{
a[k]=a[k-1];
}


}

}

}
cout<<"\n the updated array is:";
for(i=0;i cout<<"\t"< }
else
cout<<"\n Invalid entry";
}
6.//Spread the digits of the array in the same array
#include
using namespace std;
main()
{
int n,i,j;
cout<<"\n Enter the size of the array:";
cin>>n;
int a[n];
if(n>0)
{
cout<<"\n Enter the numbers into the array:";
for(i=0;i cin>>a[i];
cout<<"\n The original array is:";
for(i=0;i cout<<"\t"< for(i=0;i {
if(a[i]<0)
a[i]=a[i]*-1;
if(a[i]<10)
continue;
while(a[i]>9)
{
n++;
r=a[i]%10;
for(j=n-1;j>i;j--)
{
a[j]=a[j-1];
}
a[i+1]=r;
a[i]=a[i]/10;
}
}
cout<<"\n the updated array is:";
for(i=0;i {
cout<<"\t"< }
}
else
cout<<"\n Invalid entry";
}

7.//Update the array so that an array element is followed by
its reverse
#include
using namespace std;
main()
{
int n,i,p,rev,d,j;
cout<<"\n Enter the size of the array:";
cin>>n;
int a[2*n];
if(n>0)
{
cout<<"\n Enter the numbers into the array:";
for(i=0;i cin>>a[i];
cout<<"\n The original array is:";
for(i=0;i cout<<"\t"< for(i=0;i {

rev=0;
p=a[i];
while(p!=0)
{

d=p%10;
rev=(rev*10)+d;
p=p/10;
}
for(j=n;j>i;j--)
{
a[j]=a[j-1];
}
n++;
i++;
a[i]=rev;
}
cout<<"\n The updated array is:";
for(i=0;i {
cout<<"\t"< }
}
else
cout<<"\n Invalid entry";
}
8.//Store all palindrome numbers into another array
#include
using namespace std;
main()
{
int n,i,j,rev,r,num,m,count=0;
cout<<"How many numbers do u want to enter:";
cin>>n;
int a[n];
int b[n];
if(n>0)
{
cout<<"\n Enter the numbers:\n";
for(i=0;i cin>>a[i];
cout<<"\n The original array is:";
for(i=0;i
cout<<"\t"< cout<<"\n The updated array is:";
for(i=0;i {
rev=0;
num=a[i];
while(a[i]!=0)
{
r=a[i]%10;
rev=(rev*10)+r;
a[i]=a[i]/10;
}
if(num==rev)
{
b[count]=num;
count++;
}
}

for(j=0;j cout<<"\t"<
}
else
cout<<"\n Invalid entry";
}
9.//Merge two stored array in a sorted fashion
#include
using namespace std;
main()
{
int arr1[20],arr2[20],arr3[40],arr[40],temp;
int i,j,k,t;
int max1,max2;
cout<<"Enter number of elements in the list 1:";
cin>>max1;
cout<<"\n Take the elements in sorted order:\n";
for(i=0;i {
cout<<"Enter element"<<" "< cin>>arr1[i];
}

cout<<"\n Enter number of elements in the list 2:";
cin>>max2;
cout<<"\n Take the elements in sorted order:\n";
for(j=0;j {
cout<<"Enter element"<<" "< cin>>arr2[j];
}

i=0;
j=0;
k=0;
while((i {
if(arr1[i] arr3[k++]=arr1[i++];
else
arr3[k++]=arr2[j++];


}
while(i arr3[k++]=arr1[i++];
while(j arr3[k++]=arr2[j++];

cout<<"\n List 1:";
for(i=0;i cout<<"\t"< cout<<"\n List 2:";
for(j=0;j cout<<"\t"< cout<<"\n Merged list:";
for(k=0;k<(i+j);k++)
{
for(t=0;t<(i+j);t++)
{
if(arr3[k] {
temp=arr3[k];
arr3[k]=arr3[t];
arr3[t]=temp;
}
}
}
for(t=0;t<(i+j);t++)
{
if(arr3[t]!=arr3[t+1])

cout<<"\t"<
}
cout<<"\n";
}











Is This Answer Correct ?    2 Yes 0 No