bsc

Comprehensive codebase and cou...
Log | Files | Refs | Activity | README | LICENSE

root / semester_1 / letusc / luc053.c

luc053.c (1075B)


      1 /* Write macro definitions for: Mean, Absolute value, Uppercase to Lowercase, Biggest of three.
      2 */
      3 /* Let Us C, Chap- 12 (The C Preprocessor), Qn No.: C(b) */
      4 /* This file is auto-generated by a bot. */
      5 /* This code is not compiled; it is for reference only. */
      6 
      7 
      8 #include <stdio.h>
      9 #include <math.h>
     10 #include <stdlib.h>
     11 
     12 #define MEAN(x, y) ((x + y) / 2.0)
     13 #define ABS(x) ((x) < 0 ? -(x) : (x))
     14 #define TO_LOWER(x) ((x) >= 'A' && (x) <= 'Z' ? (x) + 32 : (x))
     15 #define MAX(x, y, z) ((x) > (y) ? ((x) > (z) ? (x) : (z)) : ((y) > (z) ? (y) : (z)))
     16 
     17 int main()
     18 {
     19     int a, b, c, num;
     20     char ch;
     21 
     22     printf("Enter two numbers for Mean: ");
     23     scanf("%d %d", &a, &b);
     24     printf("Mean: %.2f\n\n", MEAN(a, b));
     25 
     26     printf("Enter a number for Absolute value: ");
     27     scanf("%d", &num);
     28     printf("Absolute: %d\n\n", ABS(num));
     29 
     30     printf("Enter an uppercase character: ");
     31     scanf(" %c", &ch);
     32     printf("Lowercase: %c\n\n", TO_LOWER(ch));
     33 
     34     printf("Enter three numbers: ");
     35     scanf("%d %d %d", &a, &b, &c);
     36     printf("Biggest: %d\n", MAX(a, b, c));
     37 
     38     return 0;
     39 }
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror