Write a C Program to declare an array for 2 0 floats.
Accept the values from the user
sort the two arrays in descending order. Merge the two
arrays into a new array and display
the new array.

Answer Posted / irfan fazli (trying to help tw

/* Build your program around this..... */
main()
{
int a, b, c;
float t;

/*declare an array for 2 0 floats*/
float aList1[20];
float aList2[20];
float aList[40];

/* Accept the values from the user */
/* 1 */
for (c=0; c++;c <20)
scanf("%f", alist1+c);
/* 2 */
for (c=0; c++;c <20)
scanf("%f", alist2+c);

/* sort the two arrays in descending order */
/* 1 */
for (a=0; a++; a <20)
for (b=a+1; b++; b <20)
if (aList1[a] < aList1[b])
{
t = aList1[a] ;
aList1[a] aList1[b] ;
aList1[b] =t ;
}

/* 2 */
for (a=0; a++; a <20)
for (b=a+1; b++; b <20)
if (aList2[a] < aList2[b])
{
t = aList2[a] ;
aList2[a] aList2[b] ;
aList2[b] =t ;
}

/* Merge the two arrays into a new array */
c=0;
while (a < 20 || b < 20)
if (aList1[a] > aList2[b])
aList[c++] = aList[a++]
else
aList[c++] = aList[b++]

/* display the new array */
for (c=0; c++;c <40)
printf("%f, ", alist1[c]);
printf("\n");
}

Is This Answer Correct ?    14 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

cost accounting is a tool for dicission making expline

1670


Why general ledger accounts require "post automatically" setting in SAP??

1512


what four attribut in business case?

1979


7. (a) How do you implement internal controls in IT systems? (b) How to design internal controls over financial reporting, when financial reporting is performed totally from the software application? Explain briefly the major points. (c) What are the additional controls needed, when the software interfaces are webbased? Explain the materiality of the payroll processing functions to be performed by webinterfaces from the control perspective.

1917


Describe some of your most important career accomplishments

4258






What type of questions will be asked in Bank of India Computer Officers (IT) exam? Will someone provide me the sample paper of Bank of India Computer Officer (IT) exam?

2042


what is variable?

2043


What unique experience or qualifications separate you from other candidates?

7163


what is erp manufacturing perspective??

3918


How we do trimming in Solaris and how to prevent the /var from become disk full.

1508


This is related to Medical Transcription field. As i am above to get the call from the company, I just want to prepare for the interview for the post of Auditor and I have just never faced the telephonic interview and very rare attempted the interview in companies as I have worked for very few companied.

1983


Why are you interested in this position? Our company?

3768


I didn't see any category for Project Management. What are the activities, documents; how to plan, schedule and monitor tasks, statuses, people...?

1719


what do you mean by "Closures with help of Top Management and Colleagues"

2026


What are the Roles and Responsibilities of BDM in IT Industry ? And Tell me some thing about about IT industries

3898