Introduction to Algorithms and Programming COMP151 LAB 3 pattern printing Introduction to Algorithms and Programming COMP151
Exercise 1: Print the following : " " " " " " " " " "
#include<iostream> using namespace std; int main() { cout<<"\"\n"; cout<<"\"\t\"\n"; cout<<"\"\t\"\t\"\n"; cout<<"\"\t\"\t\"\t\"\n"; cout<<"\"\t\"\t\"\t\"\t\"\n"; return(0); }
Exercise 2: Print the following: ???????????
#include<iostream> using namespace std; int main() { cout<<"\?\?\?\?\?\?\?\?\?\?\?\n"; cout<<" \?\?\?\?\?\?\?\?\?\?\?\n"; return(0); }
Exercise 3: Print the following: * * * * * * * * * *
#include<iostream> using namespace std; int main() { cout<<"\t\t\t*\n"; cout<<"\t\t*\t\t*\n"; cout<<"\t*\t\t*\t\t*\n"; cout<<"*\t\t*\t\t*\t\t*\n"; return(0); }
Exercise 4: Print the following: * ** ***
#include<iostream> using namespace std; int main() { cout<<" \*\n"; cout<<" \* \*\n"; cout<<" \* \* \*\n"; return(0); }