From 67e3bdaf4a16ff4a11d603bf3bbdf391f5758dc1 Mon Sep 17 00:00:00 2001 From: Susmita Paul <137711194+susmita413@users.noreply.github.com> Date: Sat, 27 Apr 2024 02:30:22 +0600 Subject: [PATCH] Add files via upload --- module 11_stringOperation/a_copyString.c | 15 +++++++++ module 11_stringOperation/b_Lex__strcmp_.c | 19 +++++++++++ .../b_Lexicographically_compare.c | 33 +++++++++++++++++++ module 11_stringOperation/c_string_concat_3.c | 20 +++++++++++ .../c_string_concat_FUNC.c | 14 ++++++++ .../c_string_concatenation.c | 19 +++++++++++ module 11_stringOperation/d_Counting_array.c | 26 +++++++++++++++ .../e_Cunting_Array_Char.c | 25 ++++++++++++++ .../e_Cunting_Array_Char01.c | 27 +++++++++++++++ 9 files changed, 198 insertions(+) create mode 100644 module 11_stringOperation/a_copyString.c create mode 100644 module 11_stringOperation/b_Lex__strcmp_.c create mode 100644 module 11_stringOperation/b_Lexicographically_compare.c create mode 100644 module 11_stringOperation/c_string_concat_3.c create mode 100644 module 11_stringOperation/c_string_concat_FUNC.c create mode 100644 module 11_stringOperation/c_string_concatenation.c create mode 100644 module 11_stringOperation/d_Counting_array.c create mode 100644 module 11_stringOperation/e_Cunting_Array_Char.c create mode 100644 module 11_stringOperation/e_Cunting_Array_Char01.c diff --git a/module 11_stringOperation/a_copyString.c b/module 11_stringOperation/a_copyString.c new file mode 100644 index 0000000..81bc2ac --- /dev/null +++ b/module 11_stringOperation/a_copyString.c @@ -0,0 +1,15 @@ +// Copy from ONE string to ANOTHER STRING +// +#include +#include +int main(){ + char a[100], b[100]; + scanf("%s %s",&a,&b); // space will not accept in any string + // for(int i=0; i<=strlen(b); i++){ + // a[i] = b[i] ; // COPY from STRING-b to STRING-a // NULL CHARACTER also copied + // } + + strcpy(a,b); // SAME WORK WITH FUNCTION + printf("%s %s\n",a,b) ; + return 0 ; +} \ No newline at end of file diff --git a/module 11_stringOperation/b_Lex__strcmp_.c b/module 11_stringOperation/b_Lex__strcmp_.c new file mode 100644 index 0000000..87d8760 --- /dev/null +++ b/module 11_stringOperation/b_Lex__strcmp_.c @@ -0,0 +1,19 @@ +// Lexicographically compare WITH "strcmp()" FUNCTION + + +#include +#include + +int main(){ + char a[100], b[100]; + scanf("%s %s",a,b); + + int ans = strcmp(a,b); + + if(ans<0) printf("A is SMALLER"); // most of time ans=-1 + else if(ans==0) printf("SAME STRING"); + else if(ans>0) printf("B is SMALLER"); // most of time ans=1 + + + return 0 ; +} \ No newline at end of file diff --git a/module 11_stringOperation/b_Lexicographically_compare.c b/module 11_stringOperation/b_Lexicographically_compare.c new file mode 100644 index 0000000..0bde931 --- /dev/null +++ b/module 11_stringOperation/b_Lexicographically_compare.c @@ -0,0 +1,33 @@ +// Lexicographically compare + +#include +#include +int main(){ + char a[100], b[100]; + scanf("%s %s",a,b); + int i=0 ; + while(1){ + if(a[i]=='\0' && b[i]=='\0'){ // FOR NULL CHECK + printf("SAME STRING\n"); break ; + } + else if(a[i]=='\0') { + printf("A is smaller\n"); break; + } + else if(b[i]=='\0'){ + printf("B is smaller\n"); break ; + } + + if(a[i]== b[i]){ // FOR LETTER CHECK + i++ ; + } + else if(a[i]>b[i]){ + printf("B is smaller\n"); break ; + } + else { + printf("A is smaller\n"); break ; + } + + + } + return 0 ; +} \ No newline at end of file diff --git a/module 11_stringOperation/c_string_concat_3.c b/module 11_stringOperation/c_string_concat_3.c new file mode 100644 index 0000000..130799f --- /dev/null +++ b/module 11_stringOperation/c_string_concat_3.c @@ -0,0 +1,20 @@ + // STRING CONCATENATION only 3 character // a= apple , b= orange + + // after concat, a= appleora + +#include +#include + +int main(){ + char a[200], b[100]; + scanf("%s %s",&a,&b); + + int k= strlen(a); + for(int i=0; i<=2; i++){ + a[k] = b[i]; + k++ ; + } + a[k]= '\0'; + printf("%s %s", a,b); + return 0 ; +} \ No newline at end of file diff --git a/module 11_stringOperation/c_string_concat_FUNC.c b/module 11_stringOperation/c_string_concat_FUNC.c new file mode 100644 index 0000000..9c735da --- /dev/null +++ b/module 11_stringOperation/c_string_concat_FUNC.c @@ -0,0 +1,14 @@ + // STRING CONCATENATION // a= apple , b= orange + // after concat, a= appleorange + +#include +#include + +int main(){ + char a[200], b[100]; + scanf("%s %s",&a,&b); + strcat(a,b); + + printf("%s %s", a,b); + return 0 ; +} \ No newline at end of file diff --git a/module 11_stringOperation/c_string_concatenation.c b/module 11_stringOperation/c_string_concatenation.c new file mode 100644 index 0000000..c0c1107 --- /dev/null +++ b/module 11_stringOperation/c_string_concatenation.c @@ -0,0 +1,19 @@ + // STRING CONCATENATION // a= apple , b= orange + // after concat, a= appleorange + +#include +#include + +int main(){ + char a[200], b[100]; + scanf("%s %s",&a,&b); + + int k= strlen(a); + for(int i=0; i<=strlen(b); i++){ + a[k] = b[i]; + k++ ; + } + + printf("%s %s", a,b); + return 0 ; +} \ No newline at end of file diff --git a/module 11_stringOperation/d_Counting_array.c b/module 11_stringOperation/d_Counting_array.c new file mode 100644 index 0000000..137e133 --- /dev/null +++ b/module 11_stringOperation/d_Counting_array.c @@ -0,0 +1,26 @@ +// COUNTING ARRAY / FREQUENCY ARRAY // ** INTEGER +// count value 0 to 6 from an ARRAY +// MAIN ARRAY's values start from 0, end with 6. + +#include + +int main(){ + int n; + scanf("%d",&n); + int ar[n]; + for(int i=0; i +#include + +int main(){ + char ar[100]; + scanf("%s",&ar); + + int cnt[26]={0} ; + for(int i=0; i +#include + +int main(){ + char ar[100]; + scanf("%s",&ar); + + int cnt[26]={0} ; + for(int i=0; i