QuestionQuestion

1. Input a sentence from the command line. First convert all lowercase letters in the sentence (if any) into uppercase, and then sort the sentence by ASCII values of individual characters and output the sorted sentence to console standard output. (Example: When input is “I am a student.”, your output should be “   .AADEIMNSTTU”. )

2. Input an integer between 1 and 50 from the command line and print out a list of integers as a result of iteratively apply function f to the integer. The function f is defined as f(x)=3x+1 if x is odd and f(x)=x/2 if x is even. Stop the iteration when you get 1. (Example: When input is 6, your output should be 6,3,10,5,16,8,4,2,1.)

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#define MAX_LENGTH 100


/**
* bubble sort
* @param string
* @param length
*/
void sort(char string[], int length){
    int i, j, t;
   
    for (i = length - 1; i >= 0; i--) {
       for (j = 1; j <= i; j++) {
            if (string[j - 1] > string[j]) {
                t = string[j - 1];
                string[j - 1] = string[j];
                string[j] = t;
            }
       }
    }
}...
$23.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats