Vous êtes sur la page 1sur 42

About C Language

(
)
.


.
-
.
.


++
.


'C' language:


Friends 'C' language Easy programing language .'C' language
general-purpose

language Dennis Ritchie 1970 Bell Telephone



Friend's 'C' language "
"

"(flowchart)"
( ALGORITHM )

(ALGORITHM):



" "
()





" "

programing language Base

(algorithm)


(algorithm)

(algorithm)


.

Language Programining language

(example:c,c++,java..)

Example:
Problem


Problem1:
Number add (a=2 b=3 c=a+b) ?
solution:



step1: start

step2: (a=2)

step3: (b=3)

step4: nembers add add=a+b
step5: print / display add

step6: end

IN ENGLISH


step1: start

step2: read first number(a=2)

step3: read second number(b=3)

step4: add above two number i.e add=a+b

step5: diplay / print add

step6: end

:

start .

problem1 step1 start .

steps Slove Problem

. start Ending
.

last step(step6) End


problem 2:

Numbers a=2 b=3

(find the biggest number from the given two numbrs a=2 b=3)

solution:



step1: Start

step2: a2

step3: b3

step4: a~b

step5: correct a print

step6: correct b print

step7: end


IN ENGLISH

step1: Start

step2: Read a=2

step3: Read b=3

step4: if a>b = true then

step5: display a is big go to step7

step6: else display b is big

step7:end

:

start .


problem1 step1 start . step2 & step3

Reading numbers. step numbers

a~b . correct next step5 a

decide . step6 step7


end . a~b correct step5 step6

b decide


(FLOW CHAT)


(FLOW CHAT):




.

(Ilowgraph) boxes symbols

(operation)box .

boxes symbols Arrow connect

. arrow connect algorithm


Iigure symbols and
boxes







Example:
Problem 1:

Number add (a=2 b=3 c=a+b) ?
Flow Chat
(Draw a Flow Chat Diagram For Addition Of Two Numbers)

solution1:











: start
.

problem1 step1 start . oval

. 2 & 3 steps values

[parallelogram] . 4 step

addition perIorm [Rectangle]

. 5 th steps output print

[parallelogram] .

start Ending . last
step

(step6) End oval


problem 2:


Numbers a2 b3 .
Flow Chat

(find the biggest number from the given two numbrs a=2 b=3)

solution1:



: start
.

problem1 step1 start . oval

. 2 & 3 steps values input

[parallelogram] . 4

step condition check A

B CHECK Diamond .

6 th steps output print

[parallelogram] .

start Ending . last step (step7)

End oval
( Examples on Algorithm )
Example 1:
(1) N Number add ?
(write an algorith for adding number from 1 to N?)
solution:



step1: start
step2: add
N

step3: add SUM0

step4: CONDITION CHECK IF ( N != 0)
GOTO STEP 5 GOTO STEP 7.

step5: SUM=SUM+N

step 6: N=N-1 GOTO step 4.

step7:Display SUM

step8: end



IN ENGLISH


step1: start
step2:Read N; (N is the value up to we can add)

step3:we want add values from 1 to N so take SUM=0;

step4:Now we want check condition IF ( N != 0) Then

GOTO STEP 5 if else GOTO STEP 7.

step5: SUM=SUM+N

step 6: N=N-1 GOTO step 4.

step7:Display SUM

step8: end
:
start
. problem1

step1 start .step2 problem 1
N

add step 2 add value
.

next 1 value SUM 1
.NEXT STEP

N 0 step 5 N 0 step 7
.

example N 3 now Step 4
condition N!=0 check

N 3 3!0 CORRECT NEXT STEP
SUMSUMN
PERFORM SUM 0 SUM 3 (
SUM03).

STEP 6 NN-1 N 2 ( N 3-1) .


GOTO STEP 4 STEP 4 . STEP4
CONDITION
CHECK NEXT STEP PERFORM .
LOOPING .

STEP 6 STEP 4 N 0 AYE N 0
step 7

SUM VALUE Dispaly
Examples on Flowchart
Example 1:

(1) N Number add ?
(write an algorith for adding number from 1 to N?)
Solution :



:
start
. problem

step1 start .step2 problem 1
N

add step 2 add value
.

next 1 value SUM 1
.NEXT STEP
N 0 step 5 N 0 Arrow step 7
.

example N =3 now Step 4
condition N!=0 check

N 3 3!0 CORRECT Arrow NEXT STEP
SUMSUMN

PERFORM SUM 0 SUM 3 (
SUM03).

STEP 6 NN-1 N 2 ( N 3-1) .


GOTO STEP 4 Arrow STEP 4 .
STEP4
CHECK NEXT STEP PERFORM .
LOOPING .

STEP 6 Arrow STEP 4 N 0
N 0

Arrow step 7 SUM VALUE Dispaly

( C language Introduction )
C Language data
.

( key ) (or )
() () ( data )
.
(
) .
(Memory location Address ) .

access .
.


:
1. Low Level Language: .
0 ( ), 1 () .
0 , 1 Low Level Language .
.

,
. 0, 1
.
:


0001 0111 0100

Low Level Language

.
2. Middle Level Language : Middle level languages
programs
MOV ADD SUB DIV

Direct , Registers

Machine level language
.
programs computer computer
low level .

.

3. High level language : /
programs (C , C++, JAVA ... ) High level language .
language computer .
GENERAL
.

. computer programming languages High
Low Compiler/ Interpreter
.
( MACHINE LEVEL LANGUAGE / LOW LEVEL LANGUAGE/
BINARY LEVEL LANGUAGE ) .






.

"C" Language Program High Level
Low Level Compiler .
Compiler Low level Program .
Program ALT+F9 Press Low Level
. FileName .Obj Extra File Create
. File Program
Folder .


