Learning to write a computer code is as much as important as learning any skill. Coding or programming is a skill. You must practice daily to really sharpen your coding skill. Remember that an apple a day keeps you away from the doctor and a program a day keeps you from forgetting the synthax easily. Eventually you'd get used to it.
One of the many solutions to a daily program is available in the src/
directory.
You don't have to clone this repo, but create your own, solve the daily problems and gain your mastery.
Write a program to find the distance between point A and B, taken the coordinates of A
and B from the user.
Your code should return 5 for A(1, 5)
and B(5, 8)
.
You would need to include the cmath
and iostream
library or header files.
Write a program, taking a positive integer from the user, convert the integer to binary, octal and hexadecimal base. Make use of loops rather.
Give a signed, 4-bit binary number, write a program to convert it to its correspoding signed decimal number. Consider the table below for a sample input and output.
Input | Output |
---|---|
1100 | -4 |
0100 | +4 |
Write a program to find the polar coordinate of a given rectangular (cartesian) coordinate.
Write a function that takes three reals as arguments and returns the max
Implement the bubble sort algorithm
Implement the peak algorithm, given an array and its size as argument
Implement the linear search algorithm, for a one dimensional array and and a two dimensional array, gien the array and its size as arguments. Make use of functions.
Implement the factorial algorithm.
Given a time elasped in seconds, convert it to hours, minutes anf seconds. In the format, HH:MM:SS
This problem was taken (copied) from C++ P ROGRAMMING : FROM PROBLEM ANALYSIS TO PROGRAM DESIGN FIFTH EDITION D.S. M ALIK CHAPTER 9 ARRAYS AND STRINGS, programming exercise 9
Write a program that uses a two-dimensional array to store the highest and lowest temperatures for each month of the year. The program should output the average high, average low, and the highest and lowest tempera- tures for the year. Your program must consist of the following functions:
- Function getData : This function reads and stores data in the two-dimensional array.
- Function averageHigh : This function calculates and returns the average high temperature for the year.
- Function averageLow : This function calculates and returns the aver- age low temperature for the year.
- Function indexHighTemp : This function returns the index of the highest high temperature in the array.
- Function indexLowTemp : This function returns the index of the lowest low temperature in the array. (These functions must all have the appropriate parameters.)
Implement the min-max-sum algorithm given an array and its size as input.
write a program to find the inverse of a 2 by 2 matrix, taken an array of of size 4 as input where the 0th and 1th indexed elements are the first row and the 2th and 3th indexed elements are the second row.
Write a program to the find roots of a quadratic equation of the form, ax^2 + bx + c = 0, given a, b and c as input.
Write a program that calculates and prints the sum of all the natural numbers divisible by either 3 or 5, up to a given limit entered by the user.
Write a program that, given two positive integers, will calculate and print the greatest common divisor of the two.
Write a program that, given two positive integers, will calculate and print the lowest common multiple of the two.
Write a program that memics a calculator - takes 2 numerical inputs and an operator.
Implement the babylonian algorithm for finding the squareroot of a given number.
Implement the binary search algorithm given a sorted array, its size and the search item as input.
Write a function int max_of_four(int a, int b, int c, int d)
which reads four arguments and returns the greatest of them.
Write a void function that takes three arguments, sums the first two and assigns its value to the third. (Think a little - address/poiters)
Write a program that prompts the user to enter the weight of a person in kilograms and outputs the equivalent weight in pounds. Output both the weights rounded to two decimal places. (Note that 1 kilogram = 2.2 pounds.) Format your output with two decimal places.
Write a function that takes as a parameter a nonnegative integer and generates the following pattern of stars. If the nonnegative integer is 4, then the pattern generated is:
****
***
**
*
Write a function that takes a positive integer, n, as argument and returns the nth fibonacci number.
Write a function to find the sum of the first , N, natural numbers.
Write a function to return the , Nth, harmonic sum. HMn = 1 + 1/2 + 1/3 + ... + 1/n, where n is the Nth natural number
Write a function that takes a positive integer, n, as argument and returns the nth fibonacci number, using Binet’s formula:
f ( n ) = ( 1 + 5^0.5 )^n − ( 1 − 5^0.5 )^n
---------------------------------
2 ^ n * 5^0.5
Make a program which randomly chooses a number to guess and then the user will have a few chances to guess the number correctly. In each wrong attempt, the computer will give a hint that the number is greater or smaller than the one you have guessed.
Write a program that count down time in which the user can set a timer and then when the time is completed, the user will be notified that the time has ended.