From 3cd45bdc6fb76b9b6dff3faf5ec21c1e1c3667a7 Mon Sep 17 00:00:00 2001 From: ANUKAVALEDURGA <117466691+ANUKAVALEDURGA@users.noreply.github.com> Date: Tue, 15 Nov 2022 12:07:50 +0530 Subject: [PATCH 1/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..b931ed3 --- /dev/null +++ b/fact.c @@ -0,0 +1,19 @@ +#include +factorial() { + 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 4d8f93cd47e9156a1256267b20f9409b38fb4ca0 Mon Sep 17 00:00:00 2001 From: ANUKAVALEDURGA <117466691+ANUKAVALEDURGA@users.noreply.github.com> Date: Tue, 15 Nov 2022 12:50:29 +0530 Subject: [PATCH 2/3] Delete fact.c --- fact.c | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 fact.c diff --git a/fact.c b/fact.c deleted file mode 100644 index b931ed3..0000000 --- a/fact.c +++ /dev/null @@ -1,19 +0,0 @@ -#include -factorial() { - 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 76412f54df5ff651e886766c8283f31e954fa67f Mon Sep 17 00:00:00 2001 From: anusha Date: Tue, 15 Nov 2022 07:24:31 +0000 Subject: [PATCH 3/3] added c-project --- ANUSHA/big2.c | 22 ++++++++++++++++++++++ ANUSHA/big3.c | 16 ++++++++++++++++ ANUSHA/fact.c | 19 +++++++++++++++++++ ANUSHA/fib.c | 29 +++++++++++++++++++++++++++++ ANUSHA/main.c | 11 +++++++++++ ANUSHA/makefile | 21 +++++++++++++++++++++ ANUSHA/pal.c | 19 +++++++++++++++++++ ANUSHA/rev.c | 25 +++++++++++++++++++++++++ ANUSHA/sort.c | 29 +++++++++++++++++++++++++++++ ANUSHA/sum2.c | 17 +++++++++++++++++ 10 files changed, 208 insertions(+) create mode 100644 ANUSHA/big2.c create mode 100644 ANUSHA/big3.c create mode 100644 ANUSHA/fact.c create mode 100644 ANUSHA/fib.c create mode 100644 ANUSHA/main.c create mode 100644 ANUSHA/makefile create mode 100644 ANUSHA/pal.c create mode 100644 ANUSHA/rev.c create mode 100644 ANUSHA/sort.c create mode 100644 ANUSHA/sum2.c diff --git a/ANUSHA/big2.c b/ANUSHA/big2.c new file mode 100644 index 0000000..81f16ef --- /dev/null +++ b/ANUSHA/big2.c @@ -0,0 +1,22 @@ +#include + +biggest2() { + int a, b; + printf("Please Enter Two different values\n"); + scanf("%d %d", &a, &b); + + if(a > b) + { + printf("%d is Largest\n", a); + } + else if (b > a) + { + printf("%d is Largest\n", b); + } + else + { + printf("Both are Equal\n"); + } + + // return 0; +} diff --git a/ANUSHA/big3.c b/ANUSHA/big3.c new file mode 100644 index 0000000..a012664 --- /dev/null +++ b/ANUSHA/big3.c @@ -0,0 +1,16 @@ +#include +biggest3() +{ + int num1, num2, num3, largest; + + printf("\n Enter the number1 = "); + scanf("%d", &num1); + printf("\n Enter the number2 = "); + scanf("%d", &num2); + printf("\n Enter the number3 = "); + scanf("%d", &num3); + + largest =((num1>num2 && num1>num3)?num1: (num2>num3)?num2:num3); + printf("Largest number = %d \n",largest); + // return 0; +} diff --git a/ANUSHA/fact.c b/ANUSHA/fact.c new file mode 100644 index 0000000..b931ed3 --- /dev/null +++ b/ANUSHA/fact.c @@ -0,0 +1,19 @@ +#include +factorial() { + 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; +} diff --git a/ANUSHA/fib.c b/ANUSHA/fib.c new file mode 100644 index 0000000..ce5e9a2 --- /dev/null +++ b/ANUSHA/fib.c @@ -0,0 +1,29 @@ +#include +fibonacci() { + + int i, n; + + // initialize first and second terms + int t1 = 0, t2 = 1; + + // initialize the next term (3rd term) + int nextTerm = t1 + t2; + + // get no. of terms from user + printf("Enter the number of terms: "); + scanf("%d", &n); + + // print the first two terms t1 and t2 + printf("Fibonacci Series: %d, %d, ", t1, t2); + + // print 3rd to nth terms + for (i = 3; i <= n; ++i) { + printf("%d, ", nextTerm); + t1 = t2; + t2 = nextTerm; + nextTerm = t1 + t2; + } + +// return 0; +} + diff --git a/ANUSHA/main.c b/ANUSHA/main.c new file mode 100644 index 0000000..203c0c6 --- /dev/null +++ b/ANUSHA/main.c @@ -0,0 +1,11 @@ +main () { + biggest2(); + factorial(); + reverse(); + pallindrome(); + biggest3(); + sum2(); + fibonacci(); + sortnumbers(); +} + diff --git a/ANUSHA/makefile b/ANUSHA/makefile new file mode 100644 index 0000000..2d5a729 --- /dev/null +++ b/ANUSHA/makefile @@ -0,0 +1,21 @@ +ABC.exe:main.o big2.o big3.o fact.o fib.o pal.o rev.o sort.o sum2.o + gcc -o ABC.exe main.o big2.o big3.o fact.o fib.o pal.o rev.o sort.o sum2.o + +main.o:main.c + gcc -c main.c +big2.o:big2.c + gcc -c big2.c +big3.o:big3.c + gcc -c big3.c +fact.o:fact.c + gcc -c fact.c +fib.o:fib.c + gcc -c fib.c +pal.o:pal.c + gcc -c pal.c +rev.o:rev.c + gcc -c rev.c +sort.o:sort.c + gcc -c sort.c +sum2.o:sum2.c + gcc -c sum2.c diff --git a/ANUSHA/pal.c b/ANUSHA/pal.c new file mode 100644 index 0000000..17503c7 --- /dev/null +++ b/ANUSHA/pal.c @@ -0,0 +1,19 @@ +#include +pallindrome() +{ +int n,r,sum=0,temp; +printf("\nenter the number="); +scanf("%d",&n); +temp=n; +while(n>0) +{ +r=n%10; +sum=(sum*10)+r; +n=n/10; +} +if(temp==sum) +printf("palindrome number "); +else +printf("not palindrome"); +//return 0; +} diff --git a/ANUSHA/rev.c b/ANUSHA/rev.c new file mode 100644 index 0000000..1c01c65 --- /dev/null +++ b/ANUSHA/rev.c @@ -0,0 +1,25 @@ +/* using temp variable */ +#include +#include + +reverse() +{ + char Str[100], temp; + int i, j, len; + + printf("\n Actual : "); + gets(Str); + + len = strlen(Str) - 1; + + for (i = 0; i < strlen(Str)/2; i++) + { + temp = Str[i]; + Str[i] = Str[len]; + Str[len--] = temp; + } + + printf("\n Result = %s", Str); + + // return 0; +} diff --git a/ANUSHA/sort.c b/ANUSHA/sort.c new file mode 100644 index 0000000..a6db235 --- /dev/null +++ b/ANUSHA/sort.c @@ -0,0 +1,29 @@ +// C Program To Arrange Numbers in Ascending Order +#include +sortnumbers(){ + int num[25]; + int a, j, i, n; + + // Asking for input + printf("Enter total no. of elements: "); + scanf("%d", &n); + + printf("Enter the numbers one by one\n"); + for (i = 0; i < n; ++i){ + scanf("%d", &num[i]); + } + for (i = 0; i < n; ++i){ + for (j = i + 1; j < n; ++j){ + if (num[i] > num[j]){ + a = num[i]; + num[i] = num[j]; + num[j] = a; + } + } + } + printf("Numbers in ascending order: \n"); + for (i = 0; i < n; ++i){ + printf("%d\n", num[i]); + } +// return 0; +} diff --git a/ANUSHA/sum2.c b/ANUSHA/sum2.c new file mode 100644 index 0000000..5dd570b --- /dev/null +++ b/ANUSHA/sum2.c @@ -0,0 +1,17 @@ +#include + +sum2() { + int a, b, result; + + printf("Enter first number : "); + scanf("%d", &a); + + printf("Enter second number : "); + scanf("%d", &b); + + //add two numbers + result = a + b; + printf("Sum : %d\n", result); + +// return 0; +}