You are on page 1of 5

1) Explain the structure of a c-program?

Every c program consists of one or more sections. These sections shown in following figure.
Documentation section Suggested
Header file section
Optional
Global variable section Optional
Main() function section
{
Declaration part Essential
Executable part
}
Sub program section
{ Optional
User defined section
}
Documentation section (or) comment line section:
Documentation section contains
1) Name of the program 2) Name of the author and other information
In c-language comment line placed between the following below.
/* comments */
Ex: /* to write the addition of two numbers */
C Language not accepted multiple comment lines. Comments are written in the program
whenever it is necessary. Comments which are not executable statements.
Header files section (or) Link section: Header file section contains native function of C
Language. It is dynamically links during execution of a program. Header files are very important
for any programming language. The compiler immediately executes the header files before
compile the C Programming code.
They are commonly used header files in C STDIO stands for standard input and output
a) Include<stdio.h> b) Include<conio.h> CONIO stands for console input and output
Global variable section: Some variables are written before main () function. Then the variable is
called global variables. This section declares some variables that are used in more than one function.
These variables are called global variables. This section must be declares the outside all functions.
The scope of the variables entire program. Once we create a global variables entire program
whenever it is necessary.
For example PI value used in the program more functions. Then define the value of the PI
globally.
Syntax: #define variable name<constant value>
EX: #define PI 3.14
Main () function section: every C program has one main () function section. This function has two
parts.
(a) Declaration part: This part declares all the variables used in executable part.
(b) Executable part: The executable part has at least one statement.
Braces: The program execution begins at opening braces and ends at closing braces. All the
declaration statements and executable statements written in between the open and closing braces
only. Opening braces and closing braces should be balanced.
Sub program section: it contains all the user defined functions that are called by main function.
User defined functions are generally placed immediately after main function.
2) Write C Language character set?
A character denotes any alphabet, digit and special symbol used to represent information.
The character is then used to form words, numbers and expressions.
C Character se: a) alphabets i) lower case: a to z
ii) Upper case: A to Z
b) Numbers: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
c) Special symbols: #, {},[],<,>,;, \,/,|
d) White spaces: blanks, horizontal tabs, new line, form feed, carrier return
3) Explain the features of C Language?
1) Program written in C are very efficient and fast. This is due to variety of data types and
powerful operators.
2) C is powerful and flexible language which helps system developers to deliver various complex
tasks with easy. C is used for diverse projects as operating systems, word processors, graphics,
spreadsheets, and even compilers for other languages.
3) C is highly portable language. This means that a C program written for one computer system
can be run on another system with little or no modification.
4) C is easy to extend.
5) Writing C program with user defined functions makes program more simple and easy to
understand.
6) It is easy to debugging, maintenance and testing easier.
7) It is easy to learn
8) It is structured language
9) C is a middle language. Because it supports high level language features and low level
language features.
10) It can be compiled on a variety of computer platforms.
11)It produces efficient programs.
3) What is pseudo code and explain?
The pseudo code is neither an algorithm nor a program. It is an abstract form of a program. It
consists of English like statements which perform the specific operations. It is defined for an
algorithm. It does not use any graphical representation. In pseudo code, the program is represented in
terms of words and phrases, but the syntax of program is not strictly followed.
Advantages:
1) It is easy to write
2) It is easy to understand
3) It is easy to modify
Examples: write a pseudo code to perform the basic arithmetic operations.
Read n1, n2
Sum = n1 + n2
Dif = n1 n2
mult = n1 n2
Quot = n1/n2
Print sum, diff, mult, quot
End.

5. What are different data types available in C- Language?


Every variable in C has a data type. Data types specify the size and type of values that can be stored.
The C language offers a set of data types.
They can be classified into following two categories.
1. Basic data types
2. Derived data types
3. User defined data types
4. Void

C DATA
TYPES

Basic Derived User Void


Defined

Int float char double

Arrays structures union pointer


Type def Enum
I. Basic data types: A basic data type is also called built in data types.
They are 1) integer 2) float 3) character 4) double
1) Integer: we can store 4 bytes of memory. A number without decimal point (or) exponent is
called integer. We can use integers with +sign and sign. Integers we can use long int, short
int, unsigned int.
Ex: +56, -62
2) Float: A number with decimal point (or) exponent is called integer. We can use integers with
+sign and sign. Real numbers referred as float in C. its supports 4bytes of memory.
Ex: +6.9, 3.14159, -2.6, 5E6
3) Char: Character is a data type which can hold the character type data (or) integer data.
We can use ASCII character set only for use as character. The characters must be in single
quotes. Its supports 1bytes of memory.
Ex.s, e,, i, o, 2, 5
4) Double: It is like a float. But support large values. Its supports 8bytes of memory. It is used
whenever float variable is not sufficient.
Type Size(in bytes) Range
Char 1byte -127 to +127
Unsigned char 1byte 0 to 255
integer 2bytes -32,767 to +32767
Unsigned int 2bytes 0 to 65,535
Short int 2bytes -32,767 to +32767
Long int 2bytes -2,147,483,647 to -2,147,483,647
Float 4bytes 3.4e 38 t 3.4e + 38
Double 8bytes 1.7e 308 to 1.7e + 308

II. Derived data types: these are four types


(1)Arrays (2) structures (3) union (4) pointer
Arrays: A sequence of objects same type is called array.
Structures: A sequence of objects is different types is known as structures.
Unions: A sequence of objects different types. Handled one member at a time.
Pointer: It is also data type. This tells the stored place of data item in the memory.
III. User defined data types: these are two types
1) Type def 2) enum
Type def: This is used to declare constant values before main () function.
Enum: it is called enumeration data type. It is used declare dates, weeks, sub range.
IV. Void: It does not return any value to the main () function.
6. Explain the C-Tokens?
The smallest individual units in a C program are called token. The alphabets, numbers and special
symbols are combined to forms these tokens.
They are five types of tokens in C language. They are
1. Key words
2. Identifiers
3. Constants
4. Operators
5. Separators
Keywords: keywords are also called reserved words. These are system defined words. These
meanings have already been defined and these meanings cannot be changed.
Rules for using keywords:
1. Keywords names not used as variable names
2. All keywords must be written in lowercase only
3. C language has 32 keywords.
32 keywords:
auto break case char const continue default do
double else enum extern float for goto if
int long near register return short signed static
switch typedef union unsigned void while
Identifiers: 1) Identifiers names given to variables, functions and arrays.
2) They are the names which are user defined.
3) They are made up combination of letters and digits.
4) Normally an identifier should not be more than 8 characters along.
Rules for using Identifiers:
1. In identifier name the first letter should in alphabet only. They do not accept digits, special
symbols as first letter.
2. They can accept digits in the last of identifier name.
3. Special symbols allow in the middle of identifier name.
4. Identifier name short enough.
5. Easily read, understand and meaning ful.
6. Ex: min1, max_temp, averageMarks these all are valid.
7. C does not permit use of blank spaces, commas, tabs
mi n1,max*temp, $max, 2average, calculate_ are invalid identifiers in C.

You might also like