The document is a final assignment for a Data Structure Laboratory course at East Delta University, submitted by Musnat Bin Amin. It includes programming problems related to counting the maximum number of words in sentences and converting strings to snake case format. The assignment features C/C++ code snippets for both problems.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0 ratings0% found this document useful (0 votes)
11 views
Assignment 1 .241004612
The document is a final assignment for a Data Structure Laboratory course at East Delta University, submitted by Musnat Bin Amin. It includes programming problems related to counting the maximum number of words in sentences and converting strings to snake case format. The assignment features C/C++ code snippets for both problems.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 4
EDU
East DELTA
UNIVERSITY
Final Assignment Course Code: 212
Course Title: Data Structure Laboratory
Submitted by
Name:Musnat Bin Amin
1D:241004612
Section:1
Submitted to
Name: Md. Jahidul Hasan Jahid
School of Science, Engineering and Technology
Scanned with
@ camscannerProblem#1
Maximum Number of Words Found in Sentences
A sentence is a list of words that are separated by a single space with no leading or trailing spaces. An user will
provide the number of sentences, and each sentence will terminate with a newline character. Return the
‘maximum number of words appeared in any of the sentences.
#include
#include
#define MAX_SENTENCES 100
##define MAX_LENGTH 1000
int main {
int numSentences;
char sentences[MAX_ SENTENCES][MAX_ LENGTH];
printf("Enter the number of sentences:
scanf("%d", &numSentences);
getchar();
for (int i = 0; i < numSentences; i++) {
printf("Enter sentence %d: ", i+ 1);
fgets(sentences{i], MAX_LENGTH, stdin);
sentences[i){strespn(sentences(i}, "\n")]
}
int maxWords = 0;
for (int i= 0; i maxWords) {
max Words = wordCount;
}
}
‘Scanned with
|CamScannerprintf("Maximum number of words in any sentence: Yd\n", maxWords);
return 0;
ee ee
ECU CeCe Cn stay
TS ee RT og
ESA ER Lee Mt
output
Pers U tM eee Ce GN ee ae
Problem#3
Snake Case
Have the function SnakeCase(str) take the str parameter being passed and return it in proper snake case format
where cach word is lowercase and separated from adjacent words via an underscore. The string will only
contain letters and some combination of delimiter punctuation characters separating each word.
#inelude
#include
#include
void snakeCase(const char* input, char* output) {
int j
for (int i = 0; input[i] != "0; i++) {
char lowerCh = std::tolower(input[i]);
if (stdisalpha(lowerCh)) {
outputfj++] = lowerCh;
pelse {
if {> 0 && outputfj - 1] |:
output{j++] ="
}
}
3
if G> 0 && outputfj - 1)
a
}
output{j] = \0'
J
int main() {
Scanned wth
G camscannerconst char input]
const char input2f]
char output{ 100];
East Delta University*are Awesome";
"abcd-e-f%g";
snakeCase(inputl, output);
std::cout << output << std::endl;
snakeCase(input2, output);
std::cout << output << std::endl;
return 0;
/_are_awesome
canned with
G camscanner