Unit 1 - Basics of C
Unit 1 - Basics of C
Unit 1
Basics of C
1.1 History of C
„C‟ is a programming language that was developed at AT & T‟s Bell Laboratories of USA in
1972. It was designed and written by Dennis Ritchie.
Dennis Ritchie and Ken Thompson were working on Basic Common Programming
Language (BCPL). They were thinking its name as B. But afterwards some features were added by
them. So, the name was given as C (As „C‟ comes after „B‟).
Without any advertisement C‟s reputation spread and so many programmers preferred
„C‟over otherolder languages like FORTRAN, PL/I orPascal.C became so popular; because it is
reliable, simple and easy to use.
Advanced programming languages like C++ and Java are evolved from C. These languages
are having additional concepts and newer approach to programming. So it is necessary to learn C
before studying these languages.
Major parts of popular operating systems like Windows, Linux and UNIX are written in C.
C is a robust language with rich set of built-in functions. C Compiler combines features of
assembly language with high level language features. So system software as well as business
packages can be developed using C.
Symbolic representation of machine code can be used for writing programs. This kind of
programming language is called as assembly language. Program written in assembly
language is not understandable by a computer. So, it is needed to be translated to machine
language program. Conversion of an assembly language program into a machine language
program is done by system software called assembler. Original assembly language program is
known as source code and the generated machine language program is called as object
code. For loading the object code and starting its execution, loader (it is also a system
software) is used.
There are different assembly languages for different processors. i.e. The programs written in
assembly language are machine dependent (cannot be easily run on other machines).
High level languages are nearer to human languages. So, they are easily understandable.
Programs written in high level language are not machine dependent. But these programs are also
not understandable by a computer. There are two ways to make it understandable by computer.
With some programming languages, approach of Compiler is used. Compiler is system
software which translates high level language program (source code) into a machine language
program (object code). Then loader is responsible for loading the object code and initiating
execution. C uses this approach.
The other approach is Interpreter. Interpreter is system software which checks a single line of
high level language program, executes it by converting to machine level instruction. The process is
repeated line by line.
A program is a sequence of instructions for performing a specific task. A person who develops
program is called programmer and the process of developing programs is called as
programming.
Every programming language has its own syntax which is to be studied by a learner. Syntax is
the set of rules that defines combination of symbols that are considered to be correctly structured
fragment in that language. It can be considered to be similar to grammar in the human languages.
Before converting a source program into object program, compiler checks for syntax errors. If
the program contains such syntax errors, those are shown to the programmer. These are the
errors in the syntax of the programming language.
Sometimes there isanother type of errors in the program. Those are called as logical errorsor
bugs. These errors are not shown by compiler. When we develop a program that works, but it
does not do what was expected from it. These errors can be removed with the help of debugging
(i.e. removing bugs).
Jadhav Kiran
- Algorithm - Flowchart
- Pseudo-code
Discussion about algorithm and flowchart is done in 1.4.1 and 1.4.2.
1.4.1 Algorithm
The word „algorithm‟ is derived from phonetic pronunciation of last name of an Arabic
mathematician named Abu Jafar Mohammed ibn Musa Al-
Khowarizimi.
This is a very popular technique used to obtain a solution for given problem. Description
of steps for solving a given problem is provided in algorithm. Stress is given on text.
Definitions
An algorithm is said to be accurate and truthful only when it provides the exact required
output.
1. Start.
2. Wash utensil
3. Wash cup
4. Fill the cup with water (half cup)
5. Turn-on the stove/burner
6. Adjust it to medium flame
7. Place utensil on the burner
8. Pour the water from the cup in the utensil
9. Open sugar container
10. Put 2 spoons of sugar in the boiling water
11. Take cardamom
12. Grind it in a mixer/grinder
13. Take a pinch of it and put it in the vessel along with boiling water and sugar
Jadhav Kiran
14. Let the water boil for a while(~3 minutes) 15. Meanwhile:
a. Wash the sieve/drainer
b. Take out milk from refrigerator
c. Pour milk into the cup (3/4th cup)
16. Pour the milk into the boiling water
17. Let the milk and water boil (~4 minutes) 18. Open the container of tea
powder.
19. Add one spoon of tea powder in the vessel of boiling milk and water with dissolved
sugar & cardamom
20. Let it boil for few more minutes
21. Reduce the burner to low flame
22. Change/make it to high flame
23. Repeat steps 22-23, 2-3 times
24. Turn the burner off
25. Take the sieve and the cup
26. Pour the tea through the sieve into the cup
27. Tea is ready to serve.
28. Stop
1. Start.
2. Accept a number
3. Find reminder for division of the accepted number by 2.
4. If reminder is 0, print that number is even. Otherwise print that number is odd.
5. Stop.
Jadhav Kiran
1.4.2 Flowchart
Flowchart represents the solution of a given problem graphically. Pictorial representation of the
logical steps is a flowchart.It is a diagrammatic representation that shows flow of execution of a
program.
Each step in the process is represented by a different symbol and contains a short
description of the process step. Standard symbols used for drawing flowcharts are given below.
• Start / Stop
• Input / Output
• Process
• Decision
• Connector
• Manual Operation
One sample flowchart for finding whether number is even or odd is shown below.
Jadhav Kiran
Start
Accept a
number
rem=num mod 2
Y N
Is rem=0
Stop
Jadhav Kiran
Documentation Section
Link Section
Definition Section
Global Declaration Section main( )
function section section of user-
defined functions
Alphabets A, B, C, …, X, Y, Z a,b,c, …, x, y,
z
Digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Special Symbols ~!@#%^&*()_–+=
{ } [ ] : ; “ „ <> , . ? / \ |
White spaces are ignored by compiler until they are part of string constant.
Jadhav Kiran
1.7 Tokens
Tokens are individual words and punctuation marks in a passage of text. These are the
smallest individual units. In C program, they are called as C tokens. e.g.
main( )
{
printf(“Welcome”);
getch( );
}
In the above C program, C tokens are as follows (each token shown on separate line):
main
printf
“Welcome”
getch
}
C has six types of tokens. They are shown in figure 1.2.
Jadhav Kiran
"C Programming"
Strings "Hello"
Tokens
Identifiers main sum
Operators + - * /
Special ( ) [ ]
Symbols
1.7.1 Keywords
Keywords are the words whose meaning is already explained to the C compiler. They have
fixed meanings and these meanings cannot be changed. The keywords cannot be used as variable
name or function name. The keywords are also referred as reserved words.List of keywords is
shown in table 1.1. Some C compilers may use additional keywords.
Table 1.1: Keywords in C
1.7.2 Constants
A constant is an entity that does not change during execution of a program. Constants can
be of different types as integer constants, real constants, character constants, string constants etc.
Integer constants must have at least one digit. They cannot have decimal point. They can
be positive or negative. Commas, blank spaces and currency signs like ₹or $ are not allowed. Some
of valid integer constants are shown below.
Integer constants cannot represent some real life values like height, distance etc. These
values can be represented by real constants. These are also called as floating point constants.
They must have at least one digit and a decimal point. There are two ways of representing these
constants –fractional form and exponential form. Some of valid real constants in fractional form
are:
A character constant contains a single character (an alphabet, a digit or a special symbol)
encoded within a pair of single quote marks (inverted commas). Some valid character constants
are,
Each character is represented internally by a ASCII value. So the last constant „70‟
represents „F‟.
Certain character constants can be defined using escape sequences. Though these
sequences look like two characters, they represent only one character. Some of escape
sequencesare given in table 1.2.
Jadhav Kiran
If the same constant value is to be used for many times in a program, we may use a
concept of symbolic constant. Symbolic constants can be defined using a preprocessor
directive #define. Syntax is given below
The symbolic_name is defined using the rules same as that of identifier (discussed in
1.7.4). But it is good habit to use uppercase letters (although not compulsory) while giving
symbolic constants.Some examples are given below.
#define SIZE 25
1.7.3 Strings
It is discussed in 1.7.2 as string constants.
Jadhav Kiran
1.7.4 Identifiers
Identifiers refer to the name of variable, function, array etc. They are user-
defined names. Following are the rules which should be followed while defining identifiers.
30778 •x
273 •y
8721 •z
Figure 1.3: Memory locations when variables x, y and z are declared (Values are
random/ garbage)
1.7.5 Operators
An operator is a symbol that tell computer to perform some mathematical or logical
operation. Operators in C can be classified into number of categories.
They are:
- Arithmetic operators
- Relational operators
- Logical operators
- Assignment operators
- Increment and decrement operators
- Conditional operators
- Bitwise operators
- Special operators
Some operators are binary operators (require two operands), some are unary
operators (require one operand only) and there is one ternary operator (require three
operands).
C provides all the basic arithmetic operators. They are shown in Table 1.3. These
operators can operate on built-in data types of C.
Operator Meaning
+ Addition or unary plus
– Subtraction or unary minus
* Multiplication
/ Division
% Modulo Division (used with only integers)
For taking certain decisions, we have to compare two entities. This can be done
with the help of relational operators shown in Table 1.4.
Jadhav Kiran
Operator Meaning
< Is less than
<= Is less than or equal to
> Is greater than
>= Is greater than or equal to
== Is equal to
!= Is not equal to
Operator Meaning
&& Logical AND
|| Logical OR
! Logical NOT
These operators are used for assigning result of an expression to a variable. The
assignment operators supported by C are shown in Table 1.7.
Operator Meaning
= Normal assignment
+= x+=12; → x=x+12;
–= x– =7; → x=x–7;
*= x*=2; → x=x*2;
/= x/=2; → x=x/2;
Operator Meaning
++ Post-increment or Pre-increment
–– Post-decrement or Pre-decrement
These operators are unary operators and require a variable as their operand.
When postfix ++ (or – –) is used with a variable in an expression, the expression is
evaluated with original value of variable and then the variable is incremented (or
decremented).
When prefix ++ (or – –) is used with a variable in an expression, the variable is
incremented (or decremented)and then the expression is evaluated with new value of
variable.
Here exp1 is relational expression. At first, exp1 is evaluated. If the result of exp1
is TRUE, exp2 is evaluated. If the result of exp1 is FALSE, exp3 is evaluated.
e.g.
Jadhav Kiran
If value of variable age is greater than or equal to 60, 9.5 is assigned to variable
interest_rate. Otherwise, 8.75 is assigned to variable interest_rate.
Operator Meaning
& Bitwise AND
| Bitwise OR
^ Bitwise Exclusive OR
<< Shift Left
>> Shift Right
1.10.
Operator Meaning
, For linking the related expressions together
sizeof Returns number of bytes the operand occupies
& Address of operator
* Indirection / dereferencing operator
The comma-linked expressions are evaluated left to right. The value of right-most
expression becomes the value of combined expression.
Jadhav Kiran
1.7.5.9 Expressions
variable = expression;
When above kind of statement is executed, the expression is evaluated first and
then the result of expression is assigned to the variable.
x/y
3x+2y 3*x+2*y
𝑎×𝑏+𝑐 a*b+c
7𝑥2 − 4𝑥 + 7 7*x*x – 4*x + 7
𝑝÷𝑞 p/q
1/2*b*l Or b*l/2
𝑎+𝑏+𝑐
(a+b+c) / (d+e)
𝑑+𝑒
1.8Data Types
C supports various data types. Basically there are three classes of data types.
Whole Numbers
int, unsigned int, Characters char,
short int, unsigned short int, unsigned char
long int, unsigned long int
Fractional numbers (or real numbers) can be used by using float, double or long double data
types. Data type float requires 4 bytes of storage. It supports precision of 6 digits. A double
data type uses 8 bytes of storage and it supports precision of 14 digits. For having more precision
than above, long double is used which requires 10 bytes of storage.
The void type has no values. It is usually used for specifying type of function (i.e. function‟s type
is void when it does not return any value).
Table 1.13 shows the list of data types supported in C along with their size, range and format
specifiers.
Jadhav Kiran
1.8.3Declaration of Variables
A variable is used to store value of any data type. The syntax used for declaring a variable is
shown below.
int a,b,c;
char choice;
When a variable is declared a memory space is allocated (as per its data type) and the variable
points to the allocated memory (the allocated memory location initially containsgarbage value).
Variables declared here are called global variables. These variables are accessible
or visible to all the functions in the program.Scope of such variables is global. ii)
Immediately after „{‟ in a block
These variables are local variables. They are accessible or visible within the block
where they are defined.Scope of such variables is local.
Then the variables can be declared by using the user-defined identifier (in above example it is
my_int) as,
my_int x,y,z;
1.9Generating Output
In a computer, normally a keyboard is treated as standard input and a monitor is treated
as a standard output. A set of C library functions defined in a header file „stdio.h‟ is used for
handling input and output of a C program. Therefore before using these functions in our program
we have to include stdio.h file (#include<stdio.h>).
Functions defined in a file „stdio.h‟ and which are used for generating output are,
char var1=‟C‟;
putchar(var1);
putchar(„M‟);
Jadhav Kiran
Output:
CM_
We can use puts( ) function for putting a string on the standard output. It also appends a
newline character at the end.
e.g.
puts(“Welcome”);
puts(“to C Programming”);
Output:
Welcome
to C Programming
We can use printf( ) function for displaying formatted output. (printf stands for print-
formatted)
1.9.1Formatted Output
Basic syntax of printf( ) function is given below.
This function converts formats and displays its arguments on the standard output. It
returns number of characters displayed.
Simple example of displaying a constant string with ordinary characters is shown below.
Example 1:
printf(“Hello”);
printf(“Everybody”);
Jadhav Kiran
Output:
HelloEverybody_
printf(“Hello\nEverybody”);
Output:
Hello
Everybody_
Each conversion specification (or control sequence) begins with a % and ends with a
conversion character (which is similar to format specifiers listed in table 1.13).
Example 3:
int a=28;
float x=23.76;
Output:
In between % character and conversion character, following optional things can be used.
–w.p
The – symbol can be used for left justifying the output value.Sometimes, instead of –, 0 can be
used. In such case the blank spaces are padded with 0. w is a number specifying the number of
columns for the output value. p is a number specifying the number of digits after the decimal
point. Default precision for float is 6. (Important: while specifying values w and p, care should be
taken that 𝑤 ≥ 𝑝 + 7).In case of strings p is number of characters to be displayed from the string.
4 8 3
4 8 3
4 8 3
0 0 0 0 4 8 3
0 0 0 0 4 8 3
0 0 0 0 1 e 3
0 0 0 0 1 E 3
0 0 0 0 7 4 3
printf(“%7d”,a);
printf(“%–7d”,a);
printf(“%2d”,a);
printf(“%07d”,a);
printf(“%7.2d”,a);
printf(“%7x”,a);
printf(“%7X”,a);
printf(“%7o”,a); Formatted outputs
for Fractional or Real Numbers
(assuming value of b as 48.356)
Format Output
Jadhav Kiran
printf(“%f”,b); 4 8 . 3 5 5 9 9 9
printf(“%e”,b); 4 . 8 3 5 6 0 0 e + 0 1
printf(“%9.3f”,b);
printf(“%9.2f”,b); 4 8 . 3 5 6
printf(“%–9.2f”,b);
4 8 . 3 6
printf(“%12.4e”,b);
printf(“%12.2e”,b); 4 8 . 3 6
printf(“%-11.2e”,b);
4 . 8 3 5 6 e + 0 1
4 . 8 4 e + 0 1
4 . 8 4 e + 0 1
printf(“%5c”,c);
printf(“%–5c”,c);
printf(“%s”,d); H a r D D i s k
H a r D D i s k
H a r d D i s k
H a r
H a r D D
H a r
printf(“%6s”,d);
printf(“%12s”,d);
printf(“%12.3s”,d);
printf(“%.6s”,d);
printf(“%–12.3s”,d);
1.10Receiving Input
In a computer, normally a keyboard is treated as standard input and a monitor is treated
as a standard output. A set of C library functions defined in a header file „stdio.h‟ is used for
handling input and output of a C program. Therefore before using these functions in our program
we have to include stdio.h file (#include<stdio.h>).
Functions defined in a file „stdio.h‟ and which are used for receiving input are,
For receiving a single character from standard input, getchar( ) function is used.
e.g.
char var1;
var1=getchar();
putchar(var1);
Output:
D
D_
Jadhav Kiran
The received character can be tested using functions shown in table 1.14.
which are defined in header file ctype.h. Therefore before using these functions we should include
file ctype.h in the program (#include<ctype.h>).
Function Meaning
isalnum( char) Is char an alphanumeric character?
isalpha(char ) Is char an alphabet?
isdigit(char) Is char a digit?
islower(char) Is char a lowercase letter?
isprint(char) Is char a printable character?
ispunct(char) Is char a punctuation mark?
isspace(char) Is char a white space character?
isupper(char) Is char an uppercase letter?
We can use gets( ) function for getting a string from the standard input. e.g.
char name[15];
gets(name);
puts(name);
Output:
Karmaveer
Karmaveer_
We can use scanf( ) function for receiving formatted input. (scanf stands for scan-
formatted).
This function scans input (one character at a time),formats each field according to
corresponding format specifier passed in format string and stores the resulting values at the given
addresses (in the specified variables).
Jadhav Kiran
Example 1:
Output:
- Blank spaces, tabs and ordinary characters (for formatting the input field).
- Control sequence or conversion specification (they are replaced sequentially by
arguments specified after the formats).
Jadhav Kiran
scanf(“%3d%5d”,&a,&b); 765 30275 a=765 b=30275 Width of first field set to 3 and
second to 5
scanf(“%3d%5d”,&a,&b); 30275 765 a=302 b=75 As first field expects width of 3,
only first 3 digits are accepted for
a, remaining 2 digits are assigned
to b and value 765 will be used in
next scanf( ) statement.
scanf(“%f %*f %f”,&x,&y) 65.38 26.3 x=65.38 y=82.12 26.3 will be skipped/ suppressed
82.12 due to *.
scanf(“%d %f %s”,&a,&x,name); 12 87.33 Ram a=12 Data of different types can be read
b=87.12 in a single scanf( ) statement.
name=“Ram”
The scanf( ) function is very sensitive. Following cares should be taken while using this
function.
1.11 Comments
Comments are used for documentation purpose. This is a way of inserting remarks and
reminders into a program without affecting its content. Comments are the statements which are
not executed (i.e. they are ignored by compiler).
In C, comments can be written using combination of /* and */. But proper care should be
taken while writing comments. We should not forget to end the comment. Otherwise the whole
program after it will be treated as comment. e.g.
/* This is a program for performing …………….. */ main( )
{
int a,b,c; /* a and b is used for input and c is used for storing result */
………………
Source Object
Preprocessor Compiler
Program in C Program
Questions
11. State various data types along with their memory sizes. [4M]
12. What are C tokens? Give suitable example. [4M]
13. State the rules of variable declaration. [2M]
14. Give syntax of input and output statement of C. [2M]
15. Define the following. [2M]
a. Bitwise operator
b. Logical operator
16. State four printf format codes. [2M]
17. Write any two advantages of C language. [2M]
18. Elaborate different sections of a C program. [4M]
19. Draw the structure of C program. Also give one example. [4M]
20. Write and explain structure of a C program. [4M]
21. Describe different data types supported by C language. [4M]
22. What is algorithm? Explain in short [4M]
23. Write a program to shift the entered number by three bits left and display the result. [4M]
24. Define following terms. [4M]
a. Identifier
b. Token
c. Operator
d. Data type
25. Write a program to shift the entered number by five bits right and display the result.[4M]
Jadhav Kiran
26. Write a program to mask the most significant digit of the entered number. Use AND
operator. [4M]
27. State the use of increment and decrement operator and give its precedence and
associativity. [4M]
28. Write a program to enter two numbers and find the smallest out of them. Use conditional
operator. [4M]
29. Write a program to enter a number and carry out modular division operation by 2, 3 and 4
and display the remainders. [4M]
30. Explain special operators of C with example. [4M]
31. Explain logical and relational operators of C. [4M]
32. Explain any four arithmetic operators and four logical operators with example. [4M]
33. Attempt the program (5) with division operation and find the quotients.
34. Write a program to enter an integer number and display its equivalent values in octal and
hexadecimal. [4M]
35. Write a program to convert hexadecimal to decimal numbers. Enter the numbers such as
0x1c, 0x18, 0xbc, 0xcd. [4M]
36. Write a program to find the average temperature of five sunny days. Assume the
temperature in Celsius. [4M]
37. Write a program to enter two numbers. Make a comparison between them with a
conditional operator. If the first number is greater than the second perform multiplication
otherwise division operation. [4M]
38. Write a program to calculate the total cost of the vehicle by adding basic cost with (i) excise
duty (15%) (ii) sales tax (10%) (c) octroi (5%) and (d) road tax (1%). Input the basic cost. [4M]
39. Write a program to display ASCII equivalents of following. [2M each]
a. 'A', 'B','C' and 'a','b','c'.
b. 'a'-'C', 'b'-'A' and 'c' − 'B'.
c. 'a'+'c', 'b'*'a' and 'c'+12.
40. Write a program to print whether the number entered is even or odd. Use conditional
operator. [4M]
41. Explain keywords and constants. Give any four keywords. What are types of constants?
[4M]
42. Write a program to demonstrate all possible formatting specifiers. [4M]
43. Explain global and local variable. Write „C‟ program to explain global and local variable.[4M]
44. What is formatted I/O? Explain any two user-defined data types of C. [4M]
45. Explain formatted input and formatted output. [4M]
46. For the following program fragment, derive the output generated by printf statement. [4M]
int a, b, c, d; a=15; b=10; c=++a – b; printf(“a
= %d b = %d c = %d\n”,a,b,c); d=b++ + a;
printf(“a = %d b = %d d = %d\n”,a,b,c); printf(“a = %d b =
%d c = %d d = %d\n”,a,b,c,d); printf(“%d\n”,(c>d)?1:0);
printf(“%d\n”,(c<d)?1:0);
Jadhav Kiran
47. With suitable example and syntax explain how formatted input can be obtained.[4M]
48. How will you add comments into your program? Explain with example. [4M]
49. State logical and relational operator with its meaning. [4M]
50. Define the terms. [4M]
a. Keyword
b. Identifier
c. Variable
d. Constant
51. State use of increment and decrement operator. Give difference between i++ and ++i
statements with example. [4M]
52. Find out errors in the following program component and state how they can be
rectified.[4M] main( )
}
int a = 5, b = 5;
printf(“%d”,a,b)
53. Which of the following are invalid variable names and why? [4M]
BASICSALARY _basic basic–hra
#MEAN group. 422
population in 2006 over time mindovermatter
FLOAT hELLO queue.
team‟svictory Plot # 3 2015_DDay
54. Dfdfdf
55. What would be the output of following program?
a. main( )
{
int i = 2, j = 3, k, l ; float a, b
; k=i/j*j; l=j/i*i
; a=i/j*j; b=j/i*
i;
printf( "%d %d %f %f", k, l, a, b ) ;
b. main( )
{ int a, b ; a = -3 - -
3;
b = -3 - - ( - 3 ) ;
}
Jadhav Kiran
c. main( )
{
float a = 5, b = 2 ;
int c ; c =
a%b;
printf ( "%d", c ) ;
d. main( )
{
e. main( )
{ int a, b ;
printf ( "Enter values of a and b" ) ; scanf ( " %d
%d ", &a, &b ) ;
printf ( "a = %d b = %d", a, b ) ;
f. main( )
{
g. main( )
{
int p, q ; printf ( "Enter values of p and q" ) ;
scanf ( " %d %d ", p, q ) ;
printf ( "p = %d q =%d", p, q ) ;
b. Distance between 2 cities (in km.) is input through keyboard. Write a program to convert
& print this distance in meters, feet, inches and cm.
c. If the marks obtained by a student in five different subjects are input through the
keyboard, find out the aggregate marks and percentage marks obtained by the student.
Assume that the maximum marks that can be obtained by a student in each subject is
100.
d. Temperature of a city in Fahrenheit degrees is input through keyboard. Write a program
to convert this temperature into Centigrade degrees.
e. The length & breadth of a rectangle and radius of a circle are input through the keyboard.
Write a program to calculate the area & perimeter of the rectangle, and the area &
circumference of the circle.
f. Two numbers are input through the keyboard into two locations C and
D. Write a program to interchange the contents of C and D.
g. If a five-digit number is input through the keyboard, write a program to calculate the sum
of its digits. (Hint: Use the modulus operator „%‟) (h) If a five-digit number is input
through the keyboard, write a program to reverse the number.
h. If a four-digit number is input through the keyboard, write a program to obtain the sum
of the first and last digit of this number.
i. In a town, the percentage of men is 52. The percentage of total literacy is 48. If total
percentage of literate men is 35 of the total population, write a program to find the total
numberof illiterate men and women if the population of the town is 80,000.
j. A cashier has currency notes of denominations 10, 50 and 100. If the amount to be
withdrawn is input through the keyboard in hundreds, find the total number of currency
notes of each denomination the cashier will have to give to the withdrawer.
k. If the total selling price of 15 items and the total profit earned on them is input through
keyboard, write a program to find the cost of one item.
l. If a five-digit number is input through the keyboard, write a program to print a new
number by adding one to each of its digits. For example if the number that is input is
12391 then the output should be displayed as 23402.