Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Programs and Variables - Lecture Slides | CSCE 150A, Study notes of Computer Science

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

Typology: Study notes

Pre 2010

Uploaded on 08/31/2009

koofers-user-pvj-1
koofers-user-pvj-1 🇺🇸

5

(1)

10 documents

1 / 10

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSCE150A
First Program
Variables
Computer Science & Engineering 150A
Problem Solving Using Computers Laboratory
Lecture 02 Programs and Variables
Derrick Stolee
Spring 2009
dstolee@cse.unl.edu
1 / 10
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Programs and Variables - Lecture Slides | CSCE 150A and more Study notes Computer Science in PDF only on Docsity!

CSCE150A

First Program

Variables

Computer Science & Engineering 150A

Problem Solving Using Computers – Laboratory

Lecture 02 – Programs and Variables

Derrick Stolee

Spring 2009

dstolee@cse.unl.edu

CSCE150A

First Program

Variables

First Program: The Code

#include <stdio.h>

/* this is a comment! */

int main(void)

{

printf(”This lab is so cool!\n”);

}

CSCE150A

First Program

Variables

Variables: Integers

int variablename = number;

Stores integer values, 0 , 1 , − 1 , 10242.

Takes 4 bytes.

CSCE150A

First Program

Variables

Variables: Floats

float variablename = number.decmials;

Stores decimal values, 0. 0 , 1. 234 , − 1234. 5.

Takes 4 bytes.

CSCE150A

First Program

Variables

Variables: Characters

char variablename = ’c’;

Stores letters, ’A’, ’b’, ’0’, ’\n’, ’\0’.

Takes 1 byte.

CSCE150A

First Program

Variables

Printing

printf("string", parameters, ... );

Outputs “string” with a few extras... (%)

Placeholder Variable Type

%d int

%f float

%lf double

%c char

CSCE150A

First Program

Variables

Cheat Sheet

Var Name Stores Size Placeholder

int Integers 4 bytes %d

float Decimals 4 bytes %f

double Decimals (better) 8 bytes %lf

char Letters 1 byte %c

#include <stdio.h>

int main(void) {

...

}

gcc -o program file.c