0% found this document useful (0 votes)
27 views

Let Us C

Uploaded by

Rishita Dogra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Let Us C

Uploaded by

Rishita Dogra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Starting Turbo 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

How scanf works ? 86


59 Hierarchy of operators 133
) 86
41..1 More about scanf
Writing output -(printf function) 90 CONTROL
412 6.
4121 More about printf STATEMENTS 146
42
Unformatted Input/Output In this unit various control statements
100 are discussed.
functions
Character Handling Functions 100 146
421 6.1 Decision making statements
100
421.1 Character Input Functions 6.1. if statement
146
Character output functions 101 146
4212 6.1.1 Simple If
String Handling functions 102 149
422 6.1.2 The if-else statement
102 151
422.1 gets () 6.1.3 Nested If statement
4222 puts () 103 153
6.14 else-if-ladder
Various format specification 104 157
43 62 Loop control structure
159
6.2.1 The while loop
170
109 6.2.2 The do-while loop
5. OPERATORS The for loop 171
6.2.3
Tells various operators and their order Some variations of for lobp 173
of evaluation. Converting one loop into another 175
Which loop to use? 176
109 6.3
5.1 Arithmetic Operators 176
111 64 Nested loops
52 Relational Operators 65 Transfer Statements 193
53 113
Logical Operators 65.1 The break statement 193
53.1 Logical AND (&&) 113
6.52 The continue Statement 196
113
5.3.2 Logical OR(11) The switch statement 197
114 6.6
54 Assignment Operator switch v/s else-if ladder 199
55 117
Bitwise Operators 6.6.1 Application of switch statemeni 203
55.1 Logical Bitwise Operators 117
203
6.7 The goto statement
A-9
register spcifier
822 External Vriables
stateen Satic Variables
g
A k sof 824
661 Storage class of a function
213 Storage class modifiers
FUNCTIONS olled constModifier
AwarealeY 841
volatile Modifier
Whrae ni 842
213
214 ARRAYS
Fnctios
AdntgesofFunctins
215 This chapter deals with
271
Csiñcatieoffncins
Lby fncions
215 dimensional and multi arrays,
dimensionalsingle
218
a abary fnctio Arays
7321 Aesing
User defincd Fnctions
221 91 Declaration of one-dimensional
74 02
Fnction Definition Arrays
741
742
FnctieCall
93
Storing values in arrays
Function declaation
743 Argument pising techiques 231 93.1 Assigning values to each
75 231 individual elements
Value
751 Pass by Vale orCall by 233 Reading values from the keyboard m
Pass by Address 932
752 234 9.33 Initializing the elements
returm Statement
Calegonies of Functions 235 934 Accessing the elements
27 2T5
value 236 Parallel arays
771 No parumeters and no retum 94 280
772 Function wih parameters but no 95 Finding size of an array 282
returm valae 237 96 Passing arrays to a function 282
773 Function with purameters and 9.7 Constant arays as formal
Tetum valae 238 parameters 297
774 Function with no parameter but 96 Two dimensional arays 297
returm value 230
9.6.1 Declaring Two dimensional arays 298
76 Things to remember while using 9.62 Accessing Two dimensional arrays 299
functions 240
9.63 Initialization of Two dimensional
77 main() function 242
78 Recursion aray 30
781
243 9.7 Passing two dimensional Arays to a
Advantages of Recursion 246
782 Disadvantages of Recursion function 303
247
9.8
8.
Multidimensional Arays 320
STORAGE CLASSSESAND
SCOPE 255 STRING 326
Here various storage classes Here various operations that can be pe
in C are available
discussed formed on strings are discussed.
&1 Local and Global Variables
10.1 String literals 326
82 255 102 Declaring string variables 327
Storage Class Specifiers 103
821
Automatic Variables: (Local Variables)258 String input/output 32
103.1
10.3.1.1 Inputting
Inputting strings
327
250 strings using scanf () 327
10.3.1.2 Inputting strings using gets() 328
4-0
103.1.3 nputing strings using 1111 Pointers and one-dimensional arrays381
getch r() 329 L13 Pointer to array 349
10.3.2 Outputting strings 330 11.14 Array of Pointers 391
104
Initializing Strings 330 1LI5 Handling Strings using pointers
105
Traversing strings 332 1116 Pointers as function arguments 399

105 Passing strings to functions 333 1L17 Function returning pointers


