0% found this document useful (0 votes)
19 views

CS PDF

The document discusses various C programming concepts like functions, structures, arrays, pointers, input/output functions, memory allocation and more. Key functions discussed include scanf, printf, malloc and calloc for memory allocation and input/output. The document also compares arrays and linked lists and discusses call by value vs call by reference.

Uploaded by

shreeya rana
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

CS PDF

The document discusses various C programming concepts like functions, structures, arrays, pointers, input/output functions, memory allocation and more. Key functions discussed include scanf, printf, malloc and calloc for memory allocation and input/output. The document also compares arrays and linked lists and discusses call by value vs call by reference.

Uploaded by

shreeya rana
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

CS VIVA

1. header file: A c file which contains function declarations which can be used by many
files. They are either already written or available (stdio.h, string.h) or are written when
programming.
2. Default return of getchar, fgetc, getc: int
3. Constant variable: value does not change after initialization; default is 0.
static variable: if defined in function can be used everywhere (works outside it’s
scope)
4. Formal parameter: empty brackets among the function’s parameters
actual parameter: only name is passed in the function parameters after being declared
outside function
5. Functions: code blocks which are used to carry out a specific task.
the return of a function returns the control to the function call after the function
execution. It can return a value to the function call too
6. Structures: User-defined data type. Allows to combine data of different types together
size: depends on implementation and minimum size of the sum of the bytes each
parameter of the struct takes
7. Arrays: a collection of elements of similar data type
8. Default variables:
constant: 0
static: 0
local: garbage value
global: 0
9. Call by reference: changes the value of the variable. When the variable reference is
passed as an argument to the parameter in the function call
call by value: doesn’t change the value of the variable. Value is passed as the
argument to the function parameter when calling. A copy of the variable is created.
10. Fflush: used between two getchars to clear the keyboard buffer
11. String functions “\0”- used at the end of characters to denote the end of a string.
NULL character.
12. ‘ ‘ in C is used to denote a character and “ “ for string
13. Memory management
14. Data type: amount of storage to be reserved for a specified variable. Int, float, double
15. Type casting: converting from one datatype into another. Implicitly by the compiler,
explicitly when programming
16. Stdio.h – standard input output
17. Input function: takes the input from the user through keyboard and the scanf
function
output function: prints the data or the user defined message
18. Pointer: A variable which holds the address of another variable
19. Library functions: functions which are defined by C library
20. Output keyword- printf
input keyword: scanf
21. Puts and printf:
no need format specifiers, return value is EOF for puts
22. 1. Array - a collection of similar type data elements
Linked list -a collection of unordered linked elements known as nodes.
2. Array- traversal through indexes.
linked list - traversal through the head until we reach the node.
3. Array - Elements are stored in contiguous address space
Linked List - Elements are at random address spaces.
4. Array - Access is faster.
Linked List - Access is slower.
5. Array- Insertion, and Deletion of an element is not that efficient.
Linked List - Insertion and Deletion of an element is efficient.
6. Array - Fixed Size.
Linked List - Dynamic Size.
7. Array - memory assigned during compile time/ static allocation.
Linked List - Memory assigned during runtime / dynamic allocation.
23. Typedef is a keyword which is used to give another name to an existing data type.
with the new name, underlying data type not known
24. If else- when there is one condition to be checked.
else if- when there are several other alternative conditions to be checked
25. Array initialization:
- initialized without size- number of elements defined in it used to calculate the size
- partial initialization- number of elements stored is less than the size specified;
uninitialized memory locations have default 0
- compile time initializations- datatype a[size]= elements
- designated initializers- few elements in array are initialized, the remaining are given
default value 0
- runtime initialization- running a loop to initialize the values to the arrays index wise
26. Formatted functions- makes use of format specifiers
unformatted functions- don’t use format specifiers
27. Format specifiers- used during input and output functions to tell the compiler the
datatype of variable when using printf and scanf
28. R-value and l-value: right of assignment operator and left of assignment operator
29. Global variable- variable whose scope is the entire program
local variable- scope limited to the functions it is defined in
30. Length of string- strlen
31. The break command unconditionally stops the execution of any loop in which it is
encountered. Break is used in case switch. After each case, break is used to avoid code
fall through. It is used to break out of a loop and run the statements after the loop
instead of running through all cases even after the case satisfying the condition is
found.

