From a7082293b65fd58e4db123f019966e57f7985274 Mon Sep 17 00:00:00 2001 From: thanushhr <117655575+thanushhr@users.noreply.github.com> Date: Tue, 15 Nov 2022 16:45:14 +0530 Subject: [PATCH 1/3] Create big2.c --- big2.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 big2.c diff --git a/big2.c b/big2.c new file mode 100644 index 0000000..e46a7d8 --- /dev/null +++ b/big2.c @@ -0,0 +1,22 @@ +#include +big2() +{ + int num1, num2; + // Ask user to enter the two numbers + printf("Please Enter Two different values\n"); + // Read two numbers from the user + scanf("%d %d", &num1, &num2); + if(num1 > num2) + { + printf("%d is Largest\n", num1); + } + else if (num2 > num1) + { + printf("%d is Largest\n", num2); + } + else + { + printf("Both are Equal\n"); + } + // return 0; +} From f94757ad1bb9c48aba65cd6b42f7733f13010184 Mon Sep 17 00:00:00 2001 From: thanushhr <117655575+thanushhr@users.noreply.github.com> Date: Tue, 15 Nov 2022 16:46:00 +0530 Subject: [PATCH 2/3] Create fact.c --- fact.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 fact.c diff --git a/fact.c b/fact.c new file mode 100644 index 0000000..ce0c890 --- /dev/null +++ b/fact.c @@ -0,0 +1,19 @@ +#include +fact() { + int n, i; + unsigned long long fact = 1; + printf("Enter an integer: "); + scanf("%d", &n); + + // shows error if the user enters a negative integer + if (n < 0) + printf("Error! Factorial of a negative number doesn't exist."); + else { + for (i = 1; i <= n; ++i) { + fact *= i; + } + printf("Factorial of %d = %llu", n, fact); + } + + // return 0; +} From 63c45b96b4086e6a90884250a71714fad8a0db5a Mon Sep 17 00:00:00 2001 From: thanushhr <117655575+thanushhr@users.noreply.github.com> Date: Tue, 15 Nov 2022 16:47:05 +0530 Subject: [PATCH 3/3] Create sort.c --- sort.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 sort.c diff --git a/sort.c b/sort.c new file mode 100644 index 0000000..6110f7d --- /dev/null +++ b/sort.c @@ -0,0 +1,37 @@ +#include + +sort() +{ + //Initialize array + int arr[] = {5, 2, 8, 7, 1}; + int temp = 0; + + //Calculate length of array arr + int length = sizeof(arr)/sizeof(arr[0]); + + //Displaying elements of original array + printf("Elements of original array: \n"); + for (int i = 0; i < length; i++) { + printf("%d ", arr[i]); + } + + //Sort the array in ascending order + for (int i = 0; i < length; i++) { + for (int j = i+1; j < length; j++) { + if(arr[i] > arr[j]) { + temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + + printf("\n"); + + //Displaying elements of array after sorting + printf("Elements of array sorted in ascending order: \n"); + for (int i = 0; i < length; i++) { + printf("%d ", arr[i]); + } + // return 0; +}