Problem Solving Using Computers Laboratory - Assignment 2 | CSCE 150A, Assignments of Computer Science

Material Type: Assignment; Class: PRBLM SOLVNG:COMPUTR; Subject: Computer Science and Engineering ; University: University of Nebraska - Lincoln; Term: Spring 2009;

Typology: Assignments

Pre 2010

Uploaded on 08/30/2009

koofers-user-yhd
koofers-user-yhd 🇺🇸

9 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSCE 150A - Problem Solving Using Computers Laboratory - Spring 2009
Lab Assignment 2 - 01/22/2009
Name:
Section: 8:00 11:00 12:30 6:30
Problem 1: “Hello World!”
In this problem, we will write the first program anyone ever writes.
1. Write a program in a file hello.c that displays “Hello World” in the command line.
2. Compile using the command gcc -o hello hello.c
3. Run the program using the command ./hello
4. Show the instructor your output.
Problem 2: Variables
Copy hello.c to variables.c. You will rewrite the main() method to perform the following actions:
1. Store the integer value 12 in a variable called inches per foot.
2. Store the character ‘A’ in a variable called myGrade.
3. Store the decimal value 2.718282 in a variable called euler.
4. Store the decimal value 3.141592653589793 in a variable called PI (requires precision!).
5. Output the value of these variables in order using printf, in the following format:
variablename = value
Be sure to put each expression on a new line. Write the printf placeholders you used for each variable
in the table below.
Variable Placeholder
inches per foot
myGrade
euler
PI
Compile your program to the executable variables.
Q: What command did you use to compile the program?
Answer:
Run your program, and show the output to the instructor.

Partial preview of the text

Download Problem Solving Using Computers Laboratory - Assignment 2 | CSCE 150A and more Assignments Computer Science in PDF only on Docsity!

CSCE 150A - Problem Solving Using Computers Laboratory - Spring 2009

Lab Assignment 2 - 01/22/

Name:

Section: 8:00 11:00 12:30 6:

Problem 1: “Hello World!”

In this problem, we will write the first program anyone ever writes.

  1. Write a program in a file hello.c that displays “Hello World” in the command line.
  2. Compile using the command gcc -o hello hello.c
  3. Run the program using the command ./hello
  4. Show the instructor your output.

Problem 2: Variables

Copy hello.c to variables.c. You will rewrite the main() method to perform the following actions:

  1. Store the integer value 12 in a variable called inches per foot.
  2. Store the character ‘A’ in a variable called myGrade.
  3. Store the decimal value 2.718282 in a variable called euler.
  4. Store the decimal value 3.141592653589793 in a variable called PI (requires precision!).
  5. Output the value of these variables in order using printf, in the following format:

variablename = value Be sure to put each expression on a new line. Write the printf placeholders you used for each variable in the table below.

Variable Placeholder

inches per foot

myGrade

euler

PI

Compile your program to the executable variables. Q: What command did you use to compile the program?

Answer:

Run your program, and show the output to the instructor.