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
hi i am doing cause study about Enterprising young IT Entrepreneur who has recently started a small business running web hosting services for SME (Small to Medium Enterprise). You frequently need to meet (potential) clients to sell your services to them. You do so with presentations and demonstrations of your products. You will also want to install certain development software for your software development projects. So what software to use? need a server? what types of hosting should i use?
What are the Roles and Responsibilities of BDM in IT Industry ? And Tell me some thing about about IT industries
What change management processes have you used to ensure that change is introduced properly?
If you are a team lead in any IT company, and two employees are under your supervision. If one employee is good and other cannot behave professionally and personally, then how will you handle this situation?
i was looking for a general example for time management and how everything is linked together so i can have a complete picture. when i say link i mean with OM and PA and work schedule,planned working time, other relevant infotypes, personnel area and subarea and their groupings, etc...
sir iam going for an interview on feb 2nd week and i would like too ask questions that they will pose too me 1:i hav choosen conchordia wisconsin why these university what should b my answer 2:i had selected mis in mba from conchordioa university why these course if they question wat should b my answer 3:and last question is wat is guarantee u will come bck my dad works as a production manager in saudi arabia soo wat should b my anser too them because i am going for mba wat should b my answer for return gurantee pls reply too me it will b gr8 off u yours sicerly
why u choose mba after bca?
expline the relevance of economic meltdown and the cost accounting
what is the difference between BI and BW security?
Why are you interested in this position? Our company?
How retrive the deleted file frm UAT by doing migration in SAP BO 4.0
what do u mean by altkey?
From where I should start to prepare for cat?
Describe some of your most important career accomplishments
what is capital