commit 601ef51ba71c79849a9a93d72f688988d28acae4
parent 6e6bfb9bf30a120810777db575c8fa019060de6b
Author: Amit Dutta <amitdutta4255@gmail.com>
Date: Fri, 3 Oct 2025 19:59:45 +0530
update folder name
Diffstat:
24 files changed, 711 insertions(+), 0 deletions(-)
diff --git a/letusc-exercises/luc001.c b/letusc-exercises/luc001.c
@@ -0,0 +1,16 @@
+/* Temperature of a city in fahrenheit degrees is input through
+the keyboard. WAP to convert this temperature into Centigrade
+degrees. */
+/* Author - Amit Dutta, Date - 13 sep, 2025 */
+/* Chapter 1; Page 19; Question NO.: F(a) */
+
+#include<stdio.h>
+int main() {
+ float f, c;
+ printf("Enter the temperature of city in Fahrenheit : ");
+ scanf("%f", &f);
+ // formula (F - 32) 5/9
+ c = ((f - 32) * 5) / 9;
+ printf("\nTemperature in centigrade : %f", c);
+ return 0;
+}
diff --git a/letusc-exercises/luc002.c b/letusc-exercises/luc002.c
@@ -0,0 +1,27 @@
+/* The length and breadth of a rectangle and radius of a circle
+are input through the keyboard. Write a program to calculate the
+area and perimeter of the rectangle, and the area and circumference
+of the circle. */
+/* Author - Amit Dutta, Date - 16th SEP, 2025 */
+/* Let Us C; Page - 19; Chap- 1; QNo.: F(b) */
+
+#include <stdio.h>
+#include <math.h>
+int main()
+{
+ double len, bre, r, area_r, per, area_c, cir;
+ printf("Enter the length and breadth of the rectangle : ");
+ scanf("%lf %lf", &len, &bre);
+ printf("Enter the Radius of the circle : ");
+ scanf("%lf", &r);
+ area_r = len * bre;
+ per = 2 * (len + bre);
+ area_c = M_PI * r * r;
+ cir = 2 * M_PI * r;
+ printf("\nArea of Rectangle : %lf"
+ "\nPerimeter of Rectangle : %lf"
+ "\nArea of Circle : %lf"
+ "\nCircumference of Circle : %lf",
+ area_r, per, area_c, cir);
+ return 0;
+}
diff --git a/letusc-exercises/luc003.c b/letusc-exercises/luc003.c
@@ -0,0 +1,23 @@
+/* Paper of size AO has dimensions 1189 mm x 841 mm.
+Each subsequent size A(n) is defined as A(n-1) cut in
+half, parallel to its shorter sides. Thus, paper of
+size A1 would have dimensions 841 mm x 594 mm. Write
+a program to calculate and print paper sizes A0,�
+A1,�A2,�...�A8. */
+/* Author - Amit Dutta, Date - 16th SEP, 2025 */
+/* Let Us C; Page - 19; Chap- 1; QNo.: F(c) */
+
+#include<stdio.h>
+#include<math.h>
+int main() {
+ double s_long = 1189.0, s_short = 841.0, temp;
+ int i;
+ printf("A0 Dimension : %g mm x %g mm", floor(s_long), floor(s_short));
+ for (i = 1; i <= 8; i++) {
+ temp = s_long;
+ s_long = s_short;
+ s_short = temp / 2;
+ printf("\nA%d Dimension : %g mm x %g mm", i, floor(s_long), floor(s_short));
+ }
+ return 0;
+}
diff --git a/letusc-exercises/luc004.c b/letusc-exercises/luc004.c
@@ -0,0 +1,26 @@
+/* If a five digit number is input through the keyboard,
+write a program to calculate the sum of it's digit.
+(Hint : Use the modulus operator %) */
+/* Author - Amit Dutta, Date - 28th SEP, 2025 */
+/* Let Us C; Page - 37; Chap- 2; QNo.: G(a) */
+
+#include <stdio.h>
+int main()
+{
+ int inp, result = 0, i, temp;
+ printf("Enter a five digit number : ");
+ scanf("%d", &inp);
+ if (inp < 10000 || inp > 99999)
+ {
+ printf("\nPlease enter a valid five digit number.");
+ return 1;
+ }
+ temp = inp;
+ for (i = 1; i <= 5; i++)
+ {
+ result = result + (inp % 10);
+ inp = inp / 10;
+ }
+ printf("\nSum of the digit '%d' is : %d", temp, result);
+ return 0;
+}+
\ No newline at end of file
diff --git a/letusc-exercises/luc005.c b/letusc-exercises/luc005.c
@@ -0,0 +1,19 @@
+/* Write a program to recive Cartesian
+co-ordinates (x, y) of a point and convert
+them into Polar co-ordinates (r, phi)
+ Hint : r = sqrt (x^2 + y^2) and phi = tan^-1 (y/x) */
+/* Author - Amit Dutta, Date - 28th SEP, 2025 */
+/* Let Us C; Page - 37; Chap- 2; QNo.: G(b) */
+
+#include <stdio.h>
+#include <math.h>
+int main()
+{
+ double x, y, r, phi;
+ printf("Enter the Cartesian Co-Ordinates in this format 'x, y' : ");
+ scanf("%lf, %lf", &x, &y);
+ r = sqrt(pow(x, 2) + pow(y, 2));
+ phi = atan2(y, x);
+ printf("\nPolar Co-Ordinates are : (%g, %g Rad)", r, phi);
+ return 0;
+}+
\ No newline at end of file
diff --git a/letusc-exercises/luc006.c b/letusc-exercises/luc006.c
@@ -0,0 +1,27 @@
+/* Write a program to receive values of latitude (L1, L2) and longitude
+(G1, G2), in degrees, of two places on the earth and output the distance
+(D) between them in nautical miles. The formula for distance in nautical
+miles is :
+ D = 3963 cos^-1(sin L1 sin L2 + cos L1 cos L2 * cos(G2 - G1))
+*/
+/* Author - Amit Dutta, Date - 29th SEP, 2025 */
+/* Let Us C, Chap - 2, Page - 37, Qn no.: G(c) */
+
+#include <stdio.h>
+#include <math.h>
+int main()
+{
+ double l1, l2, g1, g2, d;
+ printf("Enter the Latitude in 'L1, L2' format : ");
+ scanf("%lf, %lf", &l1, &l2);
+ printf("Enter the Longitude in 'G1, G2' format : ");
+ scanf("%lf, %lf", &g1, &g2);
+ // Converting degree to radian because function from math.h use radian not degree
+ l1 = l1 * (M_PI / 180);
+ l2 = l2 * (M_PI / 180);
+ g1 = g1 * (M_PI / 180);
+ g2 = g2 * (M_PI / 180);
+ d = 3963 * acos(sin(l1) * sin(l2) + cos(l1) * cos(l2) * cos(g2 - g1));
+ printf("Distance in nautical miles : %g", d);
+ return 0;
+}+
\ No newline at end of file
diff --git a/letusc-exercises/luc007.c b/letusc-exercises/luc007.c
@@ -0,0 +1,20 @@
+/* Wind-chill factor is the felt air temperature on exposed skin due to wind.
+The wind-chill temperature is always lower than the air temperature, and is
+calculated as per the following formula.
+ wcf = 35.74 + 0.6215t + (0.4275t - 35.75) * v^0.16
+Where t is temperature and v is wind velocity. Write a program to receive
+values of t and v and calcualate wind-chill factor (wcf). */
+/* Author - Amit Dutta, Date - 30th SEP, 2025 */
+/* Let Us C, Chap - 2, Page - 37, Qn No.: G(d) */
+
+#include <stdio.h>
+#include <math.h>
+int main()
+{
+ double t, v, wcf;
+ printf("Enter the temperature and velociy of the wind : ");
+ scanf("%lf %lf", &t, &v);
+ wcf = 35.74 + (0.6215 * t) + (((0.4275 * t) - 35.75) * pow(v, 0.16));
+ printf("\nWind-chill factor (wcf) : %g", wcf);
+ return 0;
+}+
\ No newline at end of file
diff --git a/letusc-exercises/luc008.c b/letusc-exercises/luc008.c
@@ -0,0 +1,29 @@
+/* If value of an angle is input through the keyboard,
+write a program to print all its trigonometric ratios. */
+/* Author - Amit Dutta, Date - 30th SEP, 2025 */
+/* Let Us C, Chap - 2, Page - 37, Qn No.: G(e) */
+
+#include <stdio.h>
+#include <math.h>
+int main()
+{
+ double inp, rsin, rcos, rtan, rcosec, rsec, rcot;
+ printf("Enter the Angle in degree : ");
+ scanf("%lf", &inp);
+ inp = inp * (M_PI / 180); //changing degree to radian
+ rsin = sin(inp);
+ rcos = cos(inp);
+ rtan = tan(inp);
+ rcosec = 1 / rsin;
+ rsec = 1 / rcos;
+ rcot = 1 / rtan;
+ printf("\nTrigonometric ratios :-"
+ "\nsin = %g "
+ "\ncos = %g"
+ "\ntan = %g"
+ "\ncosec = %g"
+ "\nsec = %g"
+ "\ncot = %g",
+ rsin, rcos, rtan, rcosec, rsec, rcot);
+ return 0;
+}+
\ No newline at end of file
diff --git a/letusc-exercises/luc009.c b/letusc-exercises/luc009.c
@@ -0,0 +1,22 @@
+/* Two numbers are input through the keyboard into two locations
+C and D. Write a program to interchange the contents of C and D. */
+/* Author - Amit Dutta, Date - 30th SEP, 2025 */
+/* Let Us C, Chap - 2, Page - 37, Qn No.: G(d) */
+
+#include <stdio.h>
+int main()
+{
+ double a, b;
+ printf("Enter the two number A and B : ");
+ scanf("%lf %lf", &a, &b);
+ printf("\nBefore Interchange : ");
+ printf("\nA = %g (Memory location = %p)", a, &a);
+ printf("\nB = %g (Memory location = %p)", b, &b);
+ a = a + b;
+ b = a - b;
+ a = a - b;
+ printf("\nAfter Interchange :");
+ printf("\nA = %g (Memory location = %p)", a, &a);
+ printf("\nB = %g (Memory location = %p)", b, &b);
+ return 0;
+}+
\ No newline at end of file
diff --git a/letusc-exercises/luc010.c b/letusc-exercises/luc010.c
@@ -0,0 +1,30 @@
+/* A five-digit number is entered through the keyboard. Write a program
+to obtain the reversed number and to etermine whether the original and reversed
+numbers are equal or not. */
+/* Author - Amit Dutta, Date - 1st OCT, 2025 */
+/* Let Us C, Chap - 3, Page - 53, Qn No.: f(a) */
+
+#include <stdio.h>
+int main()
+{
+ int num, rev, temp, i;
+ printf("Please enter the number : ");
+ scanf("%d", &num);
+ if (num < 10000 || num > 99999)
+ {
+ printf("\nPlease enter a five digit number.");
+ return 1;
+ }
+ temp = num;
+ for (i = 1; i <= 5; i++)
+ {
+ rev = (rev * 10) + num % 10;
+ num = num / 10;
+ }
+ printf("\nReverse of the Input number : %d", rev);
+ if (rev == temp)
+ printf("\nOriginal and reversed numbers are equal.");
+ else
+ printf("\nOrigianl and reversed numbers are not equal.");
+ return 0;
+}+
\ No newline at end of file
diff --git a/letusc-exercises/luc011.c b/letusc-exercises/luc011.c
@@ -0,0 +1,21 @@
+/* If ages of Ram, Shyam and Ajay are input through the keyboard,
+write a program to determine the youngest of the three. */
+/* Author - Amit Dutta, Date - 1st OCT, 2025 */
+/* Let Us C, Chap- 3, Page - 53, Qn No.: f(b) */
+
+#include <stdio.h>
+int main()
+{
+ int ram, shyam, ajay;
+ printf("Please enter the age of Ram, Shyam and Ajay : ");
+ scanf("%d %d %d", &ram, ­am, &ajay);
+ if (ram == shyam || ram == ajay || shyam == ajay)
+ printf("\nThree must have different age.");
+ if (ram < shyam && ram < ajay)
+ printf("\nRam is the youngest. Age : %d", ram);
+ if (shyam < ram && shyam < ajay)
+ printf("\nShyam is the youngest. Age : %d", shyam);
+ if (ajay < ram && ajay < shyam)
+ printf("\nAjay is the youngest. Age : %d", ajay);
+ return 0;
+}+
\ No newline at end of file
diff --git a/letusc-exercises/luc012.c b/letusc-exercises/luc012.c
@@ -0,0 +1,19 @@
+/* Write a program to check whether a triangle is valid or not,
+if three angles of the triangle are entered through the keyboard.
+A triangle is valid if the sum of all the three angles is equal to 180 degrees. */
+/* Author - Amit Dutta, Date - 1st OCT, 2025 */
+/* Let Us C, Chap- 3, Page - 53, Qn No.: f(c) */
+
+#include <stdio.h>
+int main()
+{
+ double angle1, angle2, angle3, sum;
+ printf("Enter the value of the three angle of the triangle : ");
+ scanf("%lf %lf %lf", &angle1, &angle2, &angle3);
+ sum = angle1 + angle2 + angle3;
+ if (sum == 180.0)
+ printf("\nThis Triangle is a valid one.");
+ else
+ printf("\nThis Triangle is not valid. Sum of the angles : %g", sum);
+ return 0;
+}+
\ No newline at end of file
diff --git a/letusc-exercises/luc013.c b/letusc-exercises/luc013.c
@@ -0,0 +1,16 @@
+/* Write a program to find the absolute value
+of a number entered through the keyboard. */
+/* Author - Amit Dutta, Date - 1st OCT, 2025 */
+/* Let Us C, Chap- 3, Page - 53, Qn No.: f(d) */
+
+#include <stdio.h>
+#include <math.h>
+int main()
+{
+ double num;
+ printf("Enter the number : ");
+ scanf("%lf", &num);
+ num = abs(num);
+ printf("\nAbsolute value of the input is : %g", num);
+ return 0;
+}+
\ No newline at end of file
diff --git a/letusc-exercises/luc014.c b/letusc-exercises/luc014.c
@@ -0,0 +1,23 @@
+/* Given the length and breadth of a rectangle, write a program to find
+whether the area of the rectangle is greater than it's perimeter.
+For example, the area of the rectangle with length = 5 and breadth = 4
+is greater than its perimeter. */
+/* Author - Amit Dutta, Date - 1st OCT, 2025 */
+/* Let Us C, Chap- 3, Page - 53, Qn No.: f(e) */
+
+#include <stdio.h>
+int main()
+{
+ double len, bre, area, peri;
+ printf("Enter the length and breadth of the rectangle : ");
+ scanf("%lf %lf", &len, &bre);
+ area = len * bre;
+ peri = 2 * (len + bre);
+ if (area > peri)
+ printf("\nThe area of the rectangle is greater than it's perimeter.");
+ else if (area < peri)
+ printf("\nThe area of the rectangle is lower than it's perimeter.");
+ else
+ printf("\nThe area of the rectangle is same as it's perimeter.");
+ return 0;
+}+
\ No newline at end of file
diff --git a/letusc-exercises/luc015.c b/letusc-exercises/luc015.c
@@ -0,0 +1,26 @@
+/* Given three points (x1, y1), (x2, y2), and (x3, y3),
+write a program to check if the three poins fall on one straight line. */
+/* Author - Amit Dutta, Date - 1st OCT, 2025 */
+/* Let Us C, Chap- 3, Page - 53, Qn No.: f(f) */
+
+#include <stdio.h>
+#include <math.h>
+#define EPSILON 0.0001
+// Define a small tolerance value (EPSILON) for safe floating-point comparison
+// This is critical because of minor rounding errors in computer arithmetic.
+int main()
+{
+ double x1, x2, x3, y1, y2, y3, area;
+ printf("Enter the point A(x1, y1) : ");
+ scanf("%lf %lf", &x1, &y1);
+ printf("Enter the point B(x2, y2) : ");
+ scanf("%lf %lf", &x2, &y2);
+ printf("Enter the point C(x3, y3) : ");
+ scanf("%lf %lf", &x3, &y3);
+ area = 0.5 * ((x1 * (y2 - y3)) + (x2 * (y3 - y1)) + (x3 * (y1 - y2)));
+ if (fabs(area) < EPSILON) // abs() for integer, fabs() for float, double
+ printf("\nA(%g, %g), B(%g, %g) and C(%g, %g) points fall on one straight line.", x1, y1, x2, y2, x3, y3);
+ else
+ printf("\nA(%g, %g), B(%g, %g) and C(%g, %g) points doesn't fall on one straight line.", x1, y1, x2, y2, x3, y3);
+ return 0;
+}+
\ No newline at end of file
diff --git a/letusc-exercises/luc016.c b/letusc-exercises/luc016.c
@@ -0,0 +1,42 @@
+/* Given the coordiantes (x, y) of center of a circle and its radius,
+write a program that will determine whether a point lies inside the circle,
+on the circle or outside the circle. (Hint : Use sqrt() and pow() functions.) */
+/* Author - Amit Dutta, Date - 1st OCT, 2025 */
+/* Let Us C, Chap- 3, Page - 53, Qn No.: f(g) */
+
+#include <stdio.h>
+#include <math.h>
+// Define a small tolerance value (EPSILON) for reliable floating-point comparison
+#define EPSILON 0.0001
+
+int main()
+{
+ double h, k;
+ double R;
+ double x, y;
+ double distance_sq;
+ printf("Enter the center coordinates (h, k) : ");
+ scanf("%lf %lf", &h, &k);
+ printf("Enter the radius (R) : ");
+ scanf("%lf", &R);
+ printf("Enter the point P coordinates (x, y) : ");
+ scanf("%lf %lf", &x, &y);
+ distance_sq = pow(x - h, 2) + pow(y - k, 2);
+ double radius_sq = R * R;
+ // Case 1: On the circle (D^2 = R^2) - Use EPSILON for safety!
+ if (fabs(distance_sq - radius_sq) < EPSILON)
+ {
+ printf("The point P(%g, %g) lies ON THE CIRCLE.\n", x, y);
+ }
+ // Case 2: Inside the circle (D^2 < R^2)
+ else if (distance_sq < radius_sq)
+ {
+ printf("The point P(%g, %g) lies INSIDE THE CIRCLE.\n", x, y);
+ }
+ // Case 3: Outside the circle (D^2 > R^2)
+ else
+ {
+ printf("The point P(%g, %g) lies OUTSIDE THE CIRCLE.\n", x, y);
+ }
+ return 0;
+}+
\ No newline at end of file
diff --git a/letusc-exercises/luc017.c b/letusc-exercises/luc017.c
@@ -0,0 +1,23 @@
+/* Given a point (x, y), write a program to find out if it lies on X-axis, Y-axis or origin. */
+/* Author - Amit Dutta, Date - 1st OCT, 2025 */
+/* Let Us C, Chap- 3, Page - 53, Qn No.: f(h) */
+
+#include <stdio.h>
+#include <math.h>
+#define EPSILON 0.00001
+
+int main()
+{
+ double x, y;
+ printf("Enter the point P(x, y) : ");
+ scanf("%lf %lf", &x, &y);
+ if (fabs(x) < EPSILON && fabs(y) < EPSILON)
+ printf("\nPoint P(%g, %g) lies on the origin.", x, y);
+ else if (fabs(x) < EPSILON)
+ printf("\nPoint P(%g, %g) lies on the Y-Axis.", x, y);
+ else if (fabs(y) < EPSILON)
+ printf("\nPoint P(%G, %g) lies on the X-Axis.", x, y);
+ else
+ printf("\nThe point P(%g, %g) lies in a QUADRANT (not on an axis or the origin).", x, y);
+ return 0;
+}+
\ No newline at end of file
diff --git a/letusc-exercises/luc018-logic.c b/letusc-exercises/luc018-logic.c
@@ -0,0 +1,87 @@
+/* According to Gregorian calender, it was Monday on the date 01/01/01.
+Write a program to find out what is the day on 1st January of any input year. */
+/* Author - Amit Dutta, Date - 1st OCT, 2025 */
+/* Let Us C, Chap- 3, Page - 53, Qn No.: f(i) */
+
+#include <stdio.h>
+
+/**
+ * @brief Determines if a given year is a leap year.
+ * * The rule: A year is a leap year if it is divisible by 4, UNLESS it is
+ * divisible by 100 but NOT by 400.
+ * * @param year The year to check.
+ * @return 1 if it is a leap year, 0 otherwise.
+ */
+int is_leap(int year) {
+ // Check if divisible by 400 OR (divisible by 4 AND not divisible by 100)
+ if ((year % 400 == 0) || (year % 4 == 0 && year % 100 != 0)) {
+ return 1;
+ }
+ return 0;
+}
+
+/**
+ * @brief Calculates the day of the week for January 1st of the given year.
+ * * The base date is 01/01/01, which was a Monday (index 1).
+ * * Day Mapping: 0:Sunday, 1:Monday, 2:Tuesday, 3:Wednesday, 4:Thursday, 5:Friday, 6:Saturday
+ */
+int main() {
+ long long year; // Use long long for year input if years far in the future/past are tested
+ int i;
+ long long total_days = 0;
+ int day_index;
+
+ // Day names array for output
+ const char *day_names[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
+
+ printf("Enter the year (e.g., 2025): ");
+ if (scanf("%lld", &year) != 1 || year < 1) {
+ printf("Invalid year input. Please enter a positive integer year (>= 1).\n");
+ return 1;
+ }
+
+ // --- Core Logic: Calculate Total Days ---
+
+ // We only need to consider the years that have *passed* before the target year.
+ // So, we count days from the end of year 0 up to the end of year (year - 1).
+ int years_passed = year - 1;
+
+ // 1. Calculate the number of leap days up to the end of year (year - 1)
+ // Formula based on Gregorian calendar rules for years Y-1:
+ // (Y-1)/4 - (Y-1)/100 + (Y-1)/400
+ long long leap_years = years_passed / 4 - years_passed / 100 + years_passed / 400;
+
+ // 2. Total days = (Number of years * 365) + (Number of leap years)
+ // Note: The loop method (below) is more intuitive but the formula is faster.
+ // We will use the direct formula for efficiency.
+ total_days = years_passed * 365 + leap_years;
+
+ // --- Alternate Loop Method (for conceptual simplicity) ---
+ /*
+ for (i = 1; i < year; i++) {
+ total_days += 365;
+ if (is_leap(i)) {
+ total_days += 1; // Add 1 for the leap day
+ }
+ }
+ */
+
+ // --- Determine the Day of the Week ---
+
+ // Since 01/01/01 was Monday (index 1), we use the following setup:
+ // Index 1 corresponds to Monday.
+ // The calculation gives the number of days *past* the Monday start (01/01/01).
+ // The modulo operation gives the remainder (0-6).
+
+ // 0 days elapsed (Year 1): total_days=0. (0 + 1) % 7 = 1 (Monday). Correct.
+ // 365 days elapsed (Year 2): total_days=365. (365 + 1) % 7 = 2 (Tuesday). Correct. (365 mod 7 = 1, 1+1 = 2)
+
+ day_index = (total_days + 1) % 7;
+
+ // Correct the Day Index to match the array (0:Sun, 1:Mon, ..., 6:Sat)
+ // The +1 adjusts for the Monday starting point (index 1).
+
+ printf("\nOn January 1st, %lld, the day was: **%s**.\n", year, day_names[day_index]);
+
+ return 0;
+}+
\ No newline at end of file
diff --git a/letusc-exercises/luc018.c b/letusc-exercises/luc018.c
@@ -0,0 +1,36 @@
+/* According to Gregorian calender, it was Monday on the date 01/01/01.
+if any year is input through the keyboard write a program to find out
+what is the day on 1st January of this year. */
+/* Author - Amit Dutta, Date - 1st OCT, 2025 */
+/* Let Us C, Chap- 3, Page - 53, Qn No.: f(i) */
+
+#include <stdio.h>
+
+int is_leap(int year) {
+ if ((year % 400 == 0) || (year % 4 == 0 && year % 100 != 0)) {
+ return 1;
+ }
+ return 0;
+}
+
+int main() {
+ long long year; // long long for year input if years far in the future/past are tested
+ int i;
+ long long total_days = 0;
+ int day_index;
+
+ // Day names array for output
+ const char *day_names[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
+
+ printf("Enter the year (e.g., 2025): ");
+ if (scanf("%lld", &year) != 1 || year < 1) {
+ printf("Invalid year input. Please enter a positive integer year (>= 1).\n");
+ return 1;
+ }
+ int years_passed = year - 1;
+ long long leap_years = years_passed / 4 - years_passed / 100 + years_passed / 400;
+ total_days = years_passed * 365 + leap_years;
+ day_index = (total_days + 1) % 7;
+ printf("\nOn January 1st, %lld, the day was: %s.\n", year, day_names[day_index]);
+ return 0;
+}+
\ No newline at end of file
diff --git a/letusc-exercises/luc019.c b/letusc-exercises/luc019.c
@@ -0,0 +1,52 @@
+/* If the length of three sides of a triangle are entered through the
+keyboard, write a program to check whether the triangle is an isosceles,
+an equilateral, a scalene or a right-angled triangle. */
+/* Author - Amit Dutta, Date - 3rd OCT, 2025 */
+/* Let Us C, Chap- 4, Page - 71, Qn No.: D(a) */
+
+#include <stdio.h>
+#include <math.h>
+
+#define EPSILON 0.000001
+/* EPSILON is used to compare double values for approximate equality,
+mitigating floating-point precision errors. */
+
+int main()
+{
+ double side1, side2, side3;
+ printf("Please enter the length of three side of the triangle : ");
+ scanf("%lf %lf %lf", &side1, &side2, &side3);
+ if (side1 < 1 || side2 < 1 || side3 < 1)
+ {
+ printf("\nLength of a side of triangle should be a positive integer.");
+ return 1;
+ }
+ if (side1 + side2 < side3 || side1 + side3 < side2 || side2 + side3 < side1)
+ {
+ printf("\nEntered triangle is not VALID.");
+ return 1;
+ }
+ // isosceles check
+ if (side1 == side2 || side2 == side3 || side3 == side1)
+ printf("\nEntered triangle is a ISOSCELES triangle.");
+ else
+ printf("\nEntered triangle is NOT a ISOSCELES triangle.");
+ // equilateral check
+ if (side1 == side2 && side2 == side3)
+ printf("\nEntered triangle is a EQUILATERAL triangle.");
+ else
+ printf("\nEntered triangle is NOT a EQUILATERAL triangle.");
+ // scalene check
+ if (side1 != side2 && side2 != side3)
+ printf("\nEntered triangle is a SCALENE triangle.");
+ else
+ printf("\nEntered triangle is NOT a SCALENE triangle.");
+ // right-angle check
+ if (fabs(((side1 * side1) + (side2 * side2)) - (side3 * side3)) < EPSILON ||
+ fabs(((side2 * side2) + (side3 * side3)) - (side1 * side1)) < EPSILON ||
+ fabs(((side3 * side3) + (side1 * side1)) - (side2 * side2)) < EPSILON)
+ printf("\nEntered triangle is a RIGHT-ANGLED triangle.");
+ else
+ printf("\nEntered triangle is NOT a RIGHT-ANGLED triangle.");
+ return 0;
+}+
\ No newline at end of file
diff --git a/letusc-exercises/lucproblem001.c b/letusc-exercises/lucproblem001.c
@@ -0,0 +1,33 @@
+/* Consider a currency system in which there are notes of six denominations,
+namely, Rs. 1, Rs. 2, rs. 5, Rs. 10, Rs. 50, Rs. 100. If a sum
+of Rs. N is entered through the keyboard, Write a program to compute
+the smallest number of notes that will combine to give Rs. N. */
+/* Author - Amit Dutta, Date - 29th SEP, 2025 */
+/* Let Us C, Chap - 2, Page - 22, Problem 2.3 */
+
+#include <stdio.h>
+int main()
+{
+ int n, nonotes, temp;
+ printf("Enter the amount : ");
+ scanf("%d", &n);
+ if (n < 1)
+ {
+ printf("\nAmount should be a positive integer.");
+ return 1;
+ }
+ temp = n;
+ nonotes = n / 100;
+ n = n % 100;
+ nonotes = nonotes + (n / 50);
+ n = n % 50;
+ nonotes = nonotes + (n / 10);
+ n = n % 10;
+ nonotes = nonotes + (n / 5);
+ n = n % 5;
+ nonotes = nonotes + (n / 2);
+ n = n % 2;
+ nonotes = nonotes + n;
+ printf("\nthe smallest number of notes that will combine to give Rs. %d : %d", temp, nonotes);
+ return 0;
+}+
\ No newline at end of file
diff --git a/letusc-exercises/lucproblem002.c b/letusc-exercises/lucproblem002.c
@@ -0,0 +1,18 @@
+/* A year is entered through the keyboard, write a program to
+determine whether the year is leap or not. Use the logical operators
+&& and || . */
+/* Author - Amit Dutta, Date - 02th OCT, 2025 */
+/* Let Us C, Chap - 4, Page - 64, Problem 4.1 */
+
+#include <stdio.h>
+int main()
+{
+ int year;
+ printf("Enter year : ");
+ scanf("%d", &year);
+ if (year % 4 == 0 && year & 100 != 0 || year % 400 == 0)
+ printf("\nYear %d is a leapyear.", year);
+ else
+ printf("\nYear %d is not a leapyear.", year);
+ return 0;
+}+
\ No newline at end of file
diff --git a/letusc-exercises/lucproblem003.c b/letusc-exercises/lucproblem003.c
@@ -0,0 +1,30 @@
+/* If a character is entered through the keyboard, Write a program
+to determine whether the character is a capital letter, a small case letter,
+a digit or a speacial symbol.
+The following table shows the range of ASCII values for various characters :
+ Characters ASCII Values
+ A - Z 65 - 90
+ a - z 97 - 122
+ 0 - 9 48 - 57
+ special symbols 0 - 47, 58 - 64, 91 - 96, 123 - 127
+*/
+/* Author - Amit Dutta, Date - 02th OCT, 2025 */
+/* Let Us C, Chap - 4, Page - 65, Problem 4.2 */
+
+#include <stdio.h>
+int main()
+{
+ char inp;
+ printf("Enter one character : ");
+ scanf(" %c", &inp);
+ if (inp >= 64 && inp <= 90)
+ printf("\nInput '%c' is a CAPITAL LETTER.", inp);
+ if (inp >= 97 && inp <= 122)
+ printf("\nInput '%c' is a SMALL CASE LETTER.", inp);
+ if (inp >= 48 && inp <= 57)
+ printf("\nInput '%c' is a DIGIT.", inp);
+ if (inp >= 0 && inp <= 47 || inp >= 58 && inp <= 64
+ || inp >= 91 && inp <= 96 || inp >= 123 && inp <= 127)
+ printf("\nInput '%c' is a SPECIAL SYMBOL.", inp);
+ return 0;
+}+
\ No newline at end of file
diff --git a/letusc-exercises/lucproblem004.c b/letusc-exercises/lucproblem004.c
@@ -0,0 +1,25 @@
+/* If the lengths of three sides of a triangle are entered through the
+keyboard, write a program to check whether the triangle is valid or not.
+The triangle is valid if the sum of two sides is greater that the largest
+of the three sides. */
+/* Author - Amit Dutta, Date - 02th OCT, 2025 */
+/* Let Us C, Chap - 4, Page - 66, Problem 4.3 */
+
+#include <stdio.h>
+int main()
+{
+ double side1, side2, side3;
+ printf("Enter the length of side1, side2 and side3 of the triangle : ");
+ scanf("%lf %lf %lf", &side1, &side2, &side3);
+ if (side1 <= 0 || side2 <= 0 || side3 <= 0)
+ {
+ printf("\nTriangle sides must be positive.\n");
+ return 1;
+ }
+ if ((side1 + side2 > side3) && (side1 + side3 > side2) && (side2 + side3 > side1))
+ // Triangle Inequality Theorem
+ printf("\nThis triangle is valid.");
+ else
+ printf("\nThis triangle is not valid.");
+ return 0;
+}+
\ No newline at end of file