From 540bc671dd76b688df99e291bf3dd58aa6355940 Mon Sep 17 00:00:00 2001 From: Sunilmp11 <121597387+Sunilmp11@users.noreply.github.com> Date: Mon, 6 Jan 2025 13:36:10 +0530 Subject: [PATCH] Add files via upload --- 123 | 1 + big.c | 18 ++++++++++++++++++ fact.c | 14 ++++++++++++++ main.c | 6 ++++++ makefile | 9 +++++++++ reverse.c | 19 +++++++++++++++++++ 6 files changed, 67 insertions(+) create mode 100644 123 create mode 100644 big.c create mode 100644 fact.c create mode 100644 main.c create mode 100644 makefile create mode 100644 reverse.c diff --git a/123 b/123 new file mode 100644 index 0000000..483fd66 --- /dev/null +++ b/123 @@ -0,0 +1 @@ +Hi this is to test diff --git a/big.c b/big.c new file mode 100644 index 0000000..97e2e3f --- /dev/null +++ b/big.c @@ -0,0 +1,18 @@ +#include + +void big() { + int num1 = 20, num2 = 30, num3 = 10; + int largest; + + if (num1 > num2 && num1 > num3) { + largest = num1; + } else if (num2 > num1 && num2 > num3) { + largest = num2; + } else { + largest = num3; + } + + printf("The largest number is: %d\n", largest); + + // return 0; +} diff --git a/fact.c b/fact.c new file mode 100644 index 0000000..4028f4c --- /dev/null +++ b/fact.c @@ -0,0 +1,14 @@ +#include + +void fact() { + int num = 3; + int factorial = 1; + + for (int i = 1; i <= num; i++) { + factorial *= i; + } + + printf("The factorial of %d is: %d\n", num, factorial); + + // return 0; +} diff --git a/main.c b/main.c new file mode 100644 index 0000000..fa30915 --- /dev/null +++ b/main.c @@ -0,0 +1,6 @@ + + +main() { + big(); + fact(); +} diff --git a/makefile b/makefile new file mode 100644 index 0000000..d5c99d8 --- /dev/null +++ b/makefile @@ -0,0 +1,9 @@ +abc.exe:main.o big.o fact.o + gcc -o abc.exe main.o big.o fact.o + +main.o:main.c + gcc -c main.c +big.o:big.c + gcc -c big.c +fact.o:fact.c + gcc -c fact.c diff --git a/reverse.c b/reverse.c new file mode 100644 index 0000000..5dbfb07 --- /dev/null +++ b/reverse.c @@ -0,0 +1,19 @@ +#include + +int main() { + int num = 12345; // Example number + int reverse = 0; + + printf("Original number: %d\n", num); + + while (num != 0) { + int digit = num % 10; // Extract the last digit + reverse = reverse * 10 + digit; // Build the reversed number + num /= 10; // Remove the last digit + } + + printf("Reversed number: %d\n", reverse); + + return 0; +} +