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
I'm working with a crosstab in cognos now. Page 1 contains crosstab Page 2 contains list Fact - Revenue Dimension - Product line, Year If I click on the revenue (cell value) it should goto the particular record in another list which is located in a separate page. However, the fact could not be bookmarked. I don't know why. Do you have suggestions? Thanks in advance.
DataStage 7.5 & DataStage 8.5 :Which Oracle Database version is supported as target datasource?
what do u mean by altkey?
I have given ielts exam and i got 5.5 bands and i also got three I-20s from the US universities, so my ielts score will interrupt my visa or not? I want to confirm it.
Do you personally involved with Major incident process ? If yes, how do you manage it in your present organization ? explain with real scenario !
I didn't see any category for Project Management. What are the activities, documents; how to plan, schedule and monitor tasks, statuses, people...?
How retrive the deleted file frm UAT by doing migration in SAP BO 4.0
Is any one has SAP GTS( Global Trade Services)Reading and Exercise material. If so, please e-mail me.
What id the meaning of MIS ? MIS nasure, charactersitcs, purpose ? how can the leanr about them ?
When you are given to develop a computer based information system for banking, how do you write the SDLC diagram?. Explain the five phases with respect to banking.
what is erp manufacturing perspective??
what is the difference between BI and pervasive BI?
What are the practices you follow for closing a project and meeting the conditions required to establish closure?
could you provide me the information regarding UNIVESAL WORK LIST(UWL)?this question is regarding SAP EP.
what is variable?