Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Here are some simple programs for beginners.

1. Simple Hello World Program.
2. Frequency of a character in a string.
3. How to find the length of a string
4. Program to read a line from a file.
18 changes: 11 additions & 7 deletions length of a string
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#include <stdio.h>
#include <string.h>
int main()
{
char s[1000];
int i;
printf("Enter a string: ");
scanf("%s", s)
for(i = 0; s[i] != '\0'; ++i)
printf("Length of string: %d", i);

char a[100];
int length;
printf("Enter a string to calculate its length\n");
gets(a);
// strlen function to find the length of the string
length = strlen(a);

printf("Length of the string = %d\n", length);

return 0;
}