106
Standard Library String Handling 11.18 Pointers to functions
Functions 334 Declaration of pointer to a function 48
1061
strlen (s) 335 11.19 Array of pointers to functions 46
strcpy (sl, s2) 336 11.20 Passing function to a function 6
1062
strcmp (sl, s2) 338 11.21 Pointer Declarations 48
1063
(sl, s2 ) 342 11.22 Dynamic Memory managerment 459
1064 strcmpi
strcat (sl, s2) 410
1065
342 11.221 ma lloc() function
11.22.2 calloc () function 412
10.66 strlwr (s)
343
414
1067 strupr (s)
344 11.223 realloc () function
344 11.22.4 free () function 415
1068 strrev (s)

107 Arrayof strings 356


12. STRUCTURESAND
11. POINTERS 364 UNIONS 418
Concepts of pointer how to initialize
them and use them is discussed here.
364
EEEEREEE Here concepts of structure and unions
and various operations that can be
11.1
Understanding pointers performed on them are discussed
address of operator 365 419
112 12.1 Structure declaration
Pointer declaration 365
113 Declaring structure variables 431
Initialization of pointer variables 367 122
114 123
Accessing structure members
115
Handling uninitialized pointers 368
Structure Initialization
124
116 Accessing value through pointer 368
125 Structure assignment 424
Pointer to pointer 372 425
11.7 12.6 Structure Storage
Pointer and constants 373 426
1L8 12.7 Aray of Structures
Pointer to constant 373 431
11.8.1
374 128 Initializing an array of structures
1182 constant pointers Nesting of Structure 432
12.9
11.8.3 constant pointer to constant 12.9.1 Accessing members of nested
variable 374 433
structures
Operations on pointers 375 435
11.9 Structure and Pointers
375 12.10
Adding integer to a pointer Arrays as structure members 438
12.11
Subtracting an integer from a Structure containing pointers as
376 12.12
pointer members 440
376
Incrementing a pointer 12.13 Structures and Functions 441
Decrementing a pointer 377 441
12.13.1 Passing individual members
Subtracting one pointer variable 12.132 Passing entire structure to a
from another 377 442
377 function
Comparing pointers 12.133 Passing structure pointer to a
119.1 Invalid operations on pointers 378 444
380 function
I1.10 void pointer
A-11
1311 Predefined Streams
Fne
renumingstrctures
445
1312 Redirection and Piping
47 13121 Redirecting output
447
13.122 Redirecting input
L48
12181 Dclaningtnions
Vriables 13.123 Piping Prog No.
DvlanigCnionVriahles
262 Aooessigunion 448
CH
1283 itialininga Unic
12184 Oyerationson Union
449
451
14. THELEFTOVERS Prog. 2./ To
1216
12185 SelfreferentialSucture The various topics Prog. 2.2 To
chapters will be
left out in
461 14.1 Preprocessor discussed here. var Prog
Prog
2-3 To
24To
DATAFILES File Inclusion
14.1.1
13.
related operations andfile 14.1.2 Macro Definition
Herefile disssed 14.1.2.1 Simple macros
penig mles are
461 14.1.2.2 Parameterized macros
Fle 462 14.1.2.3 Nested macros Prog 3
131
Accessinga File 14.1.23 #undef directive Prog 32
132 462
Pointer Prog. 3
L321 Declaring a File 462 14.1.3 Conditional compilation 3
1322 Opening a File 463 14.1.3.1 #if - #endif directives Prog. 3
1323 Clasinga File Prog. 3.5y
133 Fle Opening Modes 464 14.1.3.2 #i£, #else and #endie
134 Reading and writing files 465 directives Prog 35
1341 Reading and writing one character 32
14.1.3.3 #i£, #else, #elif and ena.
tatime from/ to files 466 directives
342 Reading and writing one line at a 141.3.4 #ifdef and #ifndef directive Prog. 4.1
time fron/to files 470 Prog 42
343 Reading and writing one block 14.14 Other directives Prog. 43/
of characters at a time from/to files 471 14.15 Macro v/ls functions Prog 44
1344 Reading and writing an integer 473 S
1345 Reading and writing fomatted data 475
14.2
tydedef operator Prog 45
135
Miscellaneous functions 14.3
enumerated data types Prog. 4.6,
1351 renane ()
476 144
Indentation Prog. 4J
1352 remove () 476 145 exit () function Prog.4.8
136 477 SI2
To print contents on Prog. 49,
137 Text v/s Binary Files
printer 477
138 477 Prog.4.1
Random Access to files 15. FUN WITH C 514 Prog. 4.1
1381 Eseek () 479
1382 Etell () 480
1383
139 rewind) 48 ANSWERS
Here answers
523 Prog.4.
Prog. 4.
Error Handling during 483 to various viva-VOCt
FILE Prog. 4.
13.10 Operation questions given at the end of eact
13.10.1 Command Line Arguments 483 Prog. 4
How to run a
chapter are provided.
484 Prog, 4
command line program
argumentsusing Prog.
485
PROGRAM INDEX

