

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Lab; Class: Programming & Problem Solving I; Subject: Computer Engr & Computer Sci; University: California State University - Long Beach; Term: Fall 2003;
Typology: Lab Reports
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Write a C++ program to generate and count all the bit strings of length 8 that contain 4 consecutive ones, starting with the prototype program given below. Program prototype ////////////////////////////////////////////////////////////// // // // Add prolog comments as per Documentation Guidelines // // /////////////////////////////////////////////////////////////// #include
When your program executes, it should produce output as in the following sample dialogue: All bit strings of length 8 that contain 4 consecutive 1s: 00001111 00011110 00011111 00101111 00111100 00111101 00111110 00111111 01001111 01011110 01011111 01101111 01111000 01111001 01111010 01111011 01111100 01111101 01111110 01111111 10001111 10011110 10011111 10101111 10111100 10111101 10111110 10111111 11001111 11011110 11011111 11101111 11110000 11110001 11110010 11110011 11110100 11110101 11110110 11110111 11111000 11111001 11111010 11111011 11111100 11111101 11111110 11111111 Number of bit strings of length 8 with 4 consecutive 1s = 48
C++ Statements Needed : Declaration for int and string variables ( int and string declarations). Output integers and character strings ( cout << ). Integer division ( / ) and the remainder ( % ) operations. for loop. if-else statements.
Do the following: Name your program file lab3.cpp and place it in your 174 subdirectory. Document your program following the Program Documentation Guide which may be accessed through http://www.cecs.csulb.edu/~lam/cecs174/course-notes.html Make sure your program’s output matches the sample dialogue given above. Use script to get a typescript file that captures: a) cat lab3.cpp b) g++ lab3.cpp c) a.out. Print and hand in a hardcopy of the typescript file. Demo your program on the due date.