C Answers

Questions answered by Experts: 1 680

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

6. Negative Decimal Tally

by CodeChum Admin

We've been giving positive numbers too much attention lately, it's time to let negative numbers take the spotlight this time!


Instructions:

  1. Input four float numbers; they could be positive or negative.
  2. Only add all inputted negative numbers, and print its sum, up to 2 decimal place.
  3. Hint: The previous/latest topic is about if-else-elseif statements, but do we need one here?

Input


1. First decimal number

2. Second decimal number

3. Third decimal number

4. Fourth decimal number

Output

The first four lines will contain message prompts to input the four decimal numbers.

The last line contains the sum of all the inputted negative numbers, with 2 decimal places.

Enter·the·first·number:·-30.22
Enter·the·second·number:·10.5
Enter·the·third·number:·-2.2
Enter·the·fourth·number:·-1.8
Sum·of·all·negatives·=·-34.22

5. Largest Digit

by CodeChum Admin

This one is a bit tricky. You're going to have to isolate each digit of the integer to determine which one is the largest, so good luck!


Instructions:

  1. Input a 3-digit integer.
  2. Print the largest digit in the integer.
  3. Tip #1: Use % 10 to get the rightmost digit. For example, if you do 412 % 10, then the result would be the rightmost digit, which is 2.
  4. Tip #2: On the other hand, use / 10 to remove the rightmost digit. For example, if you do 412 / 10, then the result would be 41.
  5. Tip #3: You'd have to repeat Tip #1 and Tip #2 three times for this problem because the input is a 3-digit integer.

Input


1. A three-digit integer

Output

The first line will contain a message prompt to input the 3-digit integer.

The last line contains the largest digit of the inputted integer.

Enter·a·3-digit·integer:·173
Largest·=·7

5. Largest Digit

by CodeChum Admin

This one is a bit tricky. You're going to have to isolate each digit of the integer to determine which one is the largest, so good luck!


Instructions:

  1. Input a 3-digit integer.
  2. Print the largest digit in the integer.
  3. Tip #1: Use % 10 to get the rightmost digit. For example, if you do 412 % 10, then the result would be the rightmost digit, which is 2.
  4. Tip #2: On the other hand, use / 10 to remove the rightmost digit. For example, if you do 412 / 10, then the result would be 41.
  5. Tip #3: You'd have to repeat Tip #1 and Tip #2 three times for this problem because the input is a 3-digit integer.

Input


1. A three-digit integer

Output

The first line will contain a message prompt to input the 3-digit integer.

The last line contains the largest digit of the inputted integer.

Enter·a·3-digit·integer:·173
Largest·=·7

5. Float Galore

by CodeChum Admin

We've been dealing with integers too much, it's time for float to shine!


Instructions:

  1. Input five float numbers.
  2. Print out the float numbers in one line, separated by spaces, and make sure you only print up to 1 decimal place.
  3. Add the first four float numbers and check if their sum is greater than the fifth float number. Print out "Yes" if they are.

Input


1. First float number

2. Second float number

3. Third float number

4. Fourth float number

5. Fifth float number

Output

The first five lines will contain message prompts to input the five float numbers.

The next line contains the inputted float numbers.

The last line contains "Yes" if the condition is true.

Enter·the·first·number:·1.1
Enter·the·second·number:·1.2
Enter·the·third·number:·1.3
Enter·the·fourth·number:·1.4
Enter·the·fifth·number:·1.1
1.1·1.2·1.3·1.4·1.1
Yes

. Are Integers Created Equally?

by CodeChum Admin


It's time to find out if something is true or false. Let's test your capabilities by creating a program that checks if two integers are equal!




Instructions:


Input two integers in one line.

Print the two integers in one line, and separate them with a space.

Print a string message "Equal" on a new line, if both inputted integers are equal.

Input


1. First integer


2. Second integer


Output


The first two lines will contain message prompts to input the two integers.

The next line will contain the inputted integers.

The last line will contain a string which is the result, if the condition were true.


Enter·the·first·integer:·5

Enter·the·second·integer:·5

5·5

Equal


The Positive Ones

by CodeChum Admin

There are different kinds of numbers, but among them all, the most commonly used numbers in our daily lives are those positive ones. So, I only want you to count all the positive numbers from the 4 outputted values and print out the result.


Go and search for the positive ones among these four!


Input


1. First number

2. Second number

3. Third number

4. Fourth number

Output

The first four lines will contain message prompts to input the four numbers.

The last line contains the total count of all the positive numbers.

Enter·the·first·number:·2
Enter·the·second·number:·-4
Enter·the·third·number:·3.6
Enter·the·fourth·number:·1
Count·of·positives·=·3





2. Array is the simplest data structure where each data element can be randomly accessed by using its index number. Write a complete C program to create an array and perform the following, using functions.



a. Create an array to store some characters.



b. Get a word (which contains lower case letters only) from the user and store the letters in the array according to the order of letters.



(Ex: If the user Input = campus; Array = ‘c’ ‘a’ ‘m’ ‘p’ ‘u’ ‘s’)



c. Display the elements of the array.



d. Add uppercase letters (A, B, C, …) in between each letter in the array. Then your array length become double. Display the elements of the array.



(Ex: If the Array = ‘c’ ‘a’ ‘m’ ‘p’ ‘u’ ‘s’; After inserting numbers, the array = A c B a C m D p



E u F s)



e. Remove all the lower case letters from the array. Then your array will shrink back to the half size. Display the elements of the array.



(Ex: If the array = A c B a C m D p E u F s; then array = A B C D E F)



f. Display the array again in reverse order.






Consider the following declaration and the statements (a) to (d) written in C. Identify the statement which are correct and the ones which has an error, by giving reason. If a statement has an error correct it.

int c = 1, *pc; // declaration

(a) pc = c;

(b) *pc = &c;

(c) pc = &c;

(d) *pc = c; 


Write short answers for each of the following:

(a) Name the operator that is used to declare a pointer variable.

(b) If pt is an integer pointer variable, what is the value that this pointer variable can have? (c) List the three values that can be used to initialize a pointer variable.

(d) Name and give the symbol of the operator that returns the location in memory where its operand is stored.


Is It You, Cody?


by CodeChum Admin



Can you identify if Cody's name is spelled right? If so, then make a program that accepts four one-letter strings separated by space and print "Correct" if the inputted strings, combined in order, spell the name Cody correctly. If not, print "Wrong". It doesn't matter if it's in uppercase or lowercase, as long as it's spelled correctly, it's considered correct.

LATEST TUTORIALS
APPROVED BY CLIENTS