Basic Syntax of C Flashcards
Ignored by the C compiler
Comment
Used to document programs
Comment
Improve readability
Comment
Syntax for one-line comment
Syntax for multi-line comments
// /*...*/
Lines beginning with # are processed by the
preprocessor before compilation
Preprocessor Directive tells the preprocessor to include
<stdio.h>
What does the <stdio.h>
stand for?
Name of the standard library declaration file for all STandard Input and Output functions
Where does every C programs begins execute?
Function main
What function must contain in a C program?
main
What does void mean?
function main does not receive any information
What the function main will perform
Program Statements
Syntax of Program Statements
enclosing a block of program statements of the function within {}
How can statements terminate
Statements are terminated with a semicolon ;
What does the program statement do?
Instructs the computer to perform an action.
Syntax for variable declaration
data type variable_list;
All variables must be declared with _ before they can be used
name and data type
% indicates that
a variable’s value is to be printed, followed by a character representing it’s data type
What to use when printing a statement?
printf
What to use when scanning user input?
scanf
What is f in scanf?
formatted
Used to obtain a value from the user
scanf
Syntax of scanf
scanf(“%format control string”, &address operator)
Symbolic names is also known as
Variable Names
assign symbolic names, known as
variable names, for storing program computations and results
Variables
Variable names can only start with
letter or underscore
Is C case-sensitive?
Yes
giving values in variables is called
assignment
values are called
constants
set name of variable along with the datatype of value that it will store
Declaration
assign value to the variable as per its type
Definition
Types of data types
Integers, Floating, Character
Used for declaring integer variable
Integral Types
Integral type keyword
int
Character type keyword
char
Floating points keyword
float or double
Can hold real numbers and values that contain a decimal point
Floating Points
Difference between float and double in terms of places
float - 6 decimal places
double - 15 decimal places
Difference between float and double in terms of storage
float - 4 byte
double - 8 byte
Modifiers of real numbers (floating-point)
float, double, long double
Modifiers of whole numbers (integer)
short, int, long
Syntax for modifiers/qualifiers
optional_modifier datatype variable_list;
integer declaration syntax
int id;
Extended ASCII has __ codes
256
Alter the meaning of base data types to yield a new data type.
Modifiers/Qualifiers
Used to distinguish signed and unsigned integers.
Modifiers/Qualifiers
unsigned modifier means
variable cannot hold negative values.
signed modifier means
a variable can hold both positive and negative values.
size of modifier double
8 bytes
size of modifier long
10 bytes