Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 09f391c

Browse files
solve 3rd problem of string in C
1 parent cf4c852 commit 09f391c

File tree

3 files changed

+56
-30
lines changed

3 files changed

+56
-30
lines changed

‎a.out‎

192 Bytes
Binary file not shown.

‎solve_problem.c‎

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,67 @@
11
// / // 👉👉 🔹🔹 Question 1️⃣ create a string firstName & lastName
22
// to sore details of user & print all characters using a loop
33

4-
#include <stdio.h>
5-
void string(char arr[]);
6-
int main(){
7-
char firstName [] = "coder";
8-
char lastName [] = "Boy";
9-
string(firstName); // function call
10-
string(lastName); // last name
11-
return 0;
12-
}
4+
// #include <stdio.h>
5+
// void string(char arr[]);
6+
// int main(){
7+
// char firstName [] = "coder";
8+
// char lastName [] = "Boy";
9+
// string(firstName); // function call
10+
// string(lastName); // last name
11+
// return 0;
12+
// }
1313
// function Definition
14-
void string(char arr[]){
15-
for (int i = 0; arr[i] != '0円'; i++) // spacial in loop => arr[i] | for string
16-
{
17-
printf("%c" , arr[i]);
18-
}
19-
printf("\n");
14+
// void string(char arr[]){
15+
// for (int i = 0; arr[i] != '0円'; i++) // spacial in loop => arr[i] | for string
16+
// {
17+
// printf("%c" , arr[i]);
18+
// }
19+
// printf("\n");
2020

21-
}
21+
// }
2222

2323
// 👉👉 🔹🔹 Question 2️⃣ Ask the user to enter their firstName & print in back to them
2424
// 🌟also try this with their fullName
2525

2626

27-
#include <stdio.h>
28-
int main(){
27+
// #include <stdio.h>
28+
// int main(){
2929
// char name[20] ;
3030
// printf("Enter Your Firstname : ");
3131
// scanf("%s" , name);
3232
// printf("Your name is %s " , name);
33-
char str[100] ;
34-
fgets(str , 100 , stdin);
35-
puts(str);
33+
// char str[100] ;
34+
// fgets(str , 100 , stdin);
35+
// puts(str);
36+
// return 0;
37+
// }
38+
39+
// 👉👉 🔹🔹 Question 3️⃣ make a program thats input s user's name & print its length;
40+
41+
42+
#include <stdio.h>
43+
int lengthStr(char arr[]);
44+
45+
int main(){
46+
char name[100];
47+
fgets(name , 100 , stdin) ;
48+
printf("Length is %d" , lengthStr(name));
49+
printf("\n");
3650
return 0;
3751
}
3852

53+
// Fucntion Definition
54+
int lengthStr(char arr[]){
55+
int count = 0 ;
56+
for (int i = 0;arr[i] !='0円'; i++)
57+
{
58+
count++;
59+
60+
}
61+
return count-1 ;
62+
63+
}
64+
3965

4066
// #include <stdio.h>
4167
// int main(){

‎strings.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919

2020
// 🔲
2121

22-
#include <stdio.h>
23-
int main()
24-
{
25-
char *canChange = "Hello Wrold";
26-
puts(canChange);
27-
char *change = "Hello";
28-
puts(change);
29-
return 0;
30-
}
22+
// #include <stdio.h>
23+
// int main()
24+
// {
25+
// char *canChange = "Hello Wrold";
26+
// puts(canChange);
27+
// char *change = "Hello";
28+
// puts(change);
29+
// return 0;
30+
// }
3131

3232
// #include <stdio.h>
3333
// int main(){

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /