cs10 codes
TRANSCRIPT
-
7/29/2019 CS10 Codes
1/7
Exercise 1/* This program will demonstrate the use of Basic Arithmetic Operation
Created by: Diana Jane T. LazaroDate: October 15, 2012
*/
#include //preprocessor directive
usingnamespace std; //standard namespace
int main() //main function is the entry point of a C++ program{ //begin
//variable declarationsint length, width, perimeter=0, product=0, sum=0;double depth, volume=0, undergroundsurfacearea= 0;
//Inputcoutlength; //cin is the standard input statement in c++coutwidth;
coutdepth;
//Processsum = length + width;
product = length * width;perimeter = 2 * sum;volume = product * static_cast (depth);undergroundsurfacearea = perimeter * static_cast (depth) + product;
//Outputcout
-
7/29/2019 CS10 Codes
2/7
Exercise 2/* This program will demonstrate the use of Basic Arithmetic Operation
Created by: Diana Jane T. LazaroDate: October 15, 2012
*/
#include
usingnamespace std;
int main(){
int object, a=0, b=0, c=0, d=0, e=0;
coutobject;
a = object / 100;b = (object - a * 100) / 50;c = (object - a * 100 - b * 50) / 10;d = (object - a * 100 - b * 50 - c * 10) / 5;e = (object - a * 100 - b * 50 - c * 10 - d * 5) / 1;
cout
-
7/29/2019 CS10 Codes
3/7
/* This program will demonstrate the use of Basic Arithmetic OperationCreated by: Cristina A. PascuaDate: October 15, 2012
*/
#include //preprocessor directiveusingnamespace std; //standard namespace
int main() //main function is the entry point of a C++ program{ //begin
//variable declarationsint num1, num2, sum=0, difference=0, product=0, intquotient=0, intremainder=0;double quotient=0;
//Inputcoutnum1; //cin is the standard input statement in c++coutnum2;
//Processsum = num1 + num2;
difference = num1 - num2;product = num1 * num2;intquotient = num1 / num2;intremainder = num1 % num2;quotient = static_cast (num1) / static_cast (num2);
//Outputcout
-
7/29/2019 CS10 Codes
4/7
/* This program wil prompt the user to input month represented by an integer number (1-12).
Output will be the corresponding month in string.*/
/*#include
using namespace std;
int main(){
int month;
coutmonth;
//solution 1 using if else
if (month == 1)cout
-
7/29/2019 CS10 Codes
5/7
coutmonth;
//solution 2 using switch case
switch (month){
case 1 : cout
-
7/29/2019 CS10 Codes
6/7
/* This program will prompt the user to input an integer month and output how many daysare there in the month entered.*/#includeusingnamespace std;
int main(){ int month;
coutmonth;//solution 1if (month==4 || month==6 || month==9 || month==11)
cout
-
7/29/2019 CS10 Codes
7/7
/* This program will simulate the Rock, Paper, Scissors Game.Created by: Diana Jane T. Lazaro
Date: October 22, 2012*/
#includeusingnamespace std;
int main(){
char P1, P2;
cout