{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# Midterms - Midterm...

This preview shows pages 1–3. Sign up to view the full content.

Midterm Ex1 #include "stdafx.h" #include "math.h" #include <iostream> using namespace std; void main(){ double n=300, d=1,x; while (n>=1){ d = 1+((1/n)*d); n--; } //cout<<d<<endl; cout<< "Enter integer:" ; cin>>x; cout<<pow(d,x); } Midterm Ex 2 #include "stdafx.h" #include <iostream> using namespace std; int main () { int x, i, j; cout<< "Enter a number in the interval [1,3]: " ; cin>>x; while ((x<1)||(x>3)) {cout<< "You entered an number out of range. Enter a number in the interval [1,3]: " ; cin>>x; } switch (x) { case 1: { for ( int i=0; i<5; i++) {cout<< "1" ;} cout<< "\n" ;} { for ( int i=0; i<5; i++) {cout<< "1" ;} cout<< "\n" ; } { for ( int i=0; i<5; i++) {cout<< "1" ;} cout<< "\n" ;

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
{ for ( int i=0; i<5; i++) {cout<< "1" ;} cout<< "\n" ; } { for ( int i=0; i<5; i++) {cout<< "1" ;} cout<< "\n" ; } break ; case 2: for ( int i=0; i<10; i++) { j=i; if (j<6) { for ( int k=0; k<j; k++) { cout<< "2" ; } cout<< "\n" ; } else { for ( int k=0; k<(10-j); k++) { cout<< "2" ; } cout<< " \n" ; }} break ; case 3: for (i=1; i<10; i++) {j=i; j=10-j; cout<<j<< " " ;} cout<< "\n" ; for (i=2; i<10; i++) {j=i; j=10-j; cout<<j<< " " ;} cout<< "\n" ; for (i=3; i<10; i++) {j=i; j=10-j; cout<<j<< " " ;} cout<<
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 6

Midterms - Midterm...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online