Download presentation
Presentation is loading. Please wait.
Published byせぴあ ひろもり Modified over 5 years ago
1
In your notebook… Purpose: What types of data can we store in C
In your notebook… Purpose: What types of data can we store in C? Warmup, Copy these two lines to your notes and then answer in a sentence to tell what each line does. This is a shortcut way to combine those two lines into one line:
2
what happens? works okay?
Download twoChars.c from our web page. Compile and make it work. Copy this table to your notebook. Try each pair above in lines 9 & 10 of your program. Write the results into your notebook. X what happens? works okay? Y 68 ‘D’ 101 (101+1) ‘#’ “#” “boy” “girl”
3
This is CS50 AP. an introduction to the intellectual enterprises of computer science and the art of programming Unit 1 Module 3 © David J. Malan, Doug Lloyd
4
variable names in C, underscore preferred style, camel case is okay too. variable name length is between 1 to 32 characters can have alphabet, upper and low er case, underscore and digits. but cannot start with a digit no spaces in the name!!
5
data types
6
native types
7
int 50 -10 8529923 Stands for integer
50 -10 Stands for integer Holds integers between and
8
char ‘a’ ‘Z’ ‘?’ ‘\n’ Holds characters such as ‘x’ and ‘*’
Must have single quotes only Or Since the computer stores it as an ascii, The actual ascii number
9
float 0.0 33.3
10
double long int Holds extremely large/small floating point values
To avoid math rounding problems, less discarded digits Holds extremely large positive and negative integers
11
const
12
custom CS50 types #include <cs50.h>
13
booleans (bool) true false
14
string “A” “Hello, world!” “Hello, world!\n” “This is CS50.”
15
sizes char 1 byte bool int 4 bytes float string double 8 bytes
long long see more at
16
later this year… user-defined types
typedef, struct, enum
17
Conversion character Description %d integer %f floating-point %c character %s string Example: printf(“My dad’s name is %s and he is %d years old”, x, y);
18
This is CS50 AP.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.