You are on page 1of 5

Bangladesh University of Business &Technology

Lab Report: 01
Course Title: Compiler Design Lab
Course Code: CSE-324

Submitted By Submitted To
Name: Muslima Name: Md. Saddam Hossain.

ID: 22234103088 Assistant Professor

Intake:50, Section:3 Department of CSE BUBT


Department of CSE

Date: Signature of the instructor

…………………………...
Problem no 01: Reverse Array
Code:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int a[n];
for(int i=0; i<n; i++)
{
cin>>a[i];
}
for(int i=0; i<n/2; i++)
{
int temp=a[i];
a[i]=a[n-i-1];
a[n-i-1]=temp;
}
for(int i=0; i<n; i++)
{
cout<<a[i]<<endl;
}
}

Output:
Problem no 02: word count from a given
array
Code:
#include<bits/stdc++.h>

using namespace std;

int main()

string s;

getline(cin,s);

stringstream ss;

ss<<s;

string word;

int count=0;

while(ss>>word)

count++;

cout<<count;

}
Output:

Problem no 03: 2nd max & 2nd min from an


array
Code:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int a[n];
for(int i=0; i<n; i++)
{
cin>>a[i];
}
for(int i=0; i<n; i++)
{
sort(a, a+n);
}
cout<<"2nd Max="<<a[n-2]<<endl<<"2nd min="<<a[1];
}
Output:

You might also like