Programming Flashcards
Whats a computer program
A computer program is a sequence or set of instructions in a
programming language for a computer to execute.
Whats Low level language
● In machine level language, computer only understand digital numbers
i.e. in the form of 0 and 1.
● So, instruction given to the computer is in the form binary digit, which
is difficult to implement instruction in binary code.
● This type of program is not portable.
Whats Low level language
● In machine level language, computer only understand digital numbers
i.e. in the form of 0 and 1.
● So, instruction given to the computer is in the form binary digit, which
is difficult to implement instruction in binary code.
● This type of program is not portable.
Whats Middle level language
● The assembly language is on other hand modified version of machine
level language.
● Here instructions are given in English like word as ADD, SUM, MOV
etc.
● It is easy to write and understand but not understand by the machine. So
the translator used here is assembler to translate into machine level.
● This language is bit easier.
In the assembly level language the data are stored in the computer
register, which varies for different computer. Hence it is not portable.
Whats High level language
High Level Language
● It can be considered as a programmer-friendly language.
● It is easy to understand.
● It is easy to debug.
● It is simple in terms of maintenance.
C, C++, Java, Python
Whats IDE
Integrated Development Environments (IDE)
● The process of editing, compiling, running, and debugging programs is
often managed by a single integrated application known as IDE.
● On Mac OS, CodeWarrior and Xcode are two IDEs.
Whats IDE
Integrated Development Environments (IDE)
● The process of editing, compiling, running, and debugging programs is
often managed by a single integrated application known as IDE.
● On Mac OS, CodeWarrior and Xcode are two IDEs.
Features of C program are
(Simple,Fast,Machine independant,mid-level language)
Features of C Programming Language
● Simple: The basic syntax style of implementing C language is very simple
and easy to learn.
● Fast: The compilation and execution time of C language is fast since there
are lesser inbuilt functions and hence the lesser overhead.
● Machine Independent or Portable: Unlike assembly language, c programs
can be executed on different machines with some machine specific changes.
● Mid-level Programming Language: C is intended to do low-level programming. It is used to develop system applications such as kernel,driver, etc. It also supports the features of a high-level language.
Features of C Programming Language
(Structured Programming Language, Function Rich Library, Dynamic Memory Management)
● Structured Programming Language: C is a structured programming language in the sense that we can break the Program into parts using functions. So, it is easy to understand and modify. Functions also provide code reusability.
● Function Rich Library: C provides a lot of inbuilt functions that make the development fast.
● Dynamic Memory Management: It means that you can utilize and manage
the size of the data structure in C during runtime. C also provides several predefined functions (malloc(), calloc(), and realloc() ) to work with memory
allocation.
Features of C Programming Language
(Pointers,Easy to extend, Case senstivity)
● Pointers: With the use of pointers in C, you can directly interact with
memory. Using the C pointers, you can operate with memory, arrays,
functions, and structures.
● Easy to Extend: Programs written in C language can be extended means
when a program is already written in it then some more features and
operations can be added to it.
● Case sensitivity: It means both upper and lower case characters are treated
differently. Case sensitivity in C language helps to compile the C programs
faster.
Structure of C Language Program is?
- Documentation section
- Preprocessor section
- Definition section
- Global declaration
- Main function
- User defined functions
Whats Documentation section?
Documentation section
● It includes the statement specified at the beginning of a program, such as
a program’s name, date, description, and title.
● It is represented as:
//name of a program
/*
name of a program
*/
● Whatever is written between these two are called comments.
Whats Preprocessor section?
Preprocessor section
● It contains all the header files used in a program.
● It informs the system to link the header files to the system libraries.
● It is given by:
a. #include<stdio.h>
b. #include<conio.h>
● Header files help us to access other’s improved code into our code.
● A copy of these multiple files is inserted into our program before the
process of compilation.
● Semicolon is not used.</conio.h></stdio.h>
What is Definition section!?
● The define section comprises of different constants declared using the
define keyword.
● Semicolon is not used.
● It is given by:
○ #define a 2
?!Whats Global Declaration section
Global Declaration section
● The global declaration section contains global variables, function
declaration, and static variables.
● Variables and functions which are declared in this scope can be used
anywhere in the program.
● It is given by:
○ int num = 18;
Whats Main function?
Main Function
● Every C program must have a main function.
● main() is the first function to be executed by the computer.
● It is like any other function available in the C library.
● Parenthesis () are used for passing parameters (if any) to a function.
● We can also use int or main with the main ().
● The void main() specifies that the program will not return any value.
● The int main() specifies that the program can return integer type data.
Whats Main function?
Main Function
● Every C program must have a main function.
● main() is the first function to be executed by the computer.
● It is like any other function available in the C library.
● Parenthesis () are used for passing parameters (if any) to a function.
● We can also use int or main with the main ().
● The void main() specifies that the program will not return any value.
● The int main() specifies that the program can return integer type data.
Whats User Defined Function?
User Defined Function
● The user defined functions specified the functions specified as per the
requirements of the user.
● For example, color(), sum(), division(), etc.
int sum(int x, int y)
{
return x+y;
}
What are the steps to compile and execute the C programs?
● The compilation is a process of converting the source code into object
code.
● If the source code is error-free, then compiler will generates the object
code or machine code.
● The compilation process can be divided into four steps, i.e.,
○ Preprocessing,
○ Compiling,
○ Assembling, and
○ Linking.
What are the steps to compile and execute the C programs?
● The compilation is a process of converting the source code into object
code.
● If the source code is error-free, then compiler will generates the object
code or machine code.
● The compilation process can be divided into four steps, i.e.,
○ Preprocessing,
○ Compiling,
○ Assembling, and
○ Linking.
Whats Preprocessing?
Preprocessing
● The source code is the code which is written in a text editor and the
source code file is given an extension “.c”.
● This source code is first passed to the preprocessor, and then the
preprocessor program expands this code.
● It removes comments, include header files in source code and replace
macro name with code.
● After expanding the code, the expanded code is passed to the compiler
Explain abt Compiler and Assembler!?
Compiler and Assembler
● The C compiler converts the preprocessed code into assembly code.
● The assembly code is converted into object code by using an assembler.
● The name of the object file generated by the assembler is the same as the
source file.
● The extension of the object file in DOS is ‘.obj,’ and in UNIX, the
extension is ‘.o’.
● If the name of the source file is ‘hello.c’, then the name of the object file
would be ‘hello.obj’.
Whats Linker?
Linker
● Mainly, C programs use library functions.
● These library functions are pre-compiled, and the object code of these
library files is stored with ‘.lib’ (or ‘.a’) extension.
● The main working of the linker is to combine the object code of library
files with the object code of our program.
● Sometimes the situation arises when our program refers to the functions
defined in other files. It links the object code of these files to our
program.
● Therefore, the job of the linker is to link the object code of our program
with the object code of the library files and other files.
● The output of the linker is the executable file.
● In DOS, the extension of the executable file is ‘.exe’, and in UNIX, the
executable file can be named as ‘a.out’.
Whats Loader?
Loader
● The main objective of Loader is to load executable files to main memory
for further execution.
● It helps in allocating the address to executable codes/files.
● Loader is the program of the operating system which loads the
executable file from the hards disk into the primary memory (RAM)
for execution.
C language supports a total of ___ character?
C language supports a total of 256 characters.
The valid characters that we can use in the C
language are?
a. Digits
b. Alphabets
c. Special Symbols
d. Spaces
ASCII stands for ?
ASCII stands for American Standard Code for Information Interchange.
What does
\n
\t
\a
\r
'
"
\0
\?
Means?
● \n (New line) – We use it to shift the cursor control to the new line
● \t (Horizontal tab) – We use it to shift the cursor to a couple of spaces to the right in
the same line.
● \a (Audible bell) – A beep is generated indicating the execution of the program to
alert the user.
● \r (Carriage Return) – We use it to position the cursor to the beginning of the current
line.
● \ (Backslash) – We use it to display the backslash character.
● \’ (Apostrophe or single quotation mark) – We use it to display the single-quotation
mark.
● \” (Double quotation mark)- We use it to display the double-quotation mark.
● \0 (Null character) – We use it to represent the termination of the string.
● \? (Question mark) – We use it to display the question mark. (?)
Whats a keyword?
A keyword is a predefined or reserved word that have special meanings
to the compiler.
What are identifiers?
● Identifier refers to name given to entities such as variables, functions,
structures etc.
● Identifiers must be unique.
What are the rules for naming identifiers are?
Rules for Naming Identifiers in C
● The first character of an identifier should be either an alphabet or an
underscore, and then it can be followed by any of the character, digit, or
underscore.
● The special characters such as ‘*’,’#’,’@’,’$’ are not allowed within an
identifier.
● It should not begin with any numerical digit.
● Identifiers are case sensitive.
● Commas or blank spaces cannot be specified within an identifier.
● Keywords cannot be represented as an identifier.
Explain abt Constants in C?
Constants in C
● Constant is a value that cannot be changed during program execution; it
is fixed.
● In C language, a number or character or string of characters is called a
constant.
● Constants are also called as literals.
What are the ways of declaring Constants?
Constants in C can be declared in two ways.
○ Using const keyword.
○ Using the #define preprocessor.
What kind of integers can be put in a int declaration?!
Decimals (base 10),
hexadecimal (base 16), or octal (base 8).
What kind of integers can be put in a int declaration?!
Decimals (base 10),
hexadecimal (base 16), or octal (base 8).
What are Modifiers in C?
Data Type Modifiers in C
● Type Modifier keywords are used as prefixes to the Built-in Data types
in the declaration or initialization statements.
Explain abt Signed Modifier data type?
It indicates that it can have both negative and positive values.
● This modifier can be applied to data types like int, char, short, and long.
● In C, the value stored in a variable is signed by default.
Syntax
○ signed int age;
Unsigned Data type modifiers.
Data Type Modifiers in C: Unsigned
● An unsigned variable can contain only 0 and positive values
(non-negative values).
● This data type modifier can be used with the types- int, char, short, and
long.
Syntax
○ unsigned int age;
Data type modifiers in C Long?
Data Type Modifiers in C: Long
● The long data type modifier is used when the value to be stored is large
and exceeds the usual integer range.
● It can be applied to int and double data types in C.
● In C, “long int” is equivalent to simply “long” and similarly instead of
“long long int” you can simply write “long long”
● Syntax
○ long int salary;
Data type modifiers in C Short?
Data Type Modifiers in C: Short
● The short data type modifier is used for saving memory consumption.
● It can contain whole numbers.
● It can only be applied with an int data type and it’s also said to be a
16-bit signed integer.
Syntax
○ short int age;
The range of values taken by Integer types?
The size of int is usually 4 bytes (32 bits). And, it can take 232 distinct
states from -2147483648 to 2147483647.
Explain abt Float types in C?
Float Types in C
● In C, floating-point numbers can also be represented in exponential.
● For example,
○ float normalizationFactor = 22.442e2f;
● The size of float (single precision float data type) is 4 bytes.
Explain abt Double types in C?
Double Types in C
● Double is used to define BIG floating-point numbers. It reserves twice
the storage for the number. On
● The size of double (double precision float data type) is 8 bytes.
● Default type of real value is double. Use f to convert the value into float.