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

Angladesh University of Business and Technology: Lab Report-2

This document contains a lab report submitted by Tanvirun Islam Anika to their professor Md. Saddam Hossain. The report details solutions to 3 programming problems - determining the length of a string without built-in functions, concatenating two strings, and splitting a word into meaningful tokens. The solutions provided code snippets in C++ to solve each problem.

Uploaded by

Md Tanvir Islam
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)
14 views

Angladesh University of Business and Technology: Lab Report-2

This document contains a lab report submitted by Tanvirun Islam Anika to their professor Md. Saddam Hossain. The report details solutions to 3 programming problems - determining the length of a string without built-in functions, concatenating two strings, and splitting a word into meaningful tokens. The solutions provided code snippets in C++ to solve each problem.

Uploaded by

Md Tanvir Islam
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/ 4

Bangladesh University of

Business and Technology

Lab Report-2
Course Name : Compiler Design Lab
Course Code : CSE 324
Submission Date : 26 – 07 – 2023

Submitted To:
Md. Saddam Hossain.
Assistant Professor,
Department of Computer Science & Engineering.

Submitted By:
Name: Tanvirun Islam Anika
ID: 21225103045; Intake: 49; Section: 01
Problem No.1: Input a string from user and determine the length
[without using any built in Function].

Solution code:

#include <iostream>
using namespace std;
int main() {
cout << "Enter a string: ";
char str[100];
cin.getline(str, 100);
int length = 0;
for (length=0; str[length] != '\0'; length++) {
}
cout << "Length of the string: " << length << endl;
return 0;
}

Problem No.2: Concat Two strings into one.

Solution code:

#include <iostream>
using namespace std;
int main() {
char str1[100];
char str2[100];
char result[200];
cout << "Enter the first string: ";
cin.getline(str1, 100);
cout << "Enter the second string: ";
cin.getline(str2, 100);
int i = 0;
while (str1[i] != '\0') {
result[i] = str1[i];
i++;
}
int j = 0;
while (str2[j] != '\0') {
result[i] = str2[j];
i++;
j++; }
result[i] = '\0';
cout << "Concatenated string: " <<result<<endl;
return 0;
}

Problem No.3: Split the word into meaning full token.

Solution code:

#include<iostream>
#include<string.h>
using namespace std;
int main(){
string x;
cout<<"Enter string :";
getline(cin,x);
int len=0;
while (x[len]!='\0'){
len++;
}
for(int i=0; i<len; i++){
if(x[i]==' '||x[i]=='.'||x[i]==','||x[i]==';'){
}else{
cout<<x[i];
}
}
return 0;
}

You might also like