This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sample i/p:5 | |
| o/p:ABCDEFGHIJ | |
| ABCDEFGHI | |
| ABCDEFGH | |
| ABCDEFG | |
| ABCDEF | |
| #include <stdio.h> | |
| #include <string.h> | |
| int main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sample i/p:aaabccd | |
| o/p:a3b1c2d1 | |
| //Code by using two friends algorithm... | |
| #include <stdio.h> | |
| #include <string.h> | |
| int main() | |
| { | |
| int f=0,s=0,co=0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sample i/p:3 3 | |
| 1 4 7 | |
| 2 5 8 -> convert transpose and then multiply | |
| 3 6 9 | |
| o/p:66 78 90 | |
| 78 93 108 | |
| 90 108 126 | |
| #include <stdio.h> | |
| int main(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sample i/p: 4 | |
| o/p: 4444 | |
| 4414 | |
| 4424 | |
| 4434 | |
| 4444 | |
| #include <stdio.h> | |
| int main() | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sample i/p: 3 | |
| o/p: **0 | |
| *00 | |
| 0*0 | |
| *00 | |
| **0 | |
| #include <stdio.h> | |
| int main() | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sample i/p: 5 | |
| 1 2 5 9 4 | |
| 6 | |
| o/p: 1 1 0 0 0 0 0 | |
| 1 1 1 1 0 0 0 | |
| 1 1 1 1 0 1 1 | |
| 1 1 1 1 0 1 1 | |
| 1 1 1 1 1 1 1 | |
| subset array | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sample o/p:8 6 4 | |
| // Even numbers in an integer... | |
| #include <stdio.h> | |
| void func(int n){ | |
| if(n==0){ | |
| return 0; | |
| }else{ | |
| int r=n%10; | |
| if(r%2==0){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sample i/p:213 | |
| o/p: 6 //sum of the digits in recursively | |
| #include <stdio.h> | |
| int func(int n){ | |
| if(n==0){ | |
| return 0; | |
| }else{ | |
| return (n%10)+func(n/10); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sample i/p: 3 2 1 1 2 1 1 | |
| #include <stdio.h> | |
| int func(int n){ | |
| if(n>0){ | |
| printf("%d ", n); | |
| func(n-1); //same function calling process... | |
| func(n-1); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sample o/p: 6 | |
| #include <stdio.h> | |
| int func(int n){ | |
| if(n>0){ | |
| return func(n-1)+n; //It takes reverse order as recursively... | |
| }else{ | |
| return 0; | |
| } | |
| } |