Posts

Showing posts from June, 2018
Image
"Educating the mind without educating the heart is no education at all." - Aristotle Once a thief, always a thief. ~ American Proverb When glory comes, loss of memory follows. A diamond with a flaw is better than a common stone that is perfect. Everyone's friend is often everyone's foot. "A man is known by the company he keeps." - Our character is reflected in our choice of friends "Don’t put all your eggs in one basket." - Don’t make everything dependent on one thing - Don’t put all your resources into one thing - Don’t depend for your success on a single plan - Don’t concentrate all efforts into one area "When the cat's away, the mice will play." - Without supervision, people will do as they please, especially in disregarding or breaking rules. "Two boys are half a boy, and three boys are no boy at all."- The more boys that help, the less work they do.

Reverse string without using temp

#include <stdio.h> #include <string.h> void reverse(char *, int start, int end); int main(int argc, char **argv) {         if (sizeof(argv) > 1) {                 printf ("Given string :%s\n", *++argv);                 reverse(*argv, 0, strlen(*argv) - 1);                 printf ("String after reverse : %s\n", *argv);         }         return 0; } void reverse(char *str, int start, int end) {         if (start < end) {                 str[start] = str[start] + str[end];                 str[end] = str[start] - str[end];                 str[start] = str[start] - str[end];         } else return;         reverse(str, start + 1, end - 1); } **argv equivalent to argv[][] *argv is equivalent to *argv[0] , content of first index.

Reverse string using recursion

#include <stdio.h> #include <string.h> void reverse(char str[], int, int); int main() {         int size = 0;         char str[20];         printf ("Enter the your string \n");         scanf ("%s", str);         size = strlen(str);         reverse(str, 0, size - 1);         printf ("String after reverse : %s\n", str);         return 0; } void reverse(char str[], int index, int size) {         char temp;         temp = str[index];         str[index] = str[size - index];         str[size - index] = temp;         if (index == (size / 2)) {                 return;         }         reverse(str, index + 1, size); }

String Reverse using temp

#include <stdio.h> #include <string.h> int main() {         char str[20];         char temp;         int i = 0;         int j = 0;         int strlength = 0;         printf ("Enter string to reverse ");         scanf ("%s", str);         strlength = strlen(str);         for (i = 0, j = strlength - 1; i < strlength / 2; i++, j--) {                 temp = str[i];                 str[i] = str[j];                 str[j] = temp;         }         printf (" Reversed string is : %s\n", str);         return 0; }

Passing value from a.out

#include <stdio.h> int main(int argc, char **argv) {         printf ("*argv : %s\n", *argv);         printf ("*++argv :   %s\n", *++argv);         printf ("*argv : %s \n", *argv);         printf ("argv[0] : %s \n", argv[0]);         printf ("**argv : %c \n", **argv);         return 0; }                                         Output :  $ ./a.out chethan mandya *argv : ./a.out *++argv :   chethan *argv : chethan   argv[0] : chethan   **argv : c