Let Us C
Let Us C
211.1
DETALEDcONTENIS 2112 Creatinga new program
Typing your Program 3623 Poim
2.113
Saving the Program 3.63 Use
with STEPs
WUlSTE
2114
2.11.5 Compiling and Running a Program 363.1 Str
3632 Um
Seventhkaa 2.11.6
Exiting from IDE
Opening an Existing File 3633 Er
2.11.7 3.7 D
2118 Copying an existing Program
1 38
INTRODUCTION 2.12 Erors 39
1
Introduction what is Cand features
of C 2.12.1 Syntax Errors (Compiler errors) 3.10
2 2.12.2 Run Time Errors (Execution Error)
Introduction Linker Errors
4 2.12.3 4
Characteristics of C language
12 5 2.124 Logical Errors (semantic error)
Limitations of C language
13
2.12.5 Flowchart showing Erors
2.13 Debugging 41
PREPARINGAND 8 2.13 Break points and Watches 4LI
2
RUNNINGACPROGRAM 2.14 Help Menu
5
4.1L1
Learn to open C compiller and perform 2,15 Hot Keys available
4.12
arious other operations also learm various 2.16 Steps for running aCprogram in UnixS2 4.121
bypes of errors. 42
3. CFUNDAMENTALS 55
2.1 Pprogram Development 8
9
Tells various keywords, constants, ex 421
22 Data Representation pressions and statements 42.1.1
22.1 Representation of Characters 9
3.1 The C character Set 55 4212
222 Representation of numeric data 10
3.2 Tokens 5 422
222.1 Representation of Integers 10
422
2.2.22 Representation of Floating point
3.3 ldentifiers and Keywords
422
34 Constants
numbers 43
34.1 Integer Constants
23 Number system 14
24 Program development tools 17 34.1.1 Unsigned and Long Integer
Algorithms 17 Constants 5.
24.1.1 Properties of al gorithms 19 3.4.2 Floating Point Constants
242 FlowChart 19 3.4.3 Character Constant
24.2.1 Advantages of Flowchart 24 3.44 String constant 5.
2422 Disadvantages of Flowchart 3.5 6
24 Variables 6
243 Decision Table 24 3.6 Data Types
244 Decision Tree 6
25 3.6.1.1 Integer type
245 Pseudo Code 3.6.1.2 Character type 67
27
25
Desirable program characteristics 30 3.6.14 void Type
26 General Structure of Cprogram 31 3.62 Derived data types
210 Creating Cprograms 3.6.2.1
211 Turbo C
35 Array
37 3.6.2.2 Function
119
Pointer 5.52 Shift operators
3623 121
User defined types 71 553 One's complement operator (-)
363
554 Bitwise Asignment Operators 121
3631 Structure 71
56 Conditional operator (?1) 122
363.2 Union 71
5.7 125
data type Unary Operators
a633 Enumerated 5.7.1 Unary minus (-) 129
Declaration
5.7.2 Increment Operator (++) and
Symbolic Constants 75 125
48 Decrement Operator(--)
Expression 5.74 sizeof operator 17
39
Statements 5.75 Address of operator (&) and
pointer operator () 12%
DATA INPUT & OUTPUT 82 5.7.6 Cast operator (type) 128
4. 128
In this unit various input and output 5.7.7 Comma operator ()
functions are discuSsed 5.8 Type Conversion 129
Implicit conversions in
Formatted Functions 8 assignment statement 130
41
411 Entering Input data - scanf function 83 5.8.2 Explicit Type Conversion 132
CHAPTER3: CFUNDAMENTALS
of n)
Proe. 3,/ To demonstrate importance
importance of t2
Prog. 3,2 To demonstrate 6
data types?
De 13/ To display the maximum and minimum range of some
rectangle?
Prog. 3,4/ To calculate the area of a diarneter? 76
To calculate the area and circumference of a circle of given
Prog. 3.51 to 32767?
To show that integer range lies between -32768
Prog. 39.
CHAPTER4: DATA INPUTAND OUTPUT
and use of field width ?
Prog. 4.1. To demonstrate usage of scanf
of width and length fields ?
Prog.4.2 Program to show importance of scanf () and use
character and string ?
Prog.4.3 To show input in case of
non-whitespace characters effect scanf ?
Prog. 4.4 To demonstrate hoW
To print a message live in Amritsar
Prog45 94
field feature.
Prog, 4.6, To illustrate minimum
47 To demonstrate effect of (- sign) with integer data type conversion ?
Prog. ? 96
To demonstrate how to control the numbers after the decimal point
Prog. 48 97
printf works in case of strings ?
Prog. 49 To demonstrate in printf statements ?
97
Prog, 4.10 To show the importance of
effected when we use conversion characters
Prog. 4.1J To demonstrate how results are 98
with wrong data types ? 98
done in pintt itself ?
Prog. 4.12 To demonstrate that calculations can be 101
?
Prog. 4.13. To print a character using getchar () 10
Prog, 4.14/ To print the output using puteh () ? 102
using putchar () ?
Prog. 4.15 Write a program to print a characters 108
Prog.4.16. To use gets () to enter and a string. 103
Prog. 4.17. To use puts () to print your name.
Prog. Na. Program Name
CHAPTER6: CONTROLSTATEMENTS
Prog 6.1. To display a message Student has
passed in
are 50 or greater than 50, otherwise no action isEnglish if the marks in a subject
taken? 147
Prog 6.2. To find the roots of the quadratic ecquation : ax
+ bx +C=0. 148
Prog6.3. To test ether a ghven number is odd or even ?
150
Prog. 64. To check ita number is divisible by both 5 and 7 or
not? 150
Prog 6.5. To check whether the entered letter is in
uppercase or not?
Prog 66. To calculate the greatest of three
umbers using nested if statement. 151
Prog 6.7 To display the rarme of the angle when the user
angle in degrees ?
inputs the a number reflecting an
154
Prog62 To isclay what tine of the day it is ?
155
Program Name
Prog No.
155
To calculate f()
Prog.6.9
1-50 <xc50
x> 50
156
To calculate grade of student acoording to marks
obtained in 5 subjects
Prog 6.10.
a % above or equal to 70 First division
%between 50 to 69 Second division
Third division
C % between 40 and 49
% less than 40 Fail
given? 199
To print sum of 1 to n consecutive numbers, wherenis
Prog.6.I1. 160
To calculate average of n numbers ?
Prog.6.12 161
entered through a keyboard ?
Prog.6.13. To calculate factorial of a number 161
6.14. To show while loop is entry controlled loop ? 162
Prog.
Fibonacci number?
Prog. 6.15. fTo print nth number? 162
find the sum of first and last digit ofa
Prog. 6.16. To number is same
positive number and check whether a given
Prog.6.17. To reverse a given Palindrome) ? 163
as that of reversed (.e. 164
positive integer numbers ?
Prog. 6.18. To find HCF of two
series. (>3)
Prog. 6. 19. To print n number of 165
.....also known as Fibonacci series.
0,1, 1, 2, 3, 5, 8, 13, 21, 34, 55 166
Prog.6.20. To sum up the series:
1+1.1 +1.
2 3 4
167
Prog.6.21. To print the series
.0<x<1
n!
6 24
167
text.
Prog. 6.22. To convert lowercase text to uppercase 168
number is a circular number?
Prog. 6.23. To determine whether a given 170
To display the message
Welcome' 4 times using do-while?
Prog 6.24. 171
given positive number.
Prog. 6.25. To reverse the digits of a
between 1 to 200 which are divisible by number n that
Prog. 6.26. To display all numbers lying 174
you enter?
three digit WELL-ORDERED
Prog.6.27. Program that will find and display al possible 175
numbers less than 200 ?
178
Prog.6.28. To print the following outputs :
1 1 1
1
22 23 25
12
456 368
123 333
4444 78910 47910
**** 1234
A-xv
Progras Nae
Prog. Na 6567654
212 14543
34543 232
4567654
1
1234321
101 123 321
11 12 21
10101
121 1
1010101
1331
shown.
Prog. 6.29/ To print the output
1
112
1123
11235
112358
UNIT7:FUNCTIONS
Prog. 7.1. To check whether the entered character is a letter, digit or none of these? 218
Prog, 7.2. To inputa character and if it is aletter determine whether is a vowel or a consonant ? 219
Prog.No, Program Name Pe. No.
Prog. 7.3. To find the sum of the serios
1+X+x+x*+...e(n terms) 219
Prog. 74. To find the sum of series
x-x+X-x'+ . . +(1) xh
Prog. 7.5. To calculate sum of n terms of series 21
ONIT9:ARRAYS values ?
275
the values of five numbers and then print their 276
Prog. 9.2. To enter
Prog.9.3. lo reverse an array of n elements ? specified date (for non-leap year) ?
271
from stat of year to
Prog.9.4. lo print the number of days
A-xvii
Prog. No.
Program Name
Prog 95. To calculate average of n numbers and then calculato deviation of each nurmber
about average
Prog. 9.6. To enter a given list of numbers and find how many of them ar positivo,
negative, and zeros
Prog. 9.7. To search a glven number from a given list of numbers entered using
Linear Search ?
Prog. 9.8 To show use of parallel arrays?
Prog. 9.9. To count thenumber of elernents in the given array?
Prog 9.10. To showw how arays are passed to a function?
Prog. 9.1 L. To calculate the mean and standard deviation of n numbers using functions ?
Prog. 9.12. To search a given number from a given list of nurnbers entered using binary
search?
205
Prog.9.13. Tosort a given list of numbers entered through a keyboard using bubble sort ?
Prog. 9.14 To convert a binary number to a decimal number?
Prog. 9.15. To covert a decimal number to binary number ?
Prog. 9.16. TO delete a given element d from the K th position of the array ? 29
Prog. 9.17. To insert an element in an unsorted list ? 29
Prog. 9.18. To insert an element d in a sorted list. 291
Prog. 9.19. Given two one dimensional arrays A and B which are sorted in ascending order.
WAP to merge them into single sorted array C that contains every elerment
from A and B, in ascending order ? 293
Prog. 9.20. To input the ballot paper of voters and count the number of votes each candidate
has got? 295
Prog. 9.21ATo find the largest and srmallest element of a matrix ? Also find the range. 296
Prog. 9.27,To calculate surn of each rows and each colurnns and total of all elements of the 309
matrix?
UNIT 11:POINTERS
Prog. 11.1. Program to demonstrate use of address of operator (&). 365
Prog. 11.2. Program to demonstrate use of pointer variable and address of operator (&)? 367
Prog. 11.3. Program to demonstrate handling Uninitialized pointers using NULL. 368
Prog. 11.4. Program to demonstrate use of address of operator (&) and indirection operator
369
() for different purposes.
Prog. 11.5. Program to show how pointer to pointer operates. 373
Prog. 11.6. Program to show use of constant pointer to constant variable? 314
318
Prog. 11.7. To show how operators work in case of pointers ?
381
Prog. 11.8. To show how void pointers operate ?
343
Prog. 11.9. TO demonstrate in case of array, a and &a[O are the same ?
383
Prog. 11.10. To access array elements using indirection operator? 383
Prog. 11.l1. To access array elements using pointer? 384
Prog. 11.12. To calculate the sum of elements of an array using pointers?
entered using concept of pointers 34
Prog. 1 1.13.To search a given number from a list of numbers 385
pointers ?
Prog. 11.14. Program to sort the elements of an array using 388
Prog. 11.15. To access elements of 2D array using indirection operator? 389
Prog. 11. 16. To access elements of 2D array using pointer? 390
Prog. 11.17. To show how array elernents are accessed using pointer to array? 392
Prog. 1 1.18. To show how array of pointers are accessed? 394
string?
Prog. 11.19.Program to show use of pointers to access character 394
Prog. 11.20. To define a string using pointer notation and array notation ?
Prog. 11.21. To copy one string to another using Pointers ?
Prog. 11.22. To define a string using pointer notation and array notation ?
?
Prog. 11.23. Program to sort the strings using functions and pointers
Prog.No. Program Name Pg. No.
Prot. 11.24. To interchange value of twO numbers using call be 399
Reference ?
Prog. 11.25.|Program to calculate sumof elements of an aray using pointers? 399
Prog. 11.26. To add two matrices of integers using functions and
pointers ? 400
Prog. 11.27. To find greater of two numbers using concept of function returning 402
pointers?
Prog. 11.28. Program to demonstrate the use of pointer to afunction. 404
Prog. 11.29. Program to demonstrate the use of array of pointers to functions. 405
Prog. 11.30.Program to demonstrate how pointers to functions can be specified as argument.
It also shows how function is passed to another function? 406
Prog. 11.31. To print Table Z=3x'x-2"x+1 and sin(x) where x vary in steps of 0.5? 407
482 482 47 475 473 472 470 469 469 468 467 466 465 456 455 45 44 443
44 44
Prog. Prog. Prog. Prog.
15.5. Prog.
15.4. 15.
Prog.3. Prog. 15.Prog.1. 14.9.
Prog. 14.Pro8g.. 14.7.Prog 14.6.
Prog. Pog.
.
15.8I5.7.|
Prog. 14.4.Prog.14.3.Prog. 14.Pro2g,. 14.Pro1g.. Prog. Doe Prog. Proe. Dee.
15.6.Program 15.2. 14.5. Prog.No,
13.19. 13.I8. 13.17.13.l6. 13.15. 13,14.
Program
Program connected
ProgramProgram
ProgramProgramProgram UNIT To To To To To To To To To
LEFTOVERS
show show show show show show show show characters,Given
UNIT14: Program To
file,Program
ProgramProgram
find
15 then read
to to to in toshowing toshowing the a
sortprinta print
to : useimportance importance
howimportance importance use the to te xt print al to to to
print
a print produce FUN area spaces,
of concept
of count file
characters copy print
strings moving fom lines a conditional
enumerated the implement
screen ne a WITH macros and containing a strings
of limoving rectangle the characters file
in sound of of of of perimeter of occurrences tabs
using pendulam mesh without a #elif #if
#i£/ brackets withnested
saver form of Ccompilation and til inDOSentered
reverse
qulck ? text. using data text. the
using with directive
#else Arguments newlines on TYPE
directive macro? of n Program
Name
with of type in the WAP the as
?polygon some the of character order.
sort a a preprocessor screen. command. command
sound? line( internal directives
? directive in circle consecutive
in that
function. text in preprocessor ? the read
having ) preprocessor using is
funciton. written in text
speaker. can aentered line
preprocessor statement ? Macros vowels ?file
10 be arguments.
in and
sides it. statement
used
statement ? and
inoutputs
such a put
for statement file.
? number that
that debugging? ?
characterina
each ? of
node
is
490 485 487 486 485 No.Pg.
511 505 504 503 S02 501 501 500 498
522 521 520 520 519 519 S18 518