This is for C code not C 4 Write a c program that prompts th

This is for C code, not C++

4)

Write a c program that prompts the user to enter 3 integers separated by spaces, assigns the integers to an array, and then prints the integers in ascending order. Include a function in your program that takes integer parameters (you can decide how many parameters) and returns the largest one. Use that function to help you sort the numbers. Include the algorithm for your program as a multi-line comment at the bottom of your file. Use the algorithm format taught in the labs.

As your written answer to this question, give the output for your program when given the following input:

12 8 2

555 89999 1233456

0 88 -1

5 6 5

5) Write a c program that prompts the user to enter a noun of no more than 25 characters. The program should create a new string that is the plural of the noun. Use the following rules when creating plurals:

1. If a noun ends in \'s\', \'ch\', or \'sh\' add es to the noun

2. If a noun ends in \'y\', change the \'y\' to \'i\' and add \'es\' to the noun.

3. In all other cases add an \'s\' to the noun.

Your program should print the noun as entered by the user and then print the plural. Use a function to create the plural. The function may print the plural if you wish. Include the algorithm for your program as a multi-line comment at the bottom of your file. Use the algorithm format taught in the labs.

As your written answer to this question, give the output for your program when given the following input:

hobby

horse

couch

cat

wish

log

Include as part of this answer a brief discussion as to whether this input sufficiently tests the program operation. Support your position with examples.

Solution

4.

#include <stdio.h>
#include<conio.h>
void main()
{
int i, j, a , num[3];
clrscr();
printf(\"\ Enter three integers : \");
for (i = 0; i < 3; i++)
{
scanf(\"%d\",&num[i]);
}
for (i = 0; i < 3; ++i)
{
   for (j = i + 1; j < 3; ++j)
   {
   if (num[i] > num[j])
   {
   a = num[i];
   num[i] = num[j];
   num[j] = a;
   }
   }
}
printf(\"The integers arranged in ascending order are as follows : \ \");
for (i = 0; i < 3; ++i)
{
printf(\"%d\ \", num[i]);
}

for(i=0;i<3;i++)
{
   if(num[0]<num[i])
   {

   num[0]=num[i];
   }
}
printf(\"\ Largest integer = %d\",num[0]);

getch();
}

This is for C code, not C++ 4) Write a c program that prompts the user to enter 3 integers separated by spaces, assigns the integers to an array, and then print
This is for C code, not C++ 4) Write a c program that prompts the user to enter 3 integers separated by spaces, assigns the integers to an array, and then print

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site