khurshid alam


{ City } dhaka
< Country > bangladesh
* Profession * software developer
User No # 99422
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 # 5
Users Marked my Answers as Wrong # 2
Questions / { khurshid alam }
Questions Answers Category Views Company eMail




Answers / { khurshid alam }

Question { 6507 }

write a profram for selection sort

whats the error in it?


Answer

#include
using namespace std;
int main()
{
int i,t,j,min,n=0,m=0;
int a[6]={6,3,2,10,5,8};
//0 1 2 3 4 5
for(i=0;i<=13;i++)
{
m++;
min=i;
for(j=i+1;j<=5;j++)
{
if(a[j] min=j;
n++;
}
t=a[i];
a[i]=a[min];
a[min]=t;
}
cout<<"******Selection Sort*********"< for(i=0;i<=5;i++)
{
cout<<"a["< }

cout<<"Outer Loop Total count :"< cout<<"Inner Loop Total count :"<

return 0;
}

Is This Answer Correct ?    1 Yes 0 No

Question { BitWise, 45410 }

find second largest element in array w/o using sorting
techniques? use onle one for loop.


Answer

#include
using namespace std;
int main()
{
int i,a[]={121,104,105,205,6,25,80,77,120},max=0,second_max=0;
for(i=0;i<=8;i++)
{
if(a[i]>max)
{
max=a[i];
}
}
for(i=0;i<=8;i++)
{
if(a[i]!=max)
{
if(a[i]>second_max)
{
second_max=a[i];
}
}
}

cout<<"Second Highest Value:"< cout<<"Maximum Value:"< return 0;
}

Is This Answer Correct ?    4 Yes 2 No