C programming 2 marks
1.what is c programming ?
C is a high-level language devoleped by dennis ritche in 1972 and general purpose
programming language that is ideal for firmware or portable application. it is proven,
flexible and powerful and may be used for a variety of different applications
2.features of c ?
Features of C Programming Language:
1. Procedural Language
2. Fast and Efficient
3. Modularity
4. Statically Type
5. General-Purpose Language
6. Rich set of built-in Operators
7. Libraries with rich Functions
8. Middle-Level Language
9. Portability
10. Easy to Extend
3.importance of c ?
C is a procedure oriented computer programming language which means we can
use C to create lists of instructions for a computer to follow to solve specific
C programming 2 marks 1
problem or in other word to develop computer software.
C is feature rich powerful general purpose computer programming language.
4.what is c preprocessor ?
The C preprocessor is a micro processor that is used by compiler to transform your
code before compilation. It is called micro preprocessor because it allows us to add
macros.
All preprocessor directives starts with hash # symbol.
Let's see a list of preprocessor directives.
#include
#define
#undef
#ifdef
#ifndef
#if
#else
#elif
#endif
#error
#pragma
5.syntax for ternary operators with example ?
Syntax
condition ? value_if_true : value_if_false
The statement evaluates to value_if_true if condition is met,
and value_if_false otherwise.
Here’s the above example rewritten to use the ternary operator:
C programming 2 marks 2
int a = 10, b = 20, c;
c = (a < b) ? a : b;
printf("%d", c);
6.what is variables ?
Variables are containers for storing data values. In C, there are different types of
variables (defined with different keywords).
for example: int - stores integers (whole numbers), without decimals, such as 123 or
-123. float - stores floating point numbers, with decimals, such as 19.99 or -19.99.
7.string declaration in c ?
Declaring a String in C
A String in C is an array with character as a data type. C does not directly support string
as a data type, as seen in other programming languages like C++. Hence, character
arrays must be used to display a string in C. The general syntax of declaring a string in
C is as follows:
char variable[array_size];
8.data types ?
Data Types in C
A data type specifies the type of data that a variable can store such as integer, floating,
character, etc.
C programming 2 marks 3
9. C variable types ?
A variable is a name of the memory location. It is used to store data. Its value can be
changed, and it can be reused many times.
Types of Variables in C
There are many types of variables in c:
1. local variable
2. global variable
3. static variable
4. automatic variable
5. external variable
10.Storage class in c ?
C programming 2 marks 4
Storage Classes in C
Storage classes in C are used to determine the lifetime, visibility, memory location, and
initial value of a variable. There are four types of storage classes in C
Automatic
External
Static
Register
11.uses of continue statement in c ?
The continue statement passes control to the next iteration of the nearest
enclosing do , for , or while statement in which it appears, bypassing any
remaining statements in the do , for , or while statement body.
12.break statement ?
The break statement terminates the execution of the nearest enclosing do , for ,
switch , or while statement in which it appears.
Syntax:
While(test exp)
If(condition to break)
{
Break;
C programming 2 marks 5
13.recursion ?
Recursion is the technique of making a function call itself
. This technique provides a way to break complicated problems down into simple
problems which are easier to solve.
Example
Main()
Printf(“this is the example for recursion\n”);
Main();
}
Output: this is an example for recursion
This is an example for recursion
SYNTAX :
Int func()
C programming 2 marks 6
____
____
func();
14.what is function in c ?
Functions in C are the basic building blocks of a C program
. A function is a set of statements enclosed within curly brackets ({}) that take inputs, do
the computation, and provide the resultant output. You can call a function multiple times,
thereby allowing reusability and modularity in C programming.
15.define union in c ?
Union in C is a special data type available in C that allows storing different data
types in the same memory location.
Ex:
union car
{
char name[50];
int price;
};
16.array of pointers ?
Array of pointers
It is collection of addresses (or) collection of pointers
Declaration
Following is the declaration for array of pointers −
datatype *pointername [size];
C programming 2 marks 7
For example,
int *p[5];
It represents an array of pointers that can hold 5 integer element addresses.
17.Types of files in c ?
Now, these data files are available in 2 distinct forms in the C language, namely:
Text Files.
Binary Files.
A C program uses four types of files as follows:
18.what is structure ?
A structure is a key word that create user defined data type in C/C++. A structure
creates a data type that can be used to group items of possibly different types into a
C programming 2 marks 8
single type.
EXAMPLE :
struct address
char name[50];
char street[100];
char city[50];
char state[20];
int pin;
};
19.Why files are needed ?
Need of files in C language
Entire data is lost when the program terminates and storing in a file will preserve
your data even if the program terminates. If you want to enter a large amount of
data, normally, it takes a lot of time to enter them all.
C programming 2 marks 9