Popular posts from this blog
C: Usage Of limits.h And float.h To Access Min And Max Constants.
https://github.com/pereiradaniel/beginning_c/blob/master/ch2/limits.c // Limits // Daniel Pereira, 04 November 2022. // Use limits.h and float.h to access MIN and MIX variables. #include <stdio.h> #include <limits.h> // limits on integer types #include <float.h> // limits on floating point types int main(int argc, char* argv[]) { printf("INTEGER TYPE, MIN, MAX.\n"); printf("-----------------------\n"); printf("char, %d, %d\n", CHAR_MIN, CHAR_MAX); printf("unsigned char, NA, %u\n", UCHAR_MAX); printf("short, %d, %d\n", SHRT_MIN, SHRT_MAX); printf("unsigned short,NA,%u\n", USHRT_MAX); printf("int, %d, %d\n", INT_MIN, INT_MAX); printf("unsigned int, NA, %u\n", UINT_MAX); printf("long, %ld, %ld\n", LONG_MIN, LONG_MAX); printf("unsigned long, NA, %lu\n", ULONG_MAX); printf("long long, %lld, %lld\n", LLONG_MIN, LLONG_...
C: Program That Calculates Pay Based On Salary And Hours.
https://github.com/pereiradaniel/beginning_c/blob/master/ch2/exercises/2_4/exercise2_4.c // Exercise 2-4 // Write a program that prompts for the user’s weekly pay in dollars and the // hours worked to be entered through the keyboard as floating-point values. The program // should then calculate and output the average pay per hour in the following form: // Your average hourly pay rate is 7 dollars and 54 cents. #include <stdio.h> double checkInput(double input, double min, double max); int main(int argc, char* argv[]) { double hours = 0, rate = 0; // Get input for hours: printf("Enter number of hours worked: "); while(hours == 0) { scanf(" %lf", &hours); hours = checkInput(hours, 1, 10000); } // Get input for salary: printf("Enter hourly rate: "); while(rate == 0) { scanf(" %lf", &rate); rate = checkInput(rate, 1, 100); } // Calculate pay:...