Prog. No Pregram Name

CHAPTER2:PREPARING AND RUNNING AC PROGRAM


1 To print the message "roday I ade My Hret c Progrss'
Pog23 To calculate aroa of a ight angled Triangle.
To calculate roots of quadratic equations. a2 +bx +Gu0, a s07
Pog 2 expression.
Pg. 24,/ To evaluate the

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

CHAPTER5: OPERATORs Pe.


P 5.1. To check result obtained on applying various arithmetic operators,
Prog. 52.To check result ttained by applying
various relational operators.
Prog. 5.3 To check whether a nurnber is
divisible by 3 and 5 or by 3 or 52 l12
Prog. 54 To show importance of
Prog 5.5/ To irterchange value d two
variabies without using third variable.
Prog 56 To shoW use of logical bitwise
operators ?
Prog 5.7. To dermonstrate use of Shift
Operator
?
Prog 5.8. To demornstrate use of Negation ( Operator ? 120
Prog 5.9. To display the bit pattern
To find greatest of two corresponding
Prog. 5.10. to an unsigned integer 121
quantity.
nurnbers a and b using conditional operator? 122
Prog 5.11. To find the greatest of3
different numbers using conditional 123
Prog. 5.12. To covert
lowercase character to
operator? 123
operator ? uppercase character using conditional
Prog. 5.13. To deterrnine
whether the given year is a leap year or not? 124
Prog 5.14. To deterrnine howw
postfix and prefix operator 124
Prog 5.15. To deterrnine size of int, increment works?
char, float and double data type in 12
Prog 5.16. To dernonstrate data computer's memory.
coversion ? 127
Prog 5.17. To convert
temperature given in F to °C? 131
Prog 5.18. To calculate the 132
three subjects ?
aggregrate and percentage marks obtained by the
student in
Prog 5.19. To calculate compound interest 140
when Principle amount, rate of
number of years ? interest and
Prog 5.20. To calculate the Gross Salary for 140
any
dearness aliowance is 40% of basic basic salary entered through
salary and house rent is 20%keyboard where
Prog. 5.21. To convert gven time in of basic salary. 141
seconds to the time in hours, minutes and seconds 141

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

Prog, 6.30. To generate the Latin square?


Prog. 6.31/ To find the nth prime number ?
Prog. 6.32. To print first n prime numbers ?
Prog. 6.33/ To print out all armstrong nurmbers betrween 1 and 1000.
Prog. 6.34. To print the multiplication table? 19
Prog. 6.35. To calculate average of different lsts of numbers ? 191
Prog. 6.36. To find the sum of digits of every number betweenmand n? 19
Prog. 6.37. To find sum of Ndigit nurnber and by reducing o obtain the sum to single dgt 192
(such that number > 10)
Prog. 6.38. To show importance of break? 194
Prog. 6.39. To find whether a given number is prime or not ? 195
Prog. 6.40. To keep on adding integers from 1 to 30 and prift the integer when sum exceeds
100 ? 195
Prog. 641. To demonstrate how continue works ? 196
Prog, 6.42. To show that continue is only associated with rearest loop ? 197
Prog, 643. Program prompts user to enter the day of the week and then display its
corresponding week day? For instance, display 'Sunday for 1, Monday for 2.
Tuesday for 3 and so on. 198
Prog. 6.44. To add, subtract, mutiply two nurnbers using switch 7 212
Prog. 6.45. To check whether the input character isa vowel or not? 203
Prog. 646. To display numbers from mto n provided mn? 206

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

Program to calculate factorial of a given number.


Prog. 7.6. To calculate the binomial coefficient using functions
Prog. 7.7.
Prog. 7.8. To calculate sum of two integers using functions ?
Prog. 7.9. To determine the greatest of three numbers using functions ? 230
230
Prog. 7.10. To calculate hcf of two numbers using functions ?
231
Prog. 7.11. Program to show how pass by value works ?
233
Prog. 7.12. Program to show how pass by address works?
and returns no value ? 236
Prog. 7.13. Proaram in which a function accepts no parameters
no value? 237
Prog. 7.14. Program which accepts arguments and returns
a function accepts arguments
Prog. 7.15. Program to calculate the sum of two number to show 238
and retums value ? 239
arguments but returns some value ?
Prog. 7.16. Program is which function accepts no 240
Program to calculate simple intereston the bank balance for 1 year?
Prog. 7.17. 244
number using recursion.
Prog. 7.18. To calculate factorial of a 247
recursion.
Prog. 7.19. To calculate sum of digits using 248
recursion ?
Prog. 7.20. Print the Fibonacci Number using 248
recursion ?
Prog. 7.21. To find HCF of n numbers using 249
recursion ?
Prog. 7.22. Print the Ackerman function using 250
characters) using recursion ?
Prog. 7.23. WAP to reverse the string (array of
UNIT8:PROGRAMSTRUCTURE
25
automatic variable?
Prog, 8.1. To demonstrate use of 260
variable?
Prog. 8.2. To demonstrate use of register 264
To demonstrate use of
static variables? 266
Prog. 8.3.
modifier.
Prog. 8.4. Program to show use of const

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.22 To input and display elements of a two dimensional array?


Prog.9.23. To dermonstrate how two dimensional arrays are initialized ?
Prog. 9.24. To add two matrices using functions ?
Prog. 9.25 To calculate product of two matrices ? 305
Prog 9.26 To find transpose of a matrix 306

Prog. 9.27,To calculate surn of each rows and each colurnns and total of all elements of the 309
matrix?

Prog. 9.28.la) To calculate the sum of diagonal elements of a square matrix?


