C Language Tutorials by Ghulam Murtaza Dahar - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

Output

Maximum no. of inputs: 4

Enter n1: 1.5

Enter n2: 12.5

Enter n3: 7.2

Enter n4: -1

Average: 7.07

Though goto statement is included in ANSI standard of C, use of goto statement should be reduced as much as possible in a program.

Reasons to avoid goto statement

Though, using goto statement give power to jump to any part of program, using goto statement makes the logic of the program

complex and tangled. In modern programming, goto statement is considered a harmful construct and a bad programming practice.

The goto statement can be replaced in most of C program with the use of break and continue statements. In fact, any program in C

programming can be perfectly written without the use of goto statement. All programmer should try to avoid goto statement as possible as they can.

C Programming Decision Making and Loops Examples

This page contains examples and source code on decision making in C programming (to choose a particular statement among many statements) and loops ( to perform repeated task ). To understand all the examples on this page, you should have knowledge of following topics:

1. if...else Statement

2. for Loop

3. while Loop

4. break and Continue Statement

5. switch...case