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:
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.22by 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:
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·=·7by 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:
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·=·7by CodeChum Admin
We've been dealing with integers too much, it's time for float to shine!
Instructions:
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
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·=·32. 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.