1- // / // 👉👉 🔹🔹 Question 1️⃣ create a string firstName & lastName 
2- // to sore details of user & print all characters using a loop 
1+ // / // 👉👉 🔹🔹 Question 1️⃣ create a string firstName & lastName 
2+ // to sore details of user & print all characters using a loop 
33
44// #include <stdio.h> 
55// void string(char arr[]); 
1212// } 
1313// function Definition 
1414// void string(char arr[]){ 
15- // for (int i = 0; arr[i] != '0円'; i++) // spacial in loop => arr[i] | for string 
15+ // for (int i = 0; arr[i] != '0円'; i++) // spacial in loop => arr[i] | for string 
1616// { 
1717// printf("%c" , arr[i]); 
1818// } 
2323// 👉👉 🔹🔹 Question 2️⃣ Ask the user to enter their firstName & print in back to them 
2424// 🌟also try this with their fullName 
2525
26- 2726// #include <stdio.h> 
2827// int main(){ 
29- // char name[20] ; 
30- // printf("Enter Your Firstname : "); 
31- // scanf("%s" , name); 
32- // printf("Your name is %s " , name); 
28+ // char name[20] ; 
29+ // printf("Enter Your Firstname : "); 
30+ // scanf("%s" , name); 
31+ // printf("Your name is %s " , name); 
3332// char str[100] ; 
3433// fgets(str , 100 , stdin); 
3534// puts(str); 
3837
3938// 👉👉 🔹🔹 Question 3️⃣ make a program thats input s user's name & print its length; 
4039
41- 4240// #include <stdio.h> 
4341// int lengthStr(char arr[]); 
4442
5048// return 0; 
5149// } 
5250
53- // // Fucntion Definition 
51+ // // Fucntion Definition 
5452// int lengthStr(char arr[]){ 
5553// int count = 0 ; 
5654// for (int i = 0;arr[i] !='0円'; i++) 
5755// { 
5856// count++; 
5957
6058// } 
61- // return count-1 ; 
62- 
59+ // return count-1 ; 
60+ 6361// } 
6462
6563// 👉👉 🔹🔹 add 2.0 version of 3️⃣rd problem 
6967// int main(){ 
7068// char name[] = " Code-Lover" ; 
7169// int length = strlen(name); 
72- // printf("length is %d\n" , length); 
70+ // printf("length is %d\n" , length); 
7371// return 0; 
7472// } 
7573// 👉👉 🔹🔹 question 4️⃣ take a string input from the user using %c 
10098// { 
10199// scanf("%c" , &ch); 
102100// str[i] = ch; 
103- // i++; 
101+ // i++; 
104102// } 
105103// str[i] = '0円'; 
106104// puts(str); 
107- 
105+ 108106// return 0; 
109107// } 
110108
109+ // |🌟 ✨| salting 
111110
112- // |🌟 ✨| salting  
113- 114- // // 👉👉 🔹🔹 question 5️⃣ find the salted from a password entered by the user  
111+ // // 👉👉 🔹🔹 question 5️⃣ find the salted from a password entered by the user 
115112// if the salt "123" & added that the end 
116113
117- #include  <stdio.h> 
118- #include  <string.h> 
119- void  salting (char  password  []);
120- int  main (){
121-  char  password [100 ] ;
122-  scanf ("%s"  , password );
123-  salting (password ) ;
114+ //  #include <stdio.h>
115+ //  #include <string.h>
116+ //  void salting(char password []);
117+ //  int main(){
118+ //   char password[100] ;
119+ //   scanf("%s" , password);
120+ //  salting(password) ;
124121
122+ // return 0; 
123+ // } 
124+ // void salting(char password []){ 
125+ // char salt [] = "123 "; 
126+ // char newPass[200]; 
127+ // strcpy(newPass , password); // newPass = something 
128+ // strcat( newPass , salt); // new pass = something + 123 || strcat = + 
129+ // puts(newPass); 
130+ // } 
131+ 132+ // // 👉👉 🔹🔹 question 6️⃣ write a fuction named slice , which takes 
133+ // a string & returns sclice from string from index n to m 
134+ 135+ #include  <stdio.h> 
136+ void  sclice (char  str [], int  n , int  m );
137+ int  main ()
138+ {
139+  char  str [] =  "Coder Boy" ;
140+  sclice (str , 3 , 6 ); // Function call 
125141 return  0 ;
126142}
127- void  salting (char  password  []){
128-  char  salt  [] =  "123 " ;
129-  char  newPass [200 ];
130-  strcpy (newPass  , password ); // newPass = something 
131-  strcat ( newPass  , salt ); // new pass = something + 123 || strcat = +  
132- puts (newPass );
133- 134143
144+ // Function Definition 
145+ void  sclice (char  str [], int  n , int  m )
146+ {
147+  char  newStr [45 ];
148+  int  j  =  0 ;
149+  for  (int  i  =  n ; i  <= m ; i ++ , j ++ )
150+  {
151+  newStr [j ] =  str [i ];
152+  }
153+  newStr [j ] =  '0円' ;
154+ 155+  puts (newStr );
135156}
157+ 136158// 1️⃣ 2️⃣ 3️⃣ 4️⃣ 5️⃣ 6️⃣ 7️⃣ 8️⃣ 9️⃣ 🔟 
0 commit comments