CSCE 101 Extra Credit: C++ Variables, Assignment, Output, and Input, Assignments of Computer Science

The extra credit assignment for csce 101: introduction to computer concepts, spring 2008. Students are required to identify variables, their types, assignment statements, output statements, and input statements in five different c++ programs. The document also includes the code for each program.

Typology: Assignments

Pre 2010

Uploaded on 09/02/2009

koofers-user-6p7
koofers-user-6p7 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSCE 101: Introduction to Computer Concepts
SPRING 2008
Extra Credit Assignment 2
Name: ______________________________________________________________
Section: ________________________________ Grade: _____________
For each one of the following program, provide the following. (2 pt. each).
1. List the variables defined on the program and their corresponding types.
2. List the line numbers corresponding to an assignment statement.
3. List the line numbers corresponding to an output statement.
4. List the line numbers corresponding to an input statement.
5. The output as it would be showed in the screen if you actually run these
programs.
Program 1
Line#
Code
1
#include <iostream.h>
2
main() {
3
int number =6;
4
int weight =1;
5
if (number >= weight)
6
cout << number;
7
else {
8
cout << number;
9
cout << weight;
10
}
11
cout << endl;
12
}
Program 2
Line#
Code
1
#include <iostream.h>
2
main() {
3
int principal =3;
4
principal = principal - 1;
5
while (principal < 3){
6
cout << principal << endl;
7
principal = principal + 1;
8
}
9
}
pf3

Partial preview of the text

Download CSCE 101 Extra Credit: C++ Variables, Assignment, Output, and Input and more Assignments Computer Science in PDF only on Docsity!

CSCE 101: Introduction to Computer Concepts

SPRING 2008

Extra Credit Assignment 2

Name: ______________________________________________________________

Section: ________________________________ Grade: _____________

For each one of the following program, provide the following. (2 pt. each).

  1. List the variables defined on the program and their corresponding types.
  2. List the line numbers corresponding to an assignment statement.
  3. List the line numbers corresponding to an output statement.
  4. List the line numbers corresponding to an input statement.
  5. The output as it would be showed in the screen if you actually run these

programs.

Program 1

Line# Code

#include <iostream.h>

main() {

int number =6;

int weight =1;

if (number >= weight)

cout << number;

else {

cout << number;

cout << weight;

}

cout << endl;

}

Program 2

Line# Code

#include <iostream.h>

main() {

int principal =3;

principal = principal - 1;

while (principal < 3){

cout << principal << endl;

principal = principal + 1;

}

}

Program 3

Line# Code

#include <iostream.h>

main() {

int limit = 1;

int index;

while (limit < 4){

cout << index << endl;

index = 1;

while (index <= 3) {

cout << index << endl;

index = index + 1;

limit = limit + 1;

Program 4

Line# Code

#include <iostream.h>

main() {

int area = 0;

int principal;

while (area < 4){

cout << area << endl;

principal= area;

while (principal <= 4) {

cout << principal << endl;

principal = principal + 1;

area = area + 1;