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
8 changes: 2 additions & 6 deletions Hello world
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
#include <stdio.h>
int main()
{
printf("Hello, World!");
return 0;
}
#to print the "Hello World in python language
print("Hello, World!!")
6 changes: 3 additions & 3 deletions frequency of a character
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ int main()
{
char str[1000], ch
int i, frequency = 0
print("Enter a string: ");
print("Enter the string in which you want to find the character frequency: ");
gets(str);
printf("Enter a character to find the frequency: ");
printf("Enter a character to find the frequency in the given string: ");
scanf("%c",&ch);
for(i = 0; str[i] != '\0'; ++i)
{
if(ch == str[i])
++frequency;
}
printf("Frequency of %c = %d", ch, frequency);
printf("Frequency of %c = %d in the string provided", ch, frequency);
return 0;
}
4 changes: 2 additions & 2 deletions length of a string
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ int main()
{
char s[1000];
int i;
print("Enter a string: ")
print("Enter a string for which you need to find the length: ")
scan("%s", s)
for(i = 0; s[i] != '\0'; ++i)
printf("Length of string: %d", i);
printf("Length of the provided string: %d", i);

}
11 changes: 6 additions & 5 deletions pgm to read a line
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h> //for exit()
int main()
{
char c[1000]
char ch[1000]
FILE *fptr;
if ((fptr = fopen("program.txt", "r")) == NULL)
{
print("Error! opening file")
print("Error! opening file") // program exits if file pointer returns NULL
exit(1)
}

scanf(fptr,"%[^\n]", c);
printf("Data from the file:\n%s", c);
// reads text untill newline is encountered
scanf(fptr,"%[^\n]", ch);
printf("Data from the file:\n%s", ch);
close(fptr)

return 0;
Expand Down