becca | pk :where students come first
rq | Introduction to C Language
Q.1: Fillin the blanks. -
w@ A program called is used to convert an assembly
language program into machine language.
(ii) is used for translating a high level language program into
machine language.
(iii) C language was introduced in
(iv) A program written ina language other than machine language is called
(v) IDE stands for
(vi) The first high level Tanguage developed for writing scientific and
engineering programs is
(vii) A statement in C language is Ferteated witha
(viii) A C program consists of one or more _
Answers: (i) assembler (ii) compiler (iii) 1980s (iv) source program
(v) Integrated Development Environment (vi) FORTRAN
(vii) semicolon (;) (viii) functions
Q.2: What are the differences between assembly language and high-
level languages?
Answer:
ASSEMBLY LANGUAGE
Machine languages consist entirely of numbers and are almost impossible for
humans to read and write. Assembly languages have the same structure and set of
commands as machine languages, but they enable a programmer to use names instead
of numbers. .
Each type of CPU has its own machine language and assembly language, so
an assembly language program written for one type of CPU won't run on another. In
the early days of programming, all programs were written in assembly language.
Now, most programs are written in a high-level language such as FORTRAN or C.
Programmers still use assembly language when speed is essential or when they need
to perform an operation that isn’t possible in a high-level language.[i Ratta.pk :where students come first
HIGH-LEVEL LANGUAGE
A high level language hides the micro abstractions such as set of command
required to be performed by the processors such as CPU. C is a high level language
and easy to write, example (i=10, i<10,i++), It is not confined to particular machine.
A programming language such as C, FORTRAN, or Pascal that enables a
programmer to write programs that is more or less independent of a particular type of
computer. Such languages are considered high-level because they are closer to human
languages and further from machine languages. In contrast, assembly languages are
considered low-level because they are very close to machine languages.
The main advantage of high-level languages over low-level languages is that
they are easier to read, write, and maintain. Ultimately, programs written in a high-
level language must be translated into machine language by a compiler or interpreter.
Q.3: Briefly explain the history of C language.
Answer:
C was invented and first implemented by Dennis Ritchie on a DEC PDP-11
that used the UNIX operating system. C is the result of a development process that
started with an older language called BCPL. BCPL was developed by Martin
Richards, and it influenced a language called B, which was invented by Ken
Thompson. B led to the development of C in the 1970s.
In 1983 a committee was established to create an ANSI (American National
Standards Institute) standard that would define the C language once and for all. The
standardization process took six years. The ANSI C standard was finally adopted in
December 1989, with the first copies becoming available in carly 1990, The standard
was also adopted by ISO (International Standards Organization) and is now referred
to as the ANSI/ISO C standard. Today, all mainstream C compilers comply with
Standard C.
Cis often called a middle-level computer language. This does not mean that C
is less powerful, harder to use, or less developed than a high-level language such as
BASIC or Pascal, nor does it imply that C has the cumbersome nature of assembly
language (and its associated troubles). Rather, C is thought of as a middle-level
language because it combines the best elements of high-level languages with the
control and flexibility of assembly language.
7 As a middle-level language, C allows the manipulation of bits, bytes, and
addresses—the basic elements with which the computer functions. Despite this fact C
code is also very portable. Portability means that it is casy to adapt software written
for one type of computer or operating system to another. For example, if you can
easily convert a program written for DOS so that it runs under Windows, that
program is portable
Q.4; What is the purpose of the statement?AS Pattopk :where students come first
include
in aC program?
Answer:
stdi which stands for "standard input/output header", is the header in the
C standard library that contains macro definitions, constants, and declarations of
functions and types used for various standard input and output operations.
Functions declared in stdio.h are extremely popular, since as a part of the C
standard library, they are guaranteed to work on any platform that supports C.
All library functions in C language are declared in header files. Thus,
programmers have to include the stdio.h header in the source code in order to use the
functions declared in it.
Q.5: What is a function? Explain the main() function.
Answer:
FUNCTION
A function in C language is a block of code that performs a specific task. It
has a name and it is reusable i.c. it can be executed from as many different parts in a
C Program as required. It also optionally returns @ value to the calling program
So function in a C program has some properties discussed below.
» Every function has a unique name. This name is used to call function from
“main()” function. A function can be called from within another function.
e A function is independent and it can perform its task without intervention
from or interfering with other parts of the program.
A function performs a specific task. A task is a distinct job that your program
must perform as a part of its overall operation, such as adding two or more
integer, sorting an array into numerical order, or calculating a cube root etc.
« A function retums a value to the calling program. This is optional and
depends upon the task your function is going to accomplish. Suppose you
want to just show few lines through function then it is not necessary to retum
a value, But if you are calculating area of rectangle and wanted to use result
somewhere in program then you have to send back (return) value to the
calling function
C, language is collection of various inbuilt functions. If you have written a
program in C then it is evident that you have used C’s inbuilt functions. Printf, scanf,
clrser etc. all are C’s inbuilt functions. You cannot imagine a C program without
function.
THE MAIN() FUNCTION
When a program begins running, the system calls the function main(, which
marks the entry point of the program. Every program must have one function named