0% found this document useful (0 votes)
26 views2 pages

Lab Questions 28.11.2024

Uploaded by

mohamed.betar93
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

Lab Questions 28.11.2024

Uploaded by

mohamed.betar93
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Questions:

1. Apply the program in figure 6.13 and make it work.


2. Take the entire string “hello my name is Hakan Koyuncu” by using scanf() function. (research on
google)
#include <stdio.h>
int main() {
char str[100];
printf("Enter a string: ");
scanf("%[^\n]", str);
printf("You entered: %s\n", str);
}
3. Check if a string is palindrome (example: Hannah, radar, etc.)

#include <stdio.h>
#include <string.h>
int main() {
char str[100];
int i, length;
int isPalindrome = 1;
printf("Enter a string: ");
scanf("%s", str);
length = strlen(str);
for (i = 0; i < length / 2; i++) {
if (str[i] != str[length - i - 1]) {
isPalindrome = 0;
break;
}
}
if (isPalindrome) {
printf("The string is a palindrome.\n");
} else {
printf("The string is not a palindrome.\n");
}
}
Homework: Check if the input sentence is a “palindrome sentence”.(example: "Madam, I'm Adam."
when considering palindrome sentence, spaces and punctuation are often ignored.) (hint you can
use isalnum() function in ctype.h library)
Questions:
1. Apply the program in figure 6.13 and make it work.
2. Take the entire string “hello my name is Hakan Koyuncu” by using scanf() function. (research on
google)
3. Check if a string is palindrome (example: Hannah, radar, etc.)
4. Homework: Check if the input sentence is a “palindrome sentence”.(example: "Madam, I'm Adam."
when considering palindrome sentence, spaces and punctuation are often ignored.) (hint you can
use isalnum() function in ctype.h library)

You might also like