SPL 1.what Is Programming Language?
SPL 1.what Is Programming Language?
3.It is portable. Because it can run on another device with a little bit or no
modification.
6.It is very efficient and fast because of it’s many verity of data type.
8.C compiler combines the capabilities of assembly language with the feature
of higher level language.
4.Structure of a C program:
Ans: The program written in C language is called C program.
Link section: This section provide the instruction to the compiler to link
function from the C library.
Global declaration section: There are some variables that are used in more
than one function.This variables called global variable.This section contains
the global variable .
Main() section: Every program must have a main section .This section divided
into two sub section.One is declaration section and another is executable
section.The declaration section declare the variable which are used in
program .And the executable section execute the program.This two section
have to appear between opening and closing brace.
Sub program section:This section contains all the user defined function which
are called in main() function.
3.Linking the program: The source code are given to the linker.The linker
combines the source code and specified header file and make a file with .exe
file extension.
4.Execute the program: The processor can understand the .exe file and can
perform the task specified in the source code.
1.main()
2.main(void)
3.int main()
4. int main(void)
5. void main()
6. void main(void).
Here, the empty pair of parenthesis of main function indicates that the
function has no argument. This may be explicitly indicates by using the
keyword “void” between the parenthesis. We may also specify the keyword
“int” or “void” by using it before the word main. The “void” keyword means the
function doesn’t return any info to operating system. But the keyword “int”
means the function return an integer value to operating system.We have to
use “return 0” at the end of the program and before the closing brace if we use
“int main ()” function.
Ex: #include<math.h>
9.Difference between
}}printf() & scanf() & getchar & putchar & gets() &
getch() & getche()
scanf() Printf( Putchar( gets( getc getc
getc Puts
) )/putch() ) h() he()
har ()
()
1. it 1. It 1. It 1.It 1. It 1. It 1. It 1.
us used displays used use also also The
ed to the to d to use use puts
to show single read rea d to d to ()
ta the chrctr or d a rea rea func
ke output on acce sing da da tion
in of the screen. pt le cha cha is
pu souce It shows strin cha ract ract very
t code the g ract er er muc
fro in C output. from er fro fro h
m user fro m m simil
us in C. m the the ar to
er the use user prin
in user r tf()
C func
tion.
the
puts
()
func
tion
is
used
to
prin
t the
strin
g.
2.the 2. the ____
syntax syntax ____
of the of the
scanf() printf(
is : ) is :
Syntax Synta
: x:
(“%for (“%fo
mat rmat
specifie specifi
r”,&va er”,va
riable riable
name); name)
;
3.Here, 3.Here 2. It 2. 2. 2.T
variabl , read The The he
e is a variab s rea rea rea
name le is a char din din din
where name acte g g g
we where r don disp disp
store we from ’t laye laye
the store the disp d d
inputte the stan laye on on
d inputt dard d scre scre
value. ed inpu on en. en.
We value. t(std scre An And
must We in) en. d afte
have to don’s & And afte r
add need store afte r rea
“&” to add the r rea d
sign “&” m as rea d the
before sign aC d the cha
the before strin the cha ract
variabl the g cha ract er,it
e variab into ract er, wait
name. le the er,it it s
We name. vari goes goe for
have to We able it’s s ente
use a have until next it’s r
comma to use a stat nex key
betwee a newl eme t to
n two comm ine nt stat go
or a char wit eme to
more betwe acte hou nt the
than en two r or t wit next
two or the wait hou stat
variabl more end ing t eme
e.We than of for wai nt.
have to two file ente ting
create variab is r for
differe le.We reac key. ente
nt have hed. r
variabl to key.
e name create
for as differe
much nt
as variab
value le
we name
want for as
to much
store. as
value
we
want
to
store.
4.The 4.The
data data
type of type
variabl of
e name variab
is le
called name
format is
specifie called
r. We forma
have to t
use a specifi
format er. We
specifie have
r for to use
each a
variabl forma
e .We t
have to specifi
place er for
format each
specifie variab
r le .We
betwee have
n two to
inverte place
d forma
comma t
. We specifi
must er
have to betwe
add en two
“%” invert
before ed
each comm
format a. We
specifie must
r. have
to add
“%”
before
each
forma
t
specifi
er.
5.We 5.We
should should
use use
semicol semico
on at lon at
the end the
of the end of
scanf() the
statem scanf()
ent. statem
ent.
6. Ex: Ex: 3. Ex: 3. 3. 3. 3.E 3.
scanf(“ printf( char ch= EX: Ex: Ex: x: Ex:
%d”,& “%d”, ‘x’ #incl cha cha cha #incl
a); a+b); putch(ch ude r r r ude
);/ <std ch; ch; ch; <stdi
Here, Here,
putchar( io.h ch = ch ch = o.h>
“a” is a throug
ch); > getc = getc #incl
variabl h
h(); getc har( ude
e printf( int he() ); <stri
name. ) ,the mai ; ng.h
where progr n () {
we can am >
store a will char int
integer execut str[5 mai
value e the 0]; n () {
result
of sum char
of a & prin
str[5
b tf(" 0];
value. Ente
ra
prin
strin
tf("
g:
Ente
");
ra
strin
gets(
g:
str);
");
prin gets(
tf(" str);
You
ente
prin
red:
tf("
%s"
You
,
ente
str);
red:
");
retu puts
rn0; (str)
} ;
retu
rn 0;
}
4. 4.
Out Out
put: put:
Ente
Ente
ra
ra
strin
strin
g:
g:
This
This
is
is
my
my
crea
crea
tion
tion
You
You
ente
ente
red:
red:
This
This
is
is
my
my
crea
crea
tion.
tion
Ex: int ma in ()
Here blank space between a & i is not illegal.But we can use use blank
spaces between tokens .It is valid but optional.
In short, between tokens, blank spaces are valid but within token, it is
not valid.
Ex:
Step 1:Start.
Step 3: C=a+b.
Step 4: Print C.
Step 5: Stop.
1. Terminal=
2.input/output=
3.decision=
4..process=
5.flowline=
6.connector=
Ex: start
Input a,b
C=a+b
Print c
end
13. Characterstics of structured programming
language.
1.#include
2.#define
3.#if
4.#else
5.#error
Header file: Header file is a file that contains function declaration and
macro definition for C in-built library functions. All C standard library
functions are declared in many header files which are saved as file
“name.h” .We are including these header files in our C program using
“#include <file_name.h>” command to make use of the functions those
are declared in the header files. When we include header files in our C
program using “#include <filename.h>” command, all C code of the
header files are included in C program. Then, this C program is compiled
by compiler and executed. There are some header file given below:
1.stdio.h
2.conio.h
3.math.h
4.string.h