0% found this document useful (0 votes)
3 views

Lab task 3

This lab report from Leading University includes C++ programs for various string manipulations, such as checking for palindromes, anagrams, repeated characters, and hexadecimal digits. Each program is explained with its functionality and logic, detailing how the respective functions operate. The report is submitted by Mohammed Arif Mazeed Sikdar for the Compiler Design & Construction course.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Lab task 3

This lab report from Leading University includes C++ programs for various string manipulations, such as checking for palindromes, anagrams, repeated characters, and hexadecimal digits. Each program is explained with its functionality and logic, detailing how the respective functions operate. The report is submitted by Mohammed Arif Mazeed Sikdar for the Compiler Design & Construction course.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Department of Computer Science and Engineering

Leading University, Sylhet

Lab Report - 3

Topic: Write Programs

Course Code CSE-3316

Course Title Compiler Design & Construction Sessional

Submitted To

Naeem Ahsan Chowdhury


Adjunct Lecturer
Department of Computer Science and Engineering

Submitted By

Name Mohammed Arif Mazeed Sikdar

ID 2012020076

Batch 53(B)

Department of Computer Science and Engineering

Submission Date: 28/08/2023


1) Write C++ program that will check whether the given string is Palindrome or not:

Explanation: Palindrome is a word, phrase, or sequence that reads the same backwards as
forwards. The palindrome() function takes a const string argument and returns a boolean
indicating whether the given string is a palindrome or not. It is done by creating a reversed
version of the input string and then comparing it with the original string.
2) Write C++ program that will check whether two strings are Anagrams of each other or
not:

Explanation: An anagram of a string is another string that contains the same characters, only the
order of characters can be different. The angram() function takes two constant strings as
arguments and returns a boolean indicating whether the two strings are anagrams or not. It is
done by checking if the lengths of the two strings are equal and if their sorted versions are the
same.
3) Write C++ program that will check the Repeated Character in a given string:

Explanation: The repeat() function takes a constant string as an argument and prints out the
characters and the numbers of characters that are repeated in the input string. Inside the function,
an unordered_map named count is used to store the frequency of each character in the input
string. The for loop iterates through each character in the input string. For each character, it
increments its count in the char_count map. After counting the characters frequencies, the
function enters another loop that iterates through the pairs in the count map. It checks if the count
of a character is greater than 1, which means the character is repeated, and if so, it prints the
character using pair.first.
4) Write C++ program that will check whether a character is Hexadecimal digit or not:

Explanation: The hexa() function takes a char argument and returns a boolean indicating
whether the given character is a hexadecimal digit. It does so by calling the isxdigit function,
which checks if the character is a hexadecimal digit. The != 0 part is used to convert the return
value of isxdigit into a bool.

You might also like