You are on page 1of 3

LAB REPORT-01

Write a Program to recognize multiple


white spaces and remove it.
Course code: CSE332
Course Title: Compiler Design Lab
Submitted To:
Shah Md Tanvir Siddiquee
Assistant Professor
Department of Computer Science & Engineering
Submitted By:
MD. Jubair Hossain
Id: 201-15-13590
Section: A (Batch-57)
Department of CSE
Daffodil International University
Topic Name:
Write a Program to recognize multiple white
spaces and remove it.

Language Used: C++


Code:
Description:
Procedure of the program:

1. The string "str" is declared and inputted using the get-line


function.
2. A variable "n" is declared and initialized with the size of the input
string.
3. A for loop starts from 0 to "n-1" and checks each character in the
string.
4. If the current character is a space, all the characters after the
space are shifted one position to the left.
5. The size of the string "n" is decremented by 1 to reflect the
removal of the space.
6. The loop continues checking the next character until all characters
have been checked.

The modified string without spaces is outputted.

You might also like