DSA 3rd Sem Assignment
DSA 3rd Sem Assignment
h>
#include <ctype.h>
return 0;
}
Output:
Enter a string: JSS Acadamy of Technical Education
Vowels: 12
Consonants: 18
Tracing:
1. Start of main() function: vowels and consonants are declared but not yet
initialized.
The string str[100] is declared.
2. User input: Program prompts: "Enter a string: "User enters: "Hello World!"
fgets() reads the input and stores it in str. The content of str is:str = "HellWorld!\n"
3. Call to count Vowels And Consonants():Function call: count Vowels And
Consonants (str, &vowels, &consonants);
vowels = 0; consonants = 0;
The string "Hello World!\n" is passed, along with the addresses of vowels and
consonants.
4. Inside count Vowels And Consonants():
Initialize a pointer ptr to point to the beginning of the string: ptr = str
Start the while loop: while (*ptr != '\0')