Professional Documents
Culture Documents
Villanueva Jerick 1st Year BSIT Week 2-5 Computer Programming
Villanueva Jerick 1st Year BSIT Week 2-5 Computer Programming
Module 2
Exercise 2.2
Multiple Choice
1. C
2. C
3. B
4. C
5. A
6. B
7. A
8. A
9. A
10. A
11. C
12. A
13. A
14. B
15. A
Exercise 2.3
#include<iostream>
int main()
2.) Write C++ program to print the asterisk pattern as shown below.
**
***
****
*****
#include <iostream>
using std::cout;
using std::endl;
using std::cin;
int main()
int n;
cin >> n;
cout<<"*";
}
cout<<"\n";
}
cout<<endl;
return 0;
3.) Write a C++ program to declare 3 integers and 2 float variables. Assign 12, 22, 34, 35.6 and 88.1,
respectively
4.) Write a C++ program that will add and subtract declared integer and float variables. Assign 24, 15,
32.4 and 45.
A. 24 will be added to 15
#include<iostream>
int r;
r=a+b;
return (r);
int main()
int z;
return 0;
the result is 39
#include<iostream>
int r;
r=a+b;
return (r);
int main()
{
int z;
return 0;
the result is 47
C. 45 will be subtracted to 15
#include<iostream>
int r;
r=a-b;
return (r);
int main()
int z;
return 0;
}
the result is 30
#include<iostream>
int r;
r=a-b;
return (r);
int main()
int z;
return 0;
the result is 8
Module 3
Exercise
int main(){
int x=50;
int y(10);
if (x>y){
}
#include <iostream>
int main(){
}
}
Module 4
Exercise
int day = 2;
switch (x) {
Case 1:
System.out.println("Saturday");
break;
Case 2:
System.out.println("Sunday");
Break ;
Break ;
}
Module 5
Exercise
1. Create a function named myFunction and call it inside main().
#include <iostream>
void myFunction(){
int main(){
myFunction();
return 0;