• The int scanf (const char *format, ...) function reads the input from the standard input
stream stdin and scans that input according to the format provided.
• The int printf (const char *format, ...) function writes the output to the standard
output stream stdout and produces the output according to the format provided.
• auto variables can only be accessed in the block that they have been declared in
• command line argument is used in main function=supplies parameter to the program
when it is invoked
• token=basic component for creating a program in C- keywords/identifiers/operators
• main () is the starting point of execution, function calls
• null pointer doesn’t point to any memory location
• far pointer 32 bits that can access memory outside the current memory segment
• Near pointer is used to store 16 bits addresses means within current segment on a 16
bit machine.
• huge pointer is 32 bit and can access outside segment. In case of far pointers, a
segment is fixed. In far pointer, the segment part cannot be modified, but in Huge it
can be

• Static Memory Allocation: decided by the compiler. The address can be found using
the address of operator and can be assigned to a pointer. The memory is allocated
before execution or runtime.

• Dynamic Memory Allocation: Memory allocation done at the time of execution (run
time) is known as dynamic memory allocation. Functions calloc () and malloc ()
support allocating dynamic memory. In the Dynamic allocation of memory space is
allocated by using these functions when the value is returned by functions and
assigned to pointer variables.
malloc ()- allocated the requested size of bytes and returns void pointer pointing to
the first byte of allocated space
calloc ()- allocates space, initializes the values to 0 and returns void pointer pointing to
the memory
• Union is a user defined datatype, collection of variables of different data types in the
same memory location.
• sprintf() instead of printing on the console, it stores it in a character buffer specified in
the function
printf() writes the o/p to stdout
• In Call by value, a copy of the variable is passed whereas in Call by reference, a
variable itself is passed
• declaration gives details about the properties of a variable. Whereas, Definition of a
variable says where the variable gets stored.
• getch() method reads a single character from the keyboard and displays immediately
on output screen without waiting for enter key. getch is the the function that waits for
an input from the user
• Dennis Ritchie
• Identifiers should not be longer than 31 characters.
• We use the const qualifier to declare a variable as constant. That means that we
cannot change the value once the variable has been initialized.
• collection of instruction needed to solve a problem=program
• algorithm=Algorithm is a step-by-step procedure, which defines a set of instructions to
be executed in a certain order to get the desired output.
• An integrated development environment (IDE) is software for building applications
that combines common developer tools into a single graphical user interface (GUI).
• Keywords are part of the syntax and they cannot be used as an identifier. For example:
int money; Here, int is a keyword that indicates money is a variable of type int
(integer). 32 are there
• A variable can be thought of as a memory location that can hold values of a specific
type. The value in a variable may change during the life of the program
• Arithmetic Operators · Assignment Operators · Relational Operators, logical
• RAM-RAM gives applications a place to store and access data on a short-term basis. It
stores the information your computer is actively using so that it can be accessed
quickly.
• network- A computer network is a group of computers linked to each other that
enables the computer to communicate with another computer and share their
resources, data, and applications
• void type is A computer network is a group of computers linked to each other that
enables the computer to communicate with another computer and share their
resources, data, and applications

• A string in C (also known as C string) is an array of characters, followed by a NULL


character. To represent a string, a set of characters are enclosed within double quotes
(").
• str(len), str(cat), str(cmp)
• The simplest way that C programming information is stored in a file is sequentially,
one byte after the other. The file contains one long stream of data. File access in C is
simply another form of I/O.
• One of the major advantages of an array is that they can be declared once and reused
multiple times. It represents multiple values by making use of a single variable. This
helps in the improvement of the reusability of code and also improves the readability
of the code.
• The C library function int rand(void) returns a pseudo-random number in the range of
0 to RAND_MAX. RAND_MAX is a constant whose default value may vary between
implementations but it is granted to be at least 32767.
• Pre-processor directives, such as #define and #ifdef , are typically used to make source
programs easy to change and easy to compile in different execution environments.
Directives in the source file tell the pre-processor to take specific action
• file extensions- .c,.h
• Basically, both is used to get the absolute value of the given value. abs() is used for
Integer values whereas fabs() is used for floating type data.
• A programming language implementation is a system for executing computer
programs. The translated code may either be directly executed by hardware, or serve
as input to another interpreter or another compiler.
• Interface, in C, is a code structure that defines a contract between an object and its
user.

What is the size of structure?


What are output n input keywords?
Diff. Between if else and else if.
Can we convert for loop to while loop?
We cannot completely convert for to while loop.
Give answers please

You might also like