From 0d88c1dbbb9afa720970a24de65e06a7a1e41ede Mon Sep 17 00:00:00 2001 From: ruthud Date: Wed, 9 Oct 2019 18:08:40 +0530 Subject: [PATCH 01/12] program added --- C/program-40/program.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 C/program-40/program.c diff --git a/C/program-40/program.c b/C/program-40/program.c new file mode 100644 index 00000000..d9aa6b11 --- /dev/null +++ b/C/program-40/program.c @@ -0,0 +1,22 @@ +/*Write a C program to find the Ackermann of 2 Numbers*/ + +#include +int ack(int m,int n) +{ + if(m==0) + return n+1; + else if(m!=0 && n==0) + return ack(m-1,1); + else if (m!=0 && n!=0) + return ack(m-1,ack(m,n-1)); +} + +int main() +{ + int a,b,c; + printf("Enter 2 Elements:\n"); + scanf("%d%d",&a&b); + c=ack(a,b); + printf("Ackermann(%d,%d)=%d",a,b,c); + return 0; +} \ No newline at end of file From 78bdd2c1d94909943fc52dd9f8989dc9d0eb18dd Mon Sep 17 00:00:00 2001 From: Swasthik shetty <42874695+swaaz@users.noreply.github.com> Date: Wed, 9 Oct 2019 22:58:42 +0530 Subject: [PATCH 02/12] Update contribution.md --- .github/ISSUE_TEMPLATE/contribution.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/contribution.md b/.github/ISSUE_TEMPLATE/contribution.md index fd6a3834..3b2fc26b 100644 --- a/.github/ISSUE_TEMPLATE/contribution.md +++ b/.github/ISSUE_TEMPLATE/contribution.md @@ -3,7 +3,7 @@ - Clone it using command :
 $ git clone paste_the_copied_url.
- Open folder "C/Python" : -
$ cd filder_name
+
$ cd folder_name
eg:cd C - Create new branch :
 $ git branch new_branch_name
