diff --git a/hackerrank/problem solving/day of the programmer b/hackerrank/problem solving/day of the programmer index a47cd39..2a56fbb 100644 --- a/hackerrank/problem solving/day of the programmer +++ b/hackerrank/problem solving/day of the programmer @@ -29,7 +29,7 @@ int main(){ printf("26.09.1918"); } (y<1919) ? (out = julian(y)) : (out = georgian(y)); - + //The above and below lines are ternary operators, it is basically if else in a single line (out==1) ? (printf("12.09.%d" , y)) : (printf("13.09.%d" , y)); return 0; diff --git a/hackerrank/problem solving/encryption b/hackerrank/problem solving/encryption index 0d39e5f..3d946d9 100644 --- a/hackerrank/problem solving/encryption +++ b/hackerrank/problem solving/encryption @@ -4,13 +4,13 @@ #include int main(){ - char* s = (char *)malloc(10240 * sizeof(char)); - scanf("%s",s); + char* s = (char *)malloc(10240 * sizeof(char)); + scanf("%s",s); //Taking string inputs int len = strlen(s); int columns = ceil(sqrt(len)); - for(int i = 0; i < columns; i++) { - for(int j = i; j < len; j += columns) { - printf("%c", s[j]); + for(int i = 0; i < columns; i++) { //iterating through columns + for(int j = i; j < len; j += columns) { //iterating through strings + printf("%c", s[j]); //printing the answer } printf(" "); }