Ctrl+F9



:



:

First Program In C

,
.

output input
..
.



Mozilla Fire Fox


.








)


desktop ICON
Symbol ( ) .
.





.












.

CREATE

new














hello world
.
Write a Algorithm To print a message "HELLO WORLD "?

STEP1: Start

Step2: print HELLOWORLD

STEP3: END
Same "C "


Write a Program to print Hello world message At output ?
1. Starting step "start " . "C " Language
Stating Step Void main().
2. STEP2 print HELLO WORLD
"C " Language printf(" hello world "); Use .
3. STEP3 End Ending
}


void main()
{
printf(" Hello world ");
}

printf ("Hello world "); Hello world
. printf
. printI
output
.
printI




( Execute )
.

,

step
...





.



void main()
) " { "
printf("Hello
World");








#include <stdio.h >





#include <stdio.h >
printf

" }


....


#include <stdio.h >
.





.


.

printf syntax:

printf ("
");


Examples On printf :

printf(" hai ") ; ----------------->
printf(" siva naadh baazi is great "); -------------------->

printf("your name");---------------------->



" Printf work program already


#include
"

compila

.


Output



ALT+F5




pro1




.


pro2









Output.
Hello w
Program Output.



"
.

clrscr() -------- meaning



. program " conio.h " .






getch () ------>



------
. program " conio.h " .





#include < stdio.h >
#include < conio.h >
void main()
{
clrscr();

printf(" Hello world ");

getch();

}








.









...


......
C Programing Rules
Rules . English
Grammer
" C " Language Rules
.

C Language Rules :
1. "C" Progarm Starting point main() Function

Note: main() #include ( program ) Only
Functions Work .
Example : printf("");
program Stdio.h vundhi printf work
stdio.h include program Starting
Point main()
2. main() function statement SEMI COLON ; END
.( English sentence End full stop .
semicolon )
3. main() Function Begining Bracket and Ending Bracket .
ea statements ina .
4. main() Function #include statements Header files .




5. Program filename .(dot)c save

Example: program1.c
pro.c
abcdfeg.c
6. Progarm Complie ALT+F9
Run CTRL+ ( Output )


------------------

C programming Video tutorial:
"c program"
save
compile output









Write A Program To Print Your Name and Age At Output


#include<stdio.h>
#include<conio.h>


void main()
{
clrscr();

printf("sivanaadh baazi");
printf("22");
getch();
}




output


sivanaadhbaazi
22


.












..




#include<stdio.h>
#include<conio.h>

void main()
{
clrscr();

printf("sivanaadh baazi 22");

getch();
}




...





..

--- (New Line )





Write A program To print Your Name And Age Line By Line..




1st printf Statement















..





\n ( New Line
)
..............




Examples Printf


Write a Program To print U R Bio-Data at output


#include<stdio.h>
#include<conio.h>

void main()
{
clrscr();

printf("name=sivanaadh baazi");
printf("age=22");
printf("gender=male");
printf("father name=satyanarayana");
printf("mother name= malleswari");
printf("qualification=BTech");


getch();
}




Output

output:

name=sivanaadh baazi age=22 gender=male father name=satyanarayana mother
name=malleswari qualification=BTech








#include<stdio.h>
#include<conio.h>

void main()
{
clrscr();



printf("name=sivanaadh baazi \n");
printf("age=22");
printf("gender=male \n ");
printf("father name=satyanarayana");
printf("mother name= malleswari \n");
printf("qualification=BTech");

getch();
}




1,3,5 printf statements



Ouput:

name=sivanaadh baazi age=22 gender=male
father name=satyanarayana mothername=malleswari
qualification=BTech



...............



:) :) :)


continue

Character Escape Sequence
Newline \n
Horizontal tab \t
Vertical tab \v
Backspace \b
Carriage return \r
Alert \a
Backslash \\
Question mark \?
Single quotation mark \'
Double quotation mark \"


printf
\n .. \n
.
.

Escape Sequence
. table .

Horizontal Tab ( \t ) :

printf \n
.
\t
(space ) .


Program on Horizontal Tab :


Output :




11. Program on Back Space ( \b ):



printf \b
character
.
\b use actual \b use
character , \b character
. already
\b palce
.

example .


Program on Back Space :

Output :



output h h b
h .


Program on Back Space 2 :


Output :



output \b hello O ()
s o \b
l ( ) s ( )
. s \b O s ()
. s O(
) ( ) O ( )
.



hello
\b hells O
just S , O
O ( )
size S ()
.
\b helso .
\b S ()
just O S
L () place . O
O ()
\b \b
\b
. \b





\b

\b

7416396937)
12.program on Vertical Tab ( \v ) :


printf \v output
. \v
Fast .
Example : 20 \v Use
Line 20 \v
( Vertical ) Fast .
\v 3
. \v Use
( ) .



system
...
.
software


13.Program on Carriage return (\r)




printf \r cursor pointer
. \r
, already data \r
data print .
Example

Program on Carriage return :

Output:



output teluguer in .
output computer in telugu
. computer in telugu computer in \r \r
telugu compu
telugu
:


printf \a
Execution \a " "
.




( Alert )



..
. .
software
() soItware




output :

printI hi Iriends
\a
15. Backslash ( \\ ) Question mark ( \? ) Single quotation mark( ' ) Double
quotation mark ( \" )

output ( \ )


: output


sivanaadhbaazi\sivanaadh

output printI
.


output ( \ )
. output .

output : sivanaadhbaazisivanaaadh

( \ ) .
\n \r \a \v \t \b ( \ )
character . (\)
Escape Sequence printI ( \ )
character output
. ( \ ) S

printf (\)
.

?
,
printI
.



? (question mark ) Double Quotation (")
printI
.
single quotation (') printI

Vous aimerez peut-être aussi