Question

Develop a program that accepts integers from command line, sorts the integers into ascending order, computes...

  1. Develop a program that accepts integers from command line, sorts the integers into ascending order, computes the sum of the integers, and counts the number of even numbers and the number of odd numbers.

Solve in C programing language?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here the code to get the integer value from command line and display it in the ascending order. And also it will display the counts of even and odd numbers.

#include<stdio.h>

int main()

{

int n, data[100],i,j,temp;

int Even_Count = 0; Odd_Count = 0;

/*get the number of entries

printf("enter the input for n :");

scanf("%d", &n);

/* get the input data

for(i=0; i<n; i++)

scanf("%d", &data[i]);

/* ascending order

for(i=0;i<n-1;i++)

{  

for(j=i+1;j<n;j++)

{

if(data[i] > data[j]) {

temp = data[i];

data[i]= data[j];

data[j]=temp;

}
}
}

/* data in ascending order

printf("Ascending order: \n");

for(i=0; i<n; i++)

printf("%d\n", data[i]);

for(i=0;i<n;i++)

{

if(data[i] % 2 == 0)

{

Even_Count++;

}

else

{

Odd_Count++;

}

}

printf("\n Number of even number is = %d " , Even_Count );

printf("\n Number of odd number is = %d " , Odd_Count);

return 0;

}

Add a comment
Know the answer?
Add Answer to:
Develop a program that accepts integers from command line, sorts the integers into ascending order, computes...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT