diff --git a/Hello world b/Hello world index 3b7617c..b7da9e7 100644 --- a/Hello world +++ b/Hello world @@ -1,6 +1,2 @@ -#include -int main() -{ - printf("Hello, World!"); - return 0; -} +#to print the "Hello World in python language +print("Hello, World!!") diff --git a/frequency of a character b/frequency of a character index b5334ac..f29b638 100644 --- a/frequency of a character +++ b/frequency of a character @@ -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; } diff --git a/length of a string b/length of a string index 33cd513..3dd2b68 100644 --- a/length of a string +++ b/length of a string @@ -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); } diff --git a/pgm to read a line b/pgm to read a line index 174d15b..27f43e6 100644 --- a/pgm to read a line +++ b/pgm to read a line @@ -1,17 +1,18 @@ #include -#include +#include //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;