C goto statement
The goto statement is known as jump statement in C language. It is used to unconditionally jump to other label. It transfers control to other parts of the program It is rarely used today because it makes program less readable and complex Syntax:
goto label;
goto example
Let's see a simple example to use goto statement in C language.
#include <stdio.h> void main() { int age; ineligible: printf("You are not eligible to job!\n"); printf("Enter you age:\n"); scanf("%d", &age); if(age<20) goto ineligible; else printf("You are eligible to job!\n"); } Output: You are not eligible to job! Enter you age: 15 You are not eligible to job! Enter you age: 35 You are eligible to job!
Type Casting in C
Type casting allows us to convert one data type into other. In C language, we use cast operator for type casting which is denoted by (type). Syntax:
(type)value;
Without Type Casting:
int f= 27/5; printf("f : %d\n", f ); Output: 5
float f=(float) 27/5; printf("f : %f\n", f ); Output: 5.400000
#include <stdio.h> void main(){ float f= (float)27/5; printf("f : %f\n", f ); } Output: f : 5.400000