Problem Solving With Computer: Introduction To Software System Development Lifecycle (SDLC)
Problem Solving With Computer: Introduction To Software System Development Lifecycle (SDLC)
1. Problem definition: activity requires a precise definition of the problem in user terms.
2. Problem analysis: determine program objectives, desired output, required input, and processing
requirements.
3. Program design: characterize design techniques to convert problem definition into solution
definition.
4. Program code: select programming language and write the program code.
5. Program test: running the program on a computer and fixing the parts that do not work; unit test,
system test, integration test, alpha test, beta test.
6. Program documentation: write procedures for users, operators, and programmers.
7. Program maintenance: adjust for errors, inefficient or ineffective operations, nonstandard code, and
changes over time.
1.1Problem Definition:
This activity requires a precise definition of the problem in user terms. A clear statement of the problem is very
essential to the success of the software. It helps the program developer to understand the problem better.
1.3.2-Algorithms
Algorithms consist of statements in describing structured program steps and logic. It allows the program
designer to focus on the logical steps of the programs and not on details of programming or flowcharting.
1
1.3.3-Flowcharts
One of the most widely used tool for designing structured programs is the flowchart, which graphically
represents the logic needed to solve a programming problem. A program flowchart represents the detailed
sequence of steps, needed to solve the problem. Program flowcharts are frequently used to visualize the
logic and steps in processing. Following symbols are widely used to construct flowcharts.
Predefine Document
Internal Multiple
Process
Manual Direct
Operation Magnetic Display
Access
Disk Storage
Data symbol is used to represent any input or output operation. It may represent the point in a program
where the data (input) is required or where the information (output) is to be displayed.
Process symbol represents some type of data manipulation or arithmetic operation.
Decision symbol represents a logical comparison operation. Based on the comparison, one of the two path
will be taken.
Connector symbol is used to connect another portion of the flow chart where the program flow continues.
Predefined process symbol is often used to represent a process that is used several times in the same
program. This process is defined only once and reference by
this block thereafter. START
Terminator symbol represents the start or end of a program.
Direction of flow symbols READ N
START indicates the next step in the
program
FACTN = 1
INPUT L
I=1
INPUT B
FACTN = FACTN*I
A = L*B
NO
PRINT L, B, A IS I = N I = I+1
YES
END PRINT N, FACTN
END
2
An example of a flow chart to calculate area of a rectangle
An example of a flow chart to calculate the Factorial of a
number N
1.4Coding
In this step, programmers use the logic developed in the design phase to actually write the program. Most of
the time required to complete a project is spent here. Writing a computer program is a cyclic process of
writing code, compiling, correcting, and rewriting. The more detailed the design, the more easier is the
coding and better its reliability.
The compiler translates each high-level language instruction into a set of machine language instructions at
once. Every high level language has its own compiler. Thus, compiler can translate only those source codes,
for which it is designed. For example, a C compiler is only capable of translating source code written in C
language. Therefore, each computer requires a separate compiler for each high-level language.
3
Source File Source File Source File
Compiler
Executable
Linker
Routine program
Compiling process
The first step is to pass the source code through a compiler, which translates the high-level language
instructions into object code. If there is any syntax error in the program, it will be checked at the time of
compilation. Compiler only produces object code when the source code is free from syntax error. Then
object code is further passed through linker program to produce executable code.
1.6 Debugging, Testing and Documentation
1.6.1Testing
Testing a program means running the program on a computer and fixing the parts that do not work. There
are two types of programming errors- syntax errors and logic errors.
A syntax error occurs due to violation of the rules of the programming language (ie if a programmer does
not write syntax correctly). A logic error occurs when there is an incorrect output or result. There are
number of ways by which syntax and logic errors weeded out.
Structured walkthrough: -A structured walkthrough is a formal review process designed not only to verify
computer code but also evaluate the documentation and the design of the program. In this process, a coded
program is submitted to a review team of programmers including the one who produced the code. After
review, the program’s overall completeness, accuracy, and quality of the design are discussed. Typically the
program is put through desk checking, in which the entire program is reviewed, that is by running sample
data manually through the program.
Checking for syntax errors: - After the structured walkthrough, the programmer attempts to compile/run
the program. If there are any syntax errors that have slipped the walkthrough phase, they will be identified
by programs –compiler or interpreter.
Checking for logic errors: - After all syntax errors have been corrected and the program code has been
successfully translated into machine code, the program can be tested for logic errors using a set of test data,
designed to thoroughly test all aspects of the program. Both the tested output and the expected output are
compared to find out the existence of any logic errors.
It is important to catch these errors, both syntax and logic, as early in the programming process as possible.
Unit Testing refers to a method of testing that verifies the individual units of source code are working
properly. Since this testing deals with the software code, and requires a detailed knowledge of it, it is
implemented by the programmer itself rather than the software tester.
4
Functional Testing involves testing the system against the functional requirements for the product. For
system testing, no knowledge of internal logic or code structure is required.
Integration Testing: Different small software modules are combined together to perform the integration
testing. Here, the testing process is taken as a whole system testing.
1.6.2Debugging
Debugging is a process of eliminating logical errors (program bugs) from a program. Debugger is a kind of
translator that is used in high level programming language for debugging process. Debugger is a program
that executes a command of programming statement at a time, so we can thoroughly test all aspects of the
program. Every high level language has its own debugger.
1.6.3Documentation
Program documentation consists of written descriptions and procedures about a program and how to use it.
This document should contain statements on the program’s objectives, output specifications, input
requirements, processing requirements and feasibility. In other words, the document should describe
everything you have done so far. Documentation is carried on throughout all the programming steps.
The following items may be expected as part of the complete process of documentation:
♦ A statement of the problem.
♦ Documents specifying the formats of inputs and outputs.
♦ Details about data structure and file structure.
♦ Description about elimination of errors (error-free methods) of input and output for the program’s users.
♦ Detailed instructions to the user
1. Limitations of the program.
2. Requirements in order to run the programs
3. Details of how to run the program.
4. Instructions, with examples, on how to use the program.
Programs written in C are efficient and fast. This is due to variety of data types and powerful operators. C language is
well suited for structured programming, thus requiring the user to think of a problem in terms of function modules or
blocks. A proper collection of these modules would make a complete program. This modular structure makes program
debugging, testing and maintenance easier.
1.8-Structure of a C program
A program written in ‘C’ language may contain one or more sections given below.
Documentation Section
Link Section
Definition Section
Executable Part
}
Subprogram or user-defined function section
Function 1
Function 2
.
.
Function n
The documentation section consists of a set of comment lines giving the name of the program, the author
and other details which the programmer would like to use later.
The link section provides instructions to the compiler to link functions from the system library. The
definition section defines all symbolic constants.
There are some variable that are used in more than one function. Such variable are called global variables
and are declared in the global declaration section that is outside of all the functions.
Every C program must have one main() function. The program will always begin by executing the main
function, which may access other functions. Any other function definitions must be defined separately,
either ahead of or after main. This section contains two parts, declaration part and executable part. The
declaration part declares all the variables used in the executable part. There is at least one statement in the
executable part. These two parts must appear between the opening and the closing brace. The closing brace
of the main function section is the logical end of the program. All statements in the declaration and
executable parts end with a semicolon.
The subprogram section contains all the user-defined functions that are called in the main function. Every
C program consists of one or more modules called functions. A function is a subroutine that may include one
or more statements designed to perform a specific task. To write a C program, we first create functions and
6
then put them together. User-Defined functions are generally placed immediately after the main function
although they may appear in any order.
A simple ‘C’ program that display a message “Hello World” in your screen.
#include <stdio.h>
void main()
{
printf("***********************\n");
printf("\n* Hello World *\n");
printf("***********************\n");
}
Review Questions
1. Discuss in brief about different steps involved in program development phase.
2. Write short notes on algorithm and flowchart. Explain their uses.
3. Explain briefly about the source code compilation process of structured programming language.
4. Give a brief introduction on ‘C’ language.
5. Write short notes on following
a) Testing
b) Debugging
c) Structure of a program written ‘C’ language
2. Elements of C
In C program the smallest individual units are known as C tokens (basic elements of C).
7
C TOKENS
+ - * / = % & # ! ? ^ “ ‘ ~
\ | < > ( ) [ ] { } : ;
. , _ @ $ (blank space)
2.2Identifiers
Identifiers are names that are given to various program elements, such as variables, functions and arrays.
Identifier consist of letters and digits, in any order, except that the first character must be a letter. Both
upper- and lowercase letters are permitted. An uppercase letter is not equivalent to the corresponding
lowercase letter. The underscore character (_) can be included, and is considered to be a letter.
2.4Data types
C language is rich in its data types. Storage representations and machine instructions to handle constants
differ from machine to machine. The variety of data types allow the programmer to select the type
appropriate to the needs of the application as well as the machine. C general (or fundamental) data types are
listed below.
The char type is used to represent individual characters and it requires one byte of memory. With most
compilers, a char data type will permit a range of values extending from 0 to 255. Some compilers represent
the char data (with typical values ranging from –128 to +127).
long int big_number data range (-4294967296 through to +4294967295). Long int will generally have
double the requirements (e.g., 4 bytes).
float floating point numbers with data range (MAXFLOAT 3.40282346638528860e+38 and MINFLOAT
1.40129846432481707e-45)
long float (double) floating point numbers with data range (MAXDOUBLE 1.79769313486231470e+308
and MINDOUBLE 4.94065645841246544e-324)
Signed and unsigned prefixes: - For both the character and integer types the declaration can be preceded by
the word "unsigned". This shifts the range so that0is the minimum, and the maximum is twice that of the
signed data type. It's useful if you know that it is impossible for the number to go negative.
9
double 64 bits 1.7 * (10**-308) to 1.7 * (10**+308)
long double 80 bits 3.4 * (10**-4932) to 1.1 * (10**+4932)
2.5Escape sequence
Certain nonprinting characters, as well as the backslash (\) and apostrophe ( ‘ ), can be expressed in terms of
escape sequences. An escape sequence always begins with a backward slash and is followed by one or more
special characters.
The commonly used escape sequences are listed below.
10
CONSTANTS
Decimal (base 10). A decimal integer constant can consist of any combination of digits taken from the set 0
through 9.
Octal (base 8). An octal integer constant can consist of any combination of digits taken from the set 0
through 7. However the first digits must be 0, in order to identify the constant as an octal number.
Hexadecimal (base 16). A hexadecimal integer constant must begin with either ox or OX. It can then be
followed by any combination of digits taken from the sets 0 through 9 and the letters a through f (or A
through F) represents the (decimal) quantities 10 through 15, respectively.
Unsigned and long integer constants: - An unsigned integer constants can be approximately twice as large
as an ordinary int (though of course negative values are not permitted). An unsigned integer constant can be
identified by appending the letter U (either upper- or lowercase) to the end of the constant.
Long integer constants may exceed the magnitude of ordinary integer constants, but require more memory
within the computer. To create a long integer constant, append the letter L (either upper- or lowercase) to the
end of the constant.
Floating-Point Constants (Real Constants): - A floating-point constant is a base-10 number that contains
either a decimal point or an exponent (or both). Floating-point constants have a much greater range than
integer constants. Typically, the magnitude of a floating-point constant might range from a minimum value
of approximately 3.4E-38 to a maximum of 3.4E+38. Some versions of language permit floating-point
constants that cover a wider range, such as 1.7E-308 to 1.7E+308. Floating point constants are normally
represented as double-precision quantities in C. The general form is:
mantissa e exponent
The mantissa is either a real number expressed in decimal notation or an integer. The exponent is an
integer number with an optional plus or minus sign. The letter e separating the mantissa and the exponent
can be written in either in uppercase or lowercase. Since the exponent causes the decimal point to “float”,
this notation is said to represent a real number in floating point form.
Example
The quantity 3*105 can be represented in C by any of the following floating-point constants.
300000. 3e5 3e+5 3E5 3.0e+5 .3e6 0.3E6 30E4 300e3
-5
The quantity 5.001*10 can be represented in C by any of the following floating-point constants.
5.001E-5 .5001E-4 50.01E-6
11
Character Constants: - A character constant is a single character, enclosed in apostrophes.
Example of character constants are shown below.
‘A’ ‘X’ ‘9’
Character constants have integer values that are determined by the computer’s particular character set.
Most computers, and virtually all personal computers, make use of the ASCII (i.e., American Standard
Code for Information Interchange) character set, in which each individual character is numerically encoded
with its own unique 7-bit combination (hence a total of 27 = 128 different characters). For example
Constant Value
A---Z 65---
90
a---z 97---
122
0---9 48---
57
String Constants: - A string constant consists of any number of consecutive characters, enclosed in
(double) quotation marks.
Some examples of string constants are as shown below
“Name” “School” “245115” “$111.90” “Line 1\nLine 2\nLine 3”
Symbolic constants: - A symbolic constant is a name that substitutes for a sequence of characters. The
characters may represent a numeric constant, a character constant or a string constant. Thus a symbolic
constant allows a name to appear in place of a numeric constant, a character constant or a string. When a
program is compiled, each occurrence of a symbolic constant is replaced by its corresponding character
sequence.
void main()
{
float radius,area;
printf("Input the value of radius\n");
scanf("%f",&radius);
area = PI*radius*radius;
printf("%s\n",MESSAGE);
printf("\a\n");
printf("Radius = %f Area = %f\n\n",radius,area);
printf("Type any number and press Enter\n");
scanf("%f",&radius);
}
12
2.7Variables
A variable is an identifier that is used to represent a single data item; i.e., a numerical quantity or a character
constant. Initially, data item must be assigned to the variable at some point in the program. The data item
can then be accessed later in the program simply by referring to the variable name. A given variable can be
assigned different data items at various places within the program. Thus, the information represented by the
variable can change during the execution of the program.
Local variables: - Local variables are declared within the body of a function, and can only be used within
that function.
Global Variables: - Alternatively, a variable can be declared globally so it is available to all functions.
Modern programming practice recommends against the excessive use of global variables. A global variable
declaration looks normal, but is located outside any of the program's functions. This is usually done at the
beginning of the program file, but after preprocessor directives. The variable is not declared again in the
body of the functions which access it.
External Variables: - Where a global variable is declared in one file, but used by functions from another, then
the variable is called an external variable in these functions, and must be declared as such. The declaration
must be preceded by the word extern. The declaration is required so the compiler can find the type of the
variable without having to search through several source files for the declaration.
Global and external variables can be of any legal type. They can be initialized, but the initialization takes
place when the program starts up, before entry to the main function.
Static Variables: - Another class of local variable is the static type. A static can only be accessed from the
function in which it was declared, like a local variable. The static variable is not destroyed on exit from the
function; instead its value is preserved, and becomes available again when the function is next called. Static
variables are declared as local variables, but the declaration is preceded by the word static. Following
example represents the declaration of static variable.
Variable declarations: - A declaration associates a group of variables with a specific data type. A
declaration consists of a data type, followed by one or more variable names, ending with a semicolon. Each
array variable must be followed by a pair of square brackets, containing a positive integer which specifies
the size (number of elements) of the array.
Review Questions
1. Describe the basic data types in C with suitable example.
2. What is an operator? Describe several types of operators that are included C.
3. What is scope and lifetime of a variable? Describe global local and static variables in terms of their
scope and lifetime.
4. Write short notes on following
a) Constants
b) Variable
c) Keywords
d) Identifier
‘C’ programming language has a number of input/output functions. Some of these functions
are getchar putchar -> facilitate the input and output of character. scanf printf -> permit
the transfer of single characters, numerical values and strings.
13
gets puts -> facilitate the input and output of strings.
These functions permit the transfer of information between the computer and the standard input/output
devices. As a rule, the header file required by the standard input/output library functions is called “stdio.h”
(standard input/out function).
3.1Character input/output
getchar(): ‐ Single Character Input Function
The getchar() function is a part of the ‘C’ I/O library. It returns a single character from a standard input
device (typically a keyboard). General syntax of using getchar() function is written as: Character
variable = getchar();
Where character variable refers to some previously declared character variable
#include<stdio.h>
#include<ctype.h>
void main()
{
char upper, lower;
lower = getchar(); upper
=toupper(lower);
putchar(upper);
putchar(‘A’); putchar(65);
getch();
}
Formatted Data Output Function –printf(): - Output data can be written from the computer onto a
standard output device means of the C library function printf(). This function can be used to output any
combination of numerical values, single characters and strings. It is similar to the input function scanf(),
except that its purpose is to display data rather than to enter it to the computer. In general terms, the printf()
function is written as printf(control1 string, arg1, arg2,..., argn)
Where control string refers to a string containing certain required formatting information, and arg1, arg2, ...,
argn are arguments that represent the individual input data items.
The control string consists of individual groups of characters, with one character group for each output data
item. Each character group must begin with a percent sign (%). In its simplest form, a single character group
will consists of the percent sign, followed by a conversion character indicating the type of the corresponding
data item. Within the control string, multiple character groups can be contiguous, or they can be separated
by white-space characters (i.e., blank spaces, tab or new-line characters).
15
X Data item is displayed as a hexadecimal integer, without the leading ox
And operator
Z= X && Y
x y z
0 0 0
0 1 0
1 0 0
1 1 1
Or operator
Z= X !! Y
x y z
0 0 0
0 1 1
1 0 1
1 1 1
17
4.6- Assignment Operators
There are Several Assignment operators in C which is used to assign the value of an expression to an
identifier. The most commonly used assignment operator is =. Assignment expressions that make use of this
operator are written in the form
Identifier = expression
Where identifier generally represents a variable and expression represents a constant.
Operator Meaning
= Assign right hand side(RHS) value to the left hand side(LHS)
+= Value of LHS variable will be added to the value of RHS and assign it back to the
variable in LHS
-= Value of RHS variable will be subtracted from the value of LHS and assign it back
to the variable in LHS.
*= Value of LHS variable will be multiplied by the value of RHS and assign it back to
the variable in LHS.
/= Value of LHS variable will be divided by the value of RHS and assign it back to the
variable in LHS.
%= The Remainder will be stored back to the LHS after integer division is carried out
between the LHS variable and the RHS variable
Assignment operators have a lower precedence than any of the other operators that been discussed so far.
Expression Equivalent
Expression
i += 5 i=i+5
f -= g f=f–g
j *= (i - 3) j = j * (i - 3)
f /= 3 f=f/3
i %= (j - 2) i = i % (j - 2)
In this case, Expression 1 is evaluated first. If expression 1 is true, then expression 2 is evaluated and
becomes the value of the conditional expression. Otherwise expression 3 is evaluated and becomes the value
of the conditional expression.
Example: Here is an assignment statement that contains a conditional expression on the right-hand side.
flag = (i < 0)? 1: 0
If the value of i is negative, then 1 will be assigned to flag. If it is not negative, however, 0 will be assigned
as flag
min = (x1 < x2) ? x1 : x2
This statement causes the value of the smaller of x1 and x2 to be assigned to min. 4.8-
Precedence rule for all of the operators
Operator category Operators Associativity
18
Unary operators - ++ -- !sizeof (type) R→L
Arithmetic multiply, divide and remainder * / % L→R
Arithmetic add subtract + - L→R
Relational operators < <= > >= L→R
Equality operators == != L→R
Logical and && L→R
Logical or || L→R
Conditional operator ?: R→L
Assignment operators = += -= *= /= %= R→L
4.9-Expressions
An expression consists of one or more data items interconnected by one or more operators. Expressions can
also represent logical conditions that are either true or false.
Examp
les: a
+b x
=y a
<= b
x == y
++i
4.10-Statements
A statement causes the computer to carry out some action. There are different types of statements in C. They
are expression statements, compound statements and control statements. An expression statement consists
of an expression followed by a semicolon. The execution of an expression statement causes the expression to
be evaluated. Examples:
y = a + b;
++i;
A compound statement consists of several individual statements enclosed within a pair of braces ({ }). The
individual statements may themselves be expression statements, compound statements or control statements.
Review Questions
1. Explain operator precedence and associativity with suitable examples.
2. Explain in brief about the different types of operators available in C language.
3. What logical operators are available in C? Explain their precedence and associativity with examples.
4. Write short notes on following
a) Expressions and statements
b) Conditional operator
c) Unary Operators
5-Control Statements
The order in which program instructions are performed by the computer must be carefully controlled, and
programming languages like C contain features that allow the order of instruction execution to be controlled.
19
5.1-Control structures
Program control structures are used to regulate the order in which program statements are executed. Types of
control structures-
¾ Sequences
¾ Selections
¾ Repetitions
Sequences: In the absence of selections or repetitions program statements are executed in the sequence in
which they appear in the program:
Instruction1
Instruction2
Instruction3
5.2-Selection
Selections form part of the decision-making facilities within programming languages. They allow alternative
actions to be taken according to the conditions that exist at particular stages in program execution.
2Selections
2.1 If statement
2.2 If-else statement
2.3 if else if statement
2.4 Switch-case statement
If Statement
It is used to express conditional expressions. If the given condition is true, then it executes the statements.
Syntax
if
If(expression)
{
statement-1; statement- false
2; expression
}
true
Statement1
Statement2
endif
If -else statement
The if –else statement is used to carry out a logical test and then take one of two possible actions depending
on the outcome of the condition. If the given expression is true, then the statements of if part will be
executed, otherwise the statement of the else part will be executed.
Syntax
If(expression) if
{
false true
Instruction1;
} expression
20
Instruction2 Instruction1
endif
else {
Instruction2;
}
Syntax if
If(Expression_1)
{
true
Instruction_1;
Expression_1 Instruction1
}
else if(Expression_2) false
{ true
Instruction_2; Expression_2 Instruction2
}
else if(Expression_n) false true
{
Instruction_n; Expression_n Instruction_n
}
false
else
{ Instruction_else
Instruction_else;
}
endif
21
swhich
Expression
case ‘X’: case ‘Y’: case ‘Z’: default:
End switch
Syntax
switch(expression)
{
case ‘X’:
InstructionX;
break; case
‘Y’:
InstructionY;
break; case
‘Z’:
InstructionZ;
break; default:
Default_Instruction;
}
Example-4
#include<stdio.h>
#include<ctype.h>
#include<conoi.h>
5.4-Loop Statements
The repeated performance of the same statements is often called loping. There are three common types of
loop constructs.
Loop Statements
3.1 While Loop
3.2 For loop
3.3 do- While Loop
While loop is indefinite loop (ie. it does not define the number of repetitions that will occur when the loop
is executed). The while statement is used to carry out looping operations, in which a group of statements
is executed repeatedly, until some condition has been satisfied. The general form of the while statement is,
while (expression) statement
22 while
Instructions
true
false
The statement will be executed repeatedly, as long as the expression is true. The statement can be either
endwhile
simple or compound.
Do –while statement
With while loop, the test for continuation of the loop is carried out at the beginning of each pass. With
do- while statement, the test for continuation of the loop is carried out at the end of each pass. The
general form of the do- while statement is, do statement while (expression);
The statement will be executed repeatedly, as long as the value of expression is true. The statement will
always be executed at least once, since the test for repetition does not occur until the end of the first pass
through the loop. The statement must include some feature that eventually alters the value of expression so
the looping action can terminate.
For loop
The for loop is the most commonly used looping in C. For loop is definite loop (ie. defines the number of
repetitions that will occur during execution).
for
i=i+1
i<=10 Instructions
23 true
false
endfor
The first line of the for-statement contains three expressions, enclosed in parentheses. The first expression
assigns an initial value 0 to the integer variable i; the second expression continues the looping action as long
as the current value of digit does not exceed 10 at the beginning of each pass; and the third expression
increases the value of digit by 1 at the end of each pass through the loop.
where expression_1a and expression_1b are two expressions, separated by the comma operator. These two
expressions would typically initialize two separate indices that would be used simultaneously within the for
loop similarly, a for statement might make use of the comma operator in the following manner: for
(expression_1a, expression_1b; expression_2; expression_3a, expression_3b) statement
Example-8. A sample program that will demonstrate nested for loop structure.
#include <stdio.h>
#include <conio.h>
void main()
{
int i,j;
clrscr(); for (i
=0; i<5;i++)
{
for (j =0; j<=i;++j) printf(" %d ",i);
printf("\n");
}
getch();
}
printf("\Enter a number\n");
scanf("%",&n);
i=2;
while(i<n)
{
if(n % i==0)
{
printf("\nNot a prime number");
break;
}
i++;
}
if(i==n)
printf("\nPrime number");
getch();
}
In this program the moment num % i turns out to be zero, the message “Not a prime number” is printed and
the control breaks out of the while loop.
Continue statement
The continue statement is used to bypass the reminder of the current pass through a loop. The loop does not
terminate when a continue statement is encountered. Rather, the remaining loop statements are skipped and
the computation proceeds directly to the next pass through the loop.
Goto statement
The goto statement is used to alter the normal sequence of program execution by transferring control to
some other part of the program. Syntax
goto label;
Where label is an identifier that is used to label the target statement to which control will be transferred. The
target statement must be labeled, and the label must be followed by a colon. Thus, the target statement will
appear as
Label: statement
Example-11
#include<stdio.h>
#include<conio.h>
void main()
{
25
char ch;
clrscr();
printf("Inter any alphebet\n");
ch = getchar();
if ((ch == 'A') || (ch == 'a') || (ch == 'E') || (ch == 'e') || (ch == 'I') || (ch == 'i') || (ch == 'O') || (ch == 'o')
|| (ch == 'U') || (ch == 'u'))
{
printf("\n Youu have typed an alphabet: %c is vowel",ch);
goto label1;
}
printf("\n Youu have typed an alphabet: %c is consonent",ch);
label1:
getch();
}
26