






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
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Material Type: Notes; Class: PRBLM SOLVNG:COMPUTR; Subject: Computer Science and Engineering ; University: University of Nebraska - Lincoln; Term: Spring 2009;
Typology: Study notes
1 / 10
This page cannot be seen from the preview
Don't miss anything!
CSCE150A
First Program
Variables
Lecture 02 – Programs and Variables
Derrick Stolee
Spring 2009
dstolee@cse.unl.edu
CSCE150A
First Program
Variables
#include <stdio.h>
/* this is a comment! */
int main(void)
{
printf(”This lab is so cool!\n”);
}
CSCE150A
First Program
Variables
int variablename = number;
Stores integer values, 0 , 1 , − 1 , 10242.
Takes 4 bytes.
CSCE150A
First Program
Variables
float variablename = number.decmials;
Stores decimal values, 0. 0 , 1. 234 , − 1234. 5.
Takes 4 bytes.
CSCE150A
First Program
Variables
char variablename = ’c’;
Stores letters, ’A’, ’b’, ’0’, ’\n’, ’\0’.
Takes 1 byte.
CSCE150A
First Program
Variables
printf("string", parameters, ... );
Outputs “string” with a few extras... (%)
Placeholder Variable Type
%d int
%f float
%lf double
%c char
CSCE150A
First Program
Variables
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