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

Enter operator +, -, * or / :

/

Enter two operators:

34

3

num2/num1=11.33

Notice break statement at the end of each case, which cause switch...case statement to exit. If break statement are not used, all statements below that case statement are also executed.

C Programming goto Statement

In C programming, goto statement is used for altering the normal sequence of program execution by transferring control to some other part of the program.

Syntax of goto statement

goto label;

.............

.............

.............

label:

statement;

In this syntax, label is an identifier. When, the control of program reaches to goto statement, the control of the program will jump to the label: and executes the code/s after it.

Example of goto statement

/* C program to demonstrate the working of goto statement.*/

# include <stdio.h>

int main(){

float num,average,sum;

int i,n;

printf("Maximum no. of inputs: ");

scanf("%d",&n);

for(i=1;i<=n;++i){

printf("Enter n%d: ",i);

scanf("%f",&num);

if(num<0.0)

goto jump; /* control of the program jumps to label jump */

sum=sum+num;

}

jump:

average=sum/(i-1);

printf("Average: %.2f",average);

return 0;

}

Find Your Next Great Read

Describe what you're looking for in as much detail as you'd like.
Our AI reads your request and finds the best matching books for you.

Showing results for ""

Popular searches:

Romance Mystery & Thriller Self-Help Sci-Fi Business