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

The government’s quest to fight COVID-19 has led to the establishment of a PPE production factory in the Greater Accra region. The factory is classified as a high-risk working environment and the workers are paid an hourly rate of GHs 30 for regular hours per week and any extra hours are paid one and one-half times that. A total of 40 hours should be the normal hours and a maximum of 20 overtime hours for a week. From the worker’s gross pay, 6% is withheld for social security. 7% is withheld for tax and 3% is held for union dues. If the worker has dependents, the government pay 5.5% of the weekly wage per dependent up to 3 dependents into an insurance account. Write a program that will:

a)     Request for the number of hours worked in a week, and the number of dependents.                                                                                              

3. Float Count-off


Counting off a list of float numbers is hard when you speak it, but not when you code it! Don't believe me? Then let's try coding just that!


Instructions:

  1. An array containing 30 predefined float values are already provided for you in the code editor. Print each of the element out in separate lines, starting from the last array element down to the first.
  2. Each outputted value must also only show up to two decimal places.

Output

Multiple lines containing a float number.

2.41
143.00
3.14
3.12
0.00
-321.12
-414.12
12312.10
4.10
2.42
.
.
.

Counting Num


by CodeChum Admin



To give you more of a challenge with a number's digits, let's try counting how many of a certain digit is present on a given number.





Let's start coding!





Instructions:



Input two integer values. The first one shall accept any integer from 0-9 and the other one shall take a non-zero positive integer.


Using a while loop, count how many of the first integer (0-9) is present in the digits of the second inputted integer and print the result (see sample input and output for example).


Tip #1: You have to use your knowledge from the previous problems in looping through the digits of a number: % 10 to get the rightmost digit, while / 10 to remove the rightmost digit. Make sure to solve the previous problems first.


Input



A line containing two integers separated by a space.



2·124218


Output



A line containing an integer.



2

Write a program to input 2 numbers and print sum, subtraction, multiplication, division and modulus of those numbers.





Make a program that will accept an integer and loop for the same number of times as that of the inputted integer and input random integers and add it to the array/list one by one, per line. Afterwards, make your program accept another random integer.

Using that final integer, compare from your array/list if the final integer's value is also present in your current array/list. If so, print "Present"; otherwise, print "None".


What's in There?

Let's try defining the size of the array and create the contents of it on our own! And then, to give off a sense of excitement, let's try accessing the value of an array element in a random index position!


Let's do this fast!


Instructions:

  1. Create an empty character array with a size of 100.
  2. Use an appropriate input function for strings and store the value into the empty array.
  3. Input a random integer. It shall only be any integer that's less than the string's length.
  4. Using your understanding on accessing list elements, access and print out the array element having the index position of the inputted random integer

Input


1. A string

2. An index

Output

The first line will contain a message prompt to input the string.

The second line will contain a message prompt to input the integer which represents the index.

The last line contains the character at the index.

Enter·the·string:·Cody
Enter·the·index:·3
Character·at·index·3·=·y

Cubes and Squares


You can also make a list of numbers, ey? Let's go and have some fun in tweaking the values of each element, but let's give it some twist to add on some fun to the code.


Let's have a go at it!


Instructions:

  1. An array containing 40 integer elements is already provided for you in the code editor below.
  2. Using loops and conditions, print out the cube of the array element if it is a positive number, and print out the square of the number if it is negative. Each result must be printed out separately by each line.

Output

The squares and cubes of the elements in the array.

4
1
1
8
27
.
.
.

Read 10 integers from the keyboard in the range 0 -100, and count how many of them are larger than 50, and display this result.


Write a C program that does the following: a. Declare a structure called Car with the following members: Price (float), Year (int), Color (String) and Brand (String). b. Ask the user to enter the information of 10 cars and save them in an array called CARS. c. Print the color of the car(s) that has (have) a price greater than 15000. d. Write a function called oldestCar that takes the array CARS as an argument and returns the oldest car among all cars. e. In the main, call the function oldestCar and print all information of the oldest car.


Consider a square matrix A of size Nx N and an integer X which is an element of A. Find the row number R and column number C of X in A, and calculate the sum of


LATEST TUTORIALS
APPROVED BY CLIENTS