(b) To calculate the sum of second diagonal of a square matrix?
310
(c) To calculate the sum of upper triangle and lower triangle of a square matrix?
Prog. 9.29. To sort the elements of the matrix? 312
Prog 9.30. To calculate the average of marks of four subjects taking best out of five and also
print the result in sorted order according to average. 314
Prog. 9.3l To calculate the determinant of a matrix of any order. 315
Prog. 9.32To find out inverse of a square matrix of any order. 317
320
Prog. 9.33.Program to display al the elements of a 3-dimensional aray ?
Prog. No.
Progran Name
Prog. 9.34. To multiply number of square matrices of any
n
orde
UNIT 10:STRINGS
Prog. 10.L. Program to input and display a string entered by he user?
279 Prog. 10.2. Program to input string using gets 0and then display
281 Prog. 10.3. Program to read a ine of text upto maximum 30 characters string
282 getchar() and then display it? using
283 Prog. 10.4. Program that initializes strings and displays them?
284 Prog. 10.7. To print the line and then count the number of characters in i
Prog. 10.8. To print the ASCll equivalent of each character in the gven string?
285 Prog. 10.9a. To calculate the length of the string using lbrary function strlen()?
287 Prog. 10.9b. To calculate the length of the string without using library function strlen ()?
289 Prog. 10.10. (a) To copy a string to another using ibrary function strepy(?
289 (b) To copy a string to another withcout using lbrary funcio?
290 Prog. 10.11. (a) To compare two strings using ibrary function stremp).
291 (b) To compare two strings without using lbrary funcion
292 Prog. 10.12. To compare two strings and print the locations of the unmatched chaacter and
total number of matched character ?
Prog. 10.13. (a) To concatenate two strings using lbrary function strcat ()?
93 (b) To concatenate two strings without using libray tunction?
functions
Prog. 10.14. To convert a given string into lowercase without using built-in
95 Prog. 10.15. (a) To reverse a given string using library tunction strrev (.
96 (b) To reverse a given string without using library function?
alphabets Ato Z in given ine olt
00 Prog. 10.16. To print the number of occurences of respective
text ?
digits, spaces and other characters
4 Prog. 10.17. To count the number of vowels., consonants,
typed in ?
347
Prog. 10.18. To extract m characters from a string
starting with nth character?
38
6 alphabetically ?
Prog. 10.19. To sort the characters of the string
Prog. 10.20. To print the following ?
abcde
bcdea
cdeab
deabc
eabcd
that justfies text Le. it you enter 21 letter word and length you fixed is 20 then
Prog. 10.21. Program new line ?
last character is entered into
is a good
To replace any particular word is' in a line of text by was Eg. This
Prog. 10.22.
flower. with This was a good flower
Program Name
Prog Na
display them in the center of the
Pr 1024. /Program that accepts strings from the user and
screen, horizontally as well as vertically. 352.
recursion.
Prog 10.24.To check ifa string is equal to its reverse or not, using
Phog. 10.25. To print all the combinations ofa string. 352
353
Prog. 10.26. To convert a given integer to a string.
Prog. 10.27.To convert a given string to integer.
354
Prog. 10.28.To print out the namnes of the days of the week ?
355
356
Prog. 10.29.Program which takes a set of names of individuals and abbreviates the first,
middle and other names except the last name by the first letter ? Eg : Raman
Kumar Shama is R. K. Sharma.
351
Prog. 10.30.To sort a list of strings in alphabetic order ? 359
Prog. 10.31. To print the value of a number in words when the number is entered in the
range of O to 999999999 ?
365)

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

