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
1 change: 1 addition & 0 deletions Hello world
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <stdio.h>
int main()
{
//Print function to print hello world
printf("Hello, World!");
return 0;
}
4 changes: 4 additions & 0 deletions frequency of a character
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ int main()
char str[1000], ch;
int i, frequency = 0;
print("Enter a string: ");
//Main string
gets(str);
printf("Enter a character to find the frequency: ");
//Character whose frequency we want to get
scanf("%c",&ch);
for(i = 0; str[i] != '\0'; ++i)
{
//Whenever we are getting the character ch in the string
//we are incrementing the frequency
if(ch == str[i])
++frequency;
}
Expand Down
3 changes: 3 additions & 0 deletions length of a string
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ int main()
char s[1000];
int i;
printf("Enter a string: ");
//Our string
scanf("%s", s)
//With the help of this loop we are able to count the number of characters in the string
//untill we reach the end
for(i = 0; s[i] != '\0'; ++i)
printf("Length of string: %d", i);

Expand Down