From f6ccad8e9524264e89e02346c85e8a8355fa184f Mon Sep 17 00:00:00 2001 From: Swasthik shetty <42874695+swaaz@users.noreply.github.com> Date: Wed, 9 Oct 2019 23:00:37 +0530 Subject: [PATCH 03/12] Update contribution.md --- .github/ISSUE_TEMPLATE/contribution.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/contribution.md b/.github/ISSUE_TEMPLATE/contribution.md index 3b2fc26b..377f463e 100644 --- a/.github/ISSUE_TEMPLATE/contribution.md +++ b/.github/ISSUE_TEMPLATE/contribution.md @@ -2,6 +2,8 @@ - Fork this [repo](https://github.com/swaaz/basicprograms) - Clone it using command :
 $ git clone paste_the_copied_url.
+- Open folder "basicprograms" : +
$ cd basicprograms
- Open folder "C/Python" :
$ cd folder_name
eg:cd C From 2b49370bd918996b1b9eed8d1a8c9da847f7e16d Mon Sep 17 00:00:00 2001 From: Swasthik shetty <42874695+swaaz@users.noreply.github.com> Date: Wed, 9 Oct 2019 23:54:04 +0530 Subject: [PATCH 04/12] Update program.c --- C/program-40/program.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/C/program-40/program.c b/C/program-40/program.c index d9aa6b11..f48a3382 100644 --- a/C/program-40/program.c +++ b/C/program-40/program.c @@ -15,8 +15,8 @@ int main() { int a,b,c; printf("Enter 2 Elements:\n"); - scanf("%d%d",&a&b); + scanf("%d%d",&a,&b); c=ack(a,b); printf("Ackermann(%d,%d)=%d",a,b,c); return 0; -} \ No newline at end of file +} From 631dcd147545e217207f34212b95bddedcef302a Mon Sep 17 00:00:00 2001 From: Swasthik shetty <42874695+swaaz@users.noreply.github.com> Date: Wed, 9 Oct 2019 23:57:25 +0530 Subject: [PATCH 05/12] Update README.md --- C/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/C/README.md b/C/README.md index 5281951b..85265768 100644 --- a/C/README.md +++ b/C/README.md @@ -41,4 +41,5 @@ | Program-37 | Program to find the fibonacci sequnce using recursion | | Program-38 | Program to find the factorial of a number using recursion | | Program-39 | Program to find the GCD of a number using recursion | +| Program-40 | Program to find the ackerman of given two numbers| From f48f89e7be2a08115c4e199f3cf91b9a3527edaa Mon Sep 17 00:00:00 2001 From: RachithaRai <44114164+RachithaRai@users.noreply.github.com> Date: Sat, 12 Oct 2019 19:08:18 +0530 Subject: [PATCH 06/12] added program --- C/program-41/program.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 C/program-41/program.c diff --git a/C/program-41/program.c b/C/program-41/program.c new file mode 100644 index 00000000..2cd3cd17 --- /dev/null +++ b/C/program-41/program.c @@ -0,0 +1,14 @@ +/*To find sum of two numbers without using any operator*/ +#include + +int add(int x, int y) +{ + return printf("%*c%*c", x, ' ', y, ' '); +} + +// Driver code +int main() +{ + printf("Sum = %d", add(3, 4)); + return 0; +} From 9af8de72909564a9ea272666949776ccffe1a404 Mon Sep 17 00:00:00 2001 From: RachithaRai <44114164+RachithaRai@users.noreply.github.com> Date: Sat, 12 Oct 2019 19:13:30 +0530 Subject: [PATCH 07/12] Update README.md --- C/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/C/README.md b/C/README.md index 85265768..4b192d35 100644 --- a/C/README.md +++ b/C/README.md @@ -42,4 +42,5 @@ | Program-38 | Program to find the factorial of a number using recursion | | Program-39 | Program to find the GCD of a number using recursion | | Program-40 | Program to find the ackerman of given two numbers| +| Program-41 | Program to find sum of two numbers without using any operator | From 9388dda25cc726627a8224e4a542e4517468eb12 Mon Sep 17 00:00:00 2001 From: sharan sk <46704651+sharansk792000@users.noreply.github.com> Date: Sat, 12 Oct 2019 23:12:57 +0530 Subject: [PATCH 08/12] Create program42.c --- C/program42/program42.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 C/program42/program42.c diff --git a/C/program42/program42.c b/C/program42/program42.c new file mode 100644 index 00000000..5a6154b0 --- /dev/null +++ b/C/program42/program42.c @@ -0,0 +1,17 @@ +/*C Program to print Floyd’s triangle*/ +// Without using a temporary variable and with only one loop +#include +void floyd(n){ + int i,j=1; + for (i=1;i<=(n*(n+1))/2;i++){ + printf("%d ",i); + if(i==(j*(j+1))/2){ + printf("\n"); + j++; + } + } +} + +int main(){ + floyd(6); +} From b7bb977471d3fa0d128b794e2bc9c042512d8cf0 Mon Sep 17 00:00:00 2001 From: sharan sk <46704651+sharansk792000@users.noreply.github.com> Date: Sat, 12 Oct 2019 23:22:48 +0530 Subject: [PATCH 09/12] Create program.c --- C/Program-43/program.c | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 C/Program-43/program.c diff --git a/C/Program-43/program.c b/C/Program-43/program.c new file mode 100644 index 00000000..35e5b447 --- /dev/null +++ b/C/Program-43/program.c @@ -0,0 +1,45 @@ + +// C program for printing the hollow triangle pattern + +#include + +// Function for printing pattern +void pattern(int N) +{ + int i, j, k = 0, space = 1, rows = N; + + // For printing stars + for (i = rows; i >= 1; i--) { + for (j = 1; j <= i; j++) { + printf("*"); + } + if (i != rows) { + // for printing space + for (k = 1; k <= space; k++) { + printf(" "); + } + + // increment by 2 + space = space + 2; + } + for (j = i; j >= 1; j--) { + if (j != rows) + printf("*"); + } + printf("\n"); + } + printf("\n"); +} + +// Driver code +int main() +{ + + // Get N + int N = 6; + + // Print the pattern + pattern(N); + + return 0; +} From ab3be0cd2ad8ca2401567108b38a7ceb6a9fb063 Mon Sep 17 00:00:00 2001 From: sharan sk <46704651+sharansk792000@users.noreply.github.com> Date: Sat, 12 Oct 2019 23:29:57 +0530 Subject: [PATCH 10/12] Create program.c --- C/program-44/program.c | 48 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 C/program-44/program.c diff --git a/C/program-44/program.c b/C/program-44/program.c new file mode 100644 index 00000000..24dbbcb7 --- /dev/null +++ b/C/program-44/program.c @@ -0,0 +1,48 @@ +// C implementation of the approach +#include + +// Function to print the desired +// Alphabet Z Pattern +void alphabet_Z_Pattern(int N) +{ + int index, side_index, size; + + // Declaring the values of Right, + // Left and Diagonal values + int Top = 1, Bottom = 1, Diagonal = N - 1; + + // Loop for printing the first row + for (index = 0; index < N; index++) + printf("%d ", Top++); + + printf("\n"); + + // Main Loop for the rows from (2 to n-1) + for (index = 1; index < N - 1; index++) { + + // Spaces for the diagonals + for (side_index = 0; side_index < 2 * (N - index - 1); + side_index++) + printf(" "); + + // Printing the diagonal values + printf("%d", Diagonal--); + + printf("\n"); + } + + // Loop for printing the last row + for (index = 0; index < N; index++) + printf("%d ", Bottom++); +} + +// Driver Code +int main() +{ + // Size of the Pattern + int N = 5; + + alphabet_Z_Pattern(N); + + return 0; +} From 643a9e98bb802f168bcbbb8c68274db651282e42 Mon Sep 17 00:00:00 2001 From: sharan sk <46704651+sharansk792000@users.noreply.github.com> Date: Sat, 12 Oct 2019 23:35:49 +0530 Subject: [PATCH 11/12] Create program.c --- C/program-45/program.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 C/program-45/program.c diff --git a/C/program-45/program.c b/C/program-45/program.c new file mode 100644 index 00000000..a19e4af8 --- /dev/null +++ b/C/program-45/program.c @@ -0,0 +1,37 @@ + +// C program to illustrate the above given pattern of numbers. +#include + +int main() +{ + int n = 5, i, j, num = 1, gap; + + gap = n - 1; + + for ( j = 1 ; j <= n ; j++ ) + { + num = j; + + for ( i = 1 ; i <= gap ; i++ ) + printf(" "); + + gap --; + + for ( i = 1 ; i <= j ; i++ ) + { + printf("%d", num); + num++; + } + num--; + num--; + for ( i = 1 ; i < j ; i++) + { + printf("%d", num); + num--; + } + printf("\n"); + + } + + return 0; +} From 82d01e6ef8f8f76b5d4a29da8655bc003dc4fdab Mon Sep 17 00:00:00 2001 From: swaaz Date: Mon, 21 Oct 2019 22:05:31 +0530 Subject: [PATCH 12/12] updated --- C/README.md | 5 +++++ C/{program42 => program-42}/program42.c | 0 2 files changed, 5 insertions(+) rename C/{program42 => program-42}/program42.c (100%) diff --git a/C/README.md b/C/README.md index 4b192d35..5076d0b7 100644 --- a/C/README.md +++ b/C/README.md @@ -43,4 +43,9 @@ | Program-39 | Program to find the GCD of a number using recursion | | Program-40 | Program to find the ackerman of given two numbers| | Program-41 | Program to find sum of two numbers without using any operator | +| Program-42 | Program to print Floyd’s triangle Without using a temporary variable and with only one loop | +| Program-43 | Program for printing the hollow triangle pattern | +| Program-44 | Program for implementation of the approach | +| Program-45 | Program to illustrate the above given pattern of numbers. | + diff --git a/C/program42/program42.c b/C/program-42/program42.c similarity index 100% rename from C/program42/program42.c rename to C/program-42/program42.c