Prog, 11.32.To multiply two matrices dynamically? 411


Prog. 11.33.To show use of calloc () ? 413
Prog. 11.34. To show use of realloc()? 414

UNIT 12:STRUCTURES &UNIONS


12..
Prog. To input and display the roll numtber, name and marks obtained by two students ? 421
Prog. 12.2. To print the assigned values to members of the structure ? 422
Prog. 12.3. Program that accepts two measurements from the user and prints the absolute
difference between the measurement? 423
Prog. 12.4. Program that demonstrates initialization of the structure variables ? 424
Prog. 12.5. Program that demonstrates structure assignment operation? 425
Prog. 12.6,. To show structure members are stored in contiquOus memory locations ? 426
Prog. 12.7. To input details of n employees of an organization and then display list of
employees? 427
Prog. 12.8. To input data of n students and display the details of student with highest
percentage of marks ? 428
Prog. 12.9, Design a structure to store data about a car and using this structure WAP that
accepts data about cars from the user and retrieves the data from a car whose
engine number is given ? 429
Prog. 12.10. To sort the record of students merit wise ? 430
Prog. 12.11. To show how structures are initialized ? 432
Prog. 12.12.To show how to access elements of nested structure ? 434
Prog. 12.13. To access the member of structure in which we have pointer to a structure? 436
Prog. 12.14. To show how members of structure are accessed using a pointer to that structure? 437
Prog. 12.15. To show how members of array of structure can be accessed using convert of pointe
to a structure?
437
Prog. 12.16. To calculate the total marks obtained by students in 3 subjects. For this
members
of the structure are accessed using pointer notation? 439
Prog. 12.17.To input STD code of some cities and search city for the
entered code? 440
135. Prog Prog. 13.2. Prog
13.3. Prog 13.1. Prog. Prog Pog Poe
138.Prog.
Prog.139 Prog.
Prog Prog. Prog. Prog.
136. Prog.
13.7. Prog. Poe
Considera
structurePgthPg
e hg
13A. 12.27. 1226. 1225. 1224.1223. 12.22Deciare
13.13.13.12. 13.10.
13,11Program 1221 1220
1219Consider a
Prograrn
Progran Prograrn
Prograrn FILES
To Define Containing
Create who andnarme
UNTT13: names members.
ansame
To
Program To a
To Conskdera
Prograrn
acter
Program Program Program Progran
and rollno,Prograrm
To create unction unction o
create
opern jolin element show show
putw() have having fncson
and a date a
nane to end structure a (a+b)-(C-(a+b)
tohow(a+b) id) a
that to toseparates
to that
the a to to to to to structure
cornpleted structure, that hat
with
frequency count count copy write close print maximum linked
from lustrate structure
finddelete show file input is to passing structure
that
case read
functions and a aooepts
+ aooepts
the student contents to the mernber whose and list initialze (c+ (C+id)
use marks. anumber nurnber a a of oomputes
asize a line atleast mermory and
text file? result. n id) fraction ofhwo employee
fraction
file file. of ?
that into
of
students 25 print (self two
and and ofEscanf nurnber mernbers the -c)+ib-d) (a (aWAP complete
the
Progran of of of file one
characters, of referential (ac- fractions 1ractions
toggle
vice
even
odd
and contains
file
a lineswords one and type that needed
members +c) that that the
file year to
() and of in file then using date list. bd) add, consists gross Program
with Nane
versa ? should are +i structure consists
each and times the in to of structures), and and
informationdisplay the read service? to i(ad +(b+d) subtract salary?
some
another? dynamic departrnent ?code of
store
and
of Eprintf number also afile? file? WAP the +bo) returns returns
of by of basic
its character it. having
write it nurmerator nurmerator
haracteri.e. printcontents. a
union,
memory to and their Call their
the (). present about print insertstructure salary.
all having at multiply by
occurs sum?
result
the a maximum
the an Referenceproduct?
student. allocation. names and and and Pass
in in a
records. maximum element two
replaces
percase in a denominator.denominator.
new file a the
It file? of 4 union complex
file? using
consists Read characters,
those in method. basic
20 it,
getw() theiremployees
characters delete numbers? salary
of Make Make

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

You might also like