The 2nd part in a mini-series for beginners in C.

1 minute read


Hello. Hello. Hello

So once again, I’m here to make programming a little easier by providing the literal solutions… with GitHub (yes!).

C Programming Help that is…

The solution files can be found on my GitHub.

Problem 2.1 - Reading from the keyboard

Write a program which does the following:

1. reads two floats from the keyboard
2. prints the sum of the two floats
3. prints the difference of the two floats
4. prints the square of the first float
5. reads two integers from the keyboard
6. computes the sum and product of the two integers
7. prints the sum and product of the integers

Problem 2.2 - Decimal, octal and hexadecimal numbers

Write a program which does the following:

1. reads an integer from the keyboard
2. and prints the integer in decimal, octal and hexadecimal notation

Problem 2.3 - Time Calculation

Write a program where you can enter hours and minutes as input from the keyboard.

Your program should compute and output by printing on the screen the the total number of minutes.

Problem 2.4 - Fahrenheit and Celsius

Write a program that converts Centigrades (also known as Celsius) to Fahrenheit.

You should be able to enter a number, then the result should be computed and printed to the screen according to the following transformation:

F = (9/5)*C + 32

Problem 2.5 - Pointers and their content

Write a program which reads an integer variable val from the keyboard and prints the value on the screen.

Then declare and initialize a pointer ptr val to val, print the address where the pointer points to on the screen, increment (add 1 to it) the value of val by using the pointer variable and print the modified value and the address of the pointer on the screen as well.

Problem 2.6 - Multiple pointers to same data

Write a program which reads two float variables a and b from the keyboard.

Then declare and initialize three pointers ptr1, ptr2 and ptr3 such that ptr1 and ptr2 will both point to the variable a and ptr3 will point to b.

By using printf show that ptr1 and ptr2 contain the same memory address and ptr3 contains a different address.


, , , , , , , , , , , ,

Leave a comment

Read More