Professional Documents
Culture Documents
Table of Contents
PART1: C BASICS ..................................................................................................................... 5
INTRODUCTION TO C ......................................................................................................... 5
WHAT IS C?........................................................................................................................ 5
What is a programming language? ...................................................................................... 5
Objective for developing programming languages .............................................................. 5
Why study programming languages .................................................................................... 5
PL can be divided into 2 categories ..................................................................................... 6
HISTORY OF C .................................................................................................................. 6
SERIES OF EVOLUTION .............................................................................................. 6
SALIENT FEATURES OF C .............................................................................................. 7
BUILDING BLOCKS OF C LANGUAGE / ELEMENTS OF C LANGUAGE ....................... 7
1. C character set .................................................................................................................. 7
2. TOKENS .......................................................................................................................... 9
3. IDENTIFIERS .................................................................................................................. 9
4. KEYWORDS ................................................................................................................... 9
5. Datatypes ........................................................................................................................ 10
Fundamental data types...................................................................................................... 10
6. Constants ........................................................................................................................ 10
Integer constants ................................................................................................................ 11
Real constants in C............................................................................................................. 11
Character constants ............................................................................................................ 11
String constants .................................................................................................................. 11
7. Variables......................................................................................................................... 11
Rules for naming C variable: ............................................................................................. 12
STARTING WITH C PROGRAM ........................................................................................... 12
Declaring a variable ............................................................................................................... 12
Prepared By:Ms.Ankita Page 1
C PROGRAMMING: UNIT I
C basics: C character set, Identifiers and keywords, Data types, constants, variables and arrays,
declarations, expressions statements, symbolic constants, compound statements, arithmetic
operators, unary operators, relational and logical operators, assignment operators, conditional
operators, bit operators.
PART1: C BASICS
INTRODUCTION TO C
WHAT IS C?
C is a programming language.
1. MACHINE DEPENDENT
a. The language whose design is governed by the circuitry and the structure of the
machine is known as machine language.
b. This language is difficult to learn and use.
c. It is specific to a given computer and is different for different computers i.e these
languages are machine dependent.
HISTORY OF C
C is a programming language developed at AT & T‟s Bell laboratory of YSA in 1972. It was
designed and written by Denis Ritchie.
SERIES OF EVOLUTION
SALIENT FEATURES OF C
1. C character set
A C program is a sequence of characters. When these characters are submitted to the computer,
they are interpreted in various contexts as characters, identifiers, constants and statements.
The characters used in a C program, belong to the ASCII set.[ ASCII = American Standard Code
for Information Interchange] .
1. Letters
2. Digits
3. White space characters
4. Special characters
5. Delimiters
1. Letters
a. Upper case: A-Z
b. Lower case: a-z
2. Digits : 0-9
3. White space characters:
a. Blank space
b. Horizontal tab
c. Carriage return
d. Form feed
e. New line
4. Special characters/ symbols:
Delimiters Use
:(Colon) Useful for label
;(Semicolon) Terminates statement.
# (Hash) Preprocessor directive.
,(comma) Variable Separator.
{ } (Curly Brace) Scope of statement.
[] (Square bracket) Used for array declaration.
2. TOKENS
A token is the smallest entity that can have a meaning in itself in C.
3. IDENTIFIERS
An identifier is basically a name in a program. Identifiers can be used to denote variables and
functions. In C, an identifier is composed of sequence of characters, where each character can be
a letter, a digit or an underscore but it cannot start with a digit.
Examples
4. KEYWORDS
Keyword or reserved word is word whose meaning is well defined for compiler we can use it in
our program but we can not alter its meaning.
e.g. int, float, do, while etc.
keywords are always used in lower case, although uppercase of same can be used as identifier.
There are such 32 keywords.
5. Datatypes
Data types are used to define a variable before its use. The definition of a variable will assign
storage for the variable and define the type of data that will be held in the location.
Format
S.No C Data types storage Size in bytes Range
specifier
1 char 1 –128 to 127 %c
2 int 2 –32,768 to 32,767 %d
3 float 4 -3.4E38 to +3.4E38 %f
4 double 8 1.7E -308 to 1.7 E +308 %lf
%Lf/
5 long double 10 1.7E -308 to 1.7 E +308
%lf
6 long int 4 –2,147,483,647 to 2,147,483,647 %ld
8 unsigned int 2 0 to 65,535 %u
6. Constants
A constant is an entity that doesn‟t change.
Integer constants
Real or Floating point constants
Character constants
String constants
Integer constants
Real constants in C
Character constants
String constants
7. Variables
It is an identifier whose value changes from time to time during program execution.
C variable is a named location in a memory where a program can manipulate the data.
This location is used to hold the value of the variable.
The value of the C variable may get change in the program.
C variable might be belonging to any of the data type like int, float, char etc.
a. Name
b. Value
c. Memory, where the value gets stored
In C the length of a variable name is unlimited (although the first 31 characters must be unique).
1. Declaring variables
2. Initializing variables
3. Structure of a C program
Declaring a variable
Declaration means assigning a name to memory location where data can be stored.
Syntax :
Datatype varname
int x;
float y;
Initializing variables
When variables are to be created, then they can be initialized in 2ways:
float b=12.4;
char c =‟a‟;
b. Using assignment statement i.e values are assigned after declarations are made.
Example
a. int a;
a=10
b. float b;
b=0.5;
Declaration of a variable in C hints the compiler about the type and size of the variable
in compile time. Similarly, declaration of a function hints about type and size of function
parameters. No space is reserved in memory for any variable in case of declaration.
Example: int a;
Defining a variable means declaring it and also allocating space to hold it.
Here variable "a" is described as an int to the compiler and memory is allocated to hold
value 10
Structure of a C program
Preprocessor directives
Global data declarations
main()
{
Declaration part;
Program statements;
}
P1 SIMPLE C PROGRAM
1. #include<stdio.h>.
#include<stdio.h> tells the compiler to include this header file for compilation. To access the
standard functions that comes with your compiler, you need to include a header with the #include
directive.
2. main()
It is the main program (that is why the name „main‟) that is always executed first. It is always
written (expressed) in lower case.
3. {
These curly braces are equivalent to stating "block begin“and "block end ". The code in between
is called a “block”.
4. printf()
The actual print statement.
Text to be printed is always enclosed in double quotes.
5. }
These curly braces are equivalent to stating "block begin“and "block end ". The code in between
is called a “block”.
6. // Comments
They may appear anywhere within a program.
2 types of comments
7. ; semi colon
Every statement within a function ends with a terminator i.e. semi colon.
8. \n new line
\n at the end of text tells the program / compiler to print a new line as part of the output.
#include<stdio.h>
void main()
{
int n1, n2, sum; // variable declaration
sum = n1 + n2;
n1.n2,sum ---------------variables
int -------------------------datatype (integer)
n1 and n2 will accept integer values
printf---------------------to ask the user to enter values of n1 and n2.
scanf---------------------to intake the values into the program provided by the user.
%d----------------------format specifier
Indicates what type of value is to be printed
In last line, sum is not displayed in double quotes because we want its value to be printed.
SYMBOLIC CONSTANTS
It is a name that substitutes for a sequence of characters or a numeric constant or a character
constant or a string constant.
SYNTAX
symbolic_name in uppercase
examples
#define TRUE 1
#define FALSE 0
#define SIZE 12
If the symbolic constant appears 20 times, then it needs to be changed at 1 place only.
P3 SYMBOLIC CONSTANTS
#include <stdio.h>
#define TAX_RATE 0.10
void main()
{
float balance,tax;
balance=72.10;
tax=balance*TAX_RATE;
printf( “calculated tax= %f”, tax);
}
The individual statements enclosed by braces are executed in the order in which they appear.
General form:
Statement 1;
Statement 2;
.
.
.
Statement n;
}
For example
{
scanf (“%f %f”, &a, &b);
c=a+b;
printf (“a=%f,b=%f,c=%f”,a,b,c);
}
is a compound statement .
For example
a+b, where
+ is an operator
OPERATORS
C language supports following type of operators.
1. Arithmetic Operators( +, - , *, / , %)
6. Conditional Operators ( ? : )
7. Bitwise Operators
Arithmetic Operators
Operator Meaning of Operator
* multiplication
/ division
#include <stdio.h>
void main(){
int a=9,b=4,c;
c=a+b;
printf("a+b=%d\n",c);
c=a-b;
printf("a-b=%d\n",c);
c=a*b;
printf("a*b=%d\n",c);
c=a/b;
printf("a/b=%d\n",c);
c=a%b;
printf("Remainder when a divided by b=%d\n",c);
getch();
}
a+b=13
a-b=5
a*b=36
a/b=2
Remainder when a divided by b=1
Explanation
Here, the operators +, - and * performed normally as you expected. In normal calculation, 9/4
equals to 2.25. But, the output is 2 in this program. It is because, a and b are both integers. So,
the output is also integer and the compiler neglects the term after decimal point and shows
answer 2 instead of 2.25. And, finally a%b is 1,i.e. ,when a=9 is divided by b=4, remainder is 1.
Conversion
Operands in an arithmetic expression can be of integer, float, double type. So conversion needs
to be done.
In some cases, the value of the expression is promoted or demoted depending on the type of
variable on LHS of assignment operator (=).
a/b=2.5
a/d=2.5
c/b=2.5
c/d=2
Implicit conversion
#include<stdio.h>
#include<conio.h>
void main()
{
int i=20;
double p;
clrscr();
p=i; // implicit conversion
printf(“implicit value is %d”,p);
getch();
}
Here, the value of “a” has been promoted from int to double and we have not specified any type-
casting operator. This is known as a standard conversion.
Typecasting concept in C language is used to modify a variable from one date type to
another data type. New data type should be mentioned before the variable name or value
in brackets which to be typecast.
Explicit conversion
C type casting example program:
#include <stdio.h>
void main ()
{
float x;
x = (float) 7/5;
printf("%f",x);
getch();
}
Output:
1.400000
Note:
It is best practice to convert lower data type to higher data type to avoid data loss.
Data will be truncated when higher data type is converted to lower. For example, if float
is converted to int, data which is present after decimal point will be lost.
http://www.programiz.com/c-programming/c-operators
In C, ++ and -- are called increment and decrement operators respectively. Both of these
operators are unary operators, i.e, used on single operand. ++ adds 1 to operand and -- subtracts
1 to operand respectively. For example:
Expression Explanation
++a First increment a by 1, then use the new value of a.
a++ First use given value of a, then increment a by 1.
--b First decrement b by 1, then use the new value of b.
b-- First use given value of b, then decrement b by 1.
Right to left
For example
int a=2,b=3,c;
c=++a – b--;
Explanation
1. First b is evaluated. Since, it is a post decrement operator, current value of b will be used
in the expression i.e. 3 and then b will be decremented by 1.
2. Then,a preincrement is used with „a‟. So, first „a‟ is incremented to 3 and then its value
will be used.
3. After this b=3
a=3
c=a-b
= 3-3
=0
sizeof Operator
Relational operators
main()
int a,b;
if (a<=b)
else
Output
10 <= 12
Logical operators
These type of operators are used to evaluate expressions which may be true or false.
Expressions which involve logical operations are evaluated and found to be one of two values :
true (1) or false (0).
C provides logical operators that may be used to form more complex conditions by combining
simple conditions.
Meaning of
Operator Example
Operator
Logical
! If c=5 then, !(c==5) returns false.
NOT
Explanation
For expression, ((c==5) && (d>5)) to be true, both c==5 and d>5 should be true but, (d>5) is
false in the given example. So, the expression is false. For expression ((c==5) || (d>5)) to be true,
either the expression should be true. Since, (c==5) is true. So, the expression is true. Since,
expression (c==5) is true, !(c==5) is false.
OR operator
Assignment operator
The most common assignment operator is =. This operator assigns the value in right side
to the left side. For example:
= a=b a=b
+= a+=b a=a+b
-= a-=b a=a-b
*= a*=b a=a*b
/= a/=b a=a/b
%= a%=b a=a%b
Conditional Operator
Conditional operator takes three operands and consists of two symbols ? and : . Conditional
operators are used for decision making in C.
2nd operand: represents the value of the entire conditional expression if the condition is true.
3rd operand: represents the value of the entire conditional expression if the condition is false.
For example:
1. c=(c>0)?10:-10;
If c is greater than 0, value of c will be 10 but, if c is less than 0, value of c will be -10
2.
#include <stdio.h>
void main(){
char feb;
int days;
printf("Enter l if the year is leap year otherwise enter 0: ");
scanf("%c",&feb);
days=(feb=='l')?29:28;
/*If test condition (feb=='l') is true, days will be equal to 29. */
/*If test condition (feb=='l') is false, days will be equal to 28. */
printf("Number of days in February = %d",days);
getch();
}
Output
Bitwise Operators
| Bitwise OR
^ Bitwise exclusive OR
~ Bitwise complement
00001100
& 00011001
________
As, every bitwise operator works on each bit of data. The corresponding bits of two inputs are
check and if both bits are 1 then only the output will be 1. In this case, both bits are 1 at only one
position,i.e, fourth position from the right, hence the output bit of that position is 1 and all other
bits are 0.
#include <stdio.h>
int main()
int a=12,b=39;
printf("Output=%d",a&b);
return 0;
Output
Output=4
Bitwise OR operator in C
The output of bitwise OR is 1 if either of the bit is 1 or both the bits are 1. In C
Programming, bitwise OR operator is denoted by |.
#include <stdio.h>
int main()
{
int a=12,b=25;
printf("Output=%d",a|b);
return 0;
Output
Output=29
The output of bitwise XOR operator is 1 if the corresponding bits of two operators are
opposite(i.e., To get corresponding output bit 1; if corresponding bit of first operand is 0
then, corresponding bit of second operand should be 1 and vice -versa.). It is denoted by
^.
#include <stdio.h>
int main()
{
int a=12,b=25;
printf("Output=%d",a^b);
return 0;
}
Output=21
Shift Operator
There are two shift operators in C programming: Right shift operator and Left shift
operator.
1. It is denoted by >>
3. When Data is Shifted Right , leading zero’s are filled with zero.
Syntax :
[variable]>>[number of places]
#include<stdio.h>
int main()
{
int a = 60;
return(0);
}
Output :
Number is Shifted By 1 Bit : 30
Number is Shifted By 2 Bits : 15
Number is Shifted By 3 Bits : 7
3. When Data is Shifted Left , trailing zero’s are filled with zero.
Trailing Zero’s
Replaced by 0
(Shown in RED)
[variable]<<[number of places]
int main()
{
int a = 60;
return(0);
}
Output :
Number is Shifted By 1 Bit : 120
Number is Shifted By 2 Bits : 240
Number is Shifted By 3 Bits : 480
Now after shifting all the bits to left towards MSB we will get following bit pattern
0000 0000 0011 1100 = 60
<< 1
-------------------
0000 0000 0111 1000 = 120
0 Bit 2^0 1
1 Bit 2^1 2
2 Bits 2^2 4
3 Bits 2^3 8
4 Bits 2^4 16
5 Bits 2^5 32
6 Bits 2^6 64
Part 2: C constructs
Control statements determine the “flow of control” in a program and enable us to specify the
order in which the various instructions in a program are to be executed by the computer.
1. Sequence instruction
2. Selection/ decision instruction
3. Repetition or loop instruction
1. Sequence instructions means executing one instruction after another, in the order in
which they occur in the source file.
2. Selection means executing different sections of code depending on a specific condition or
the value of a variable.
1. If
2. If…else
3. Switch
3. Repetition or looping means executing the same section of code more than once. A
section of code may either be executed a fixed number of times, or while some condition
is true.
1. While
2. Do…while
3. for
In if statements:
Then, depending on whether the value of expression is “true” or “false”, it transfers the control to
a particular statement or a group of statements.
Forms of if-statement
1. Simple If statement
2. If else
3. Nested if else
1. SIMPLE IF STATEMENT
It is used to execute an instruction or block of instructions only if a condition is fulfilled.
Syntax
if (test expression) {
The if statement checks whether the text expression inside parenthesis () is true or not. If the test
expression is true, statement/s inside the body of if statement is executed but if test is false,
statement/s inside body of if is ignored.
Flowchart of if statement
Example 1: C if statement
Write a C program to print the number entered by user only if the number entered is
negative.
#include <stdio.h>
int main(){
int num;
scanf("%d",&num);
printf("Number = %d\n",num);
/*If test condition is true, statement above will be executed, otherwise it will not be executed */
return 0;
Output 1
-2
Number = -2
When user enters -2 then, the test expression (num<0) becomes true. Hence, Number = -2 is
displayed in the screen.
Output 2
When the user enters 5 then, the test expression (num<0) becomes false. So, the statement/s
inside body of if is skipped and only the statement below it is executed.
2. C if...else statement
The if...else statement is used if the programmer wants to execute some statement/s when the test
expression is true and execute some other statement/s if the test expression is false.
Syntax of if...else
if (test expression) {
else {
#include <stdio.h>
void main(){
int num;
scanf("%d",&num);
printf("%d is even.",num);
else
printf("%d is odd.",num);
getch();
Output 1
25
25 is odd.
Output 2
2 is even.
else {
The nested if...else statement has more than one test expression. If the first test expression is true,
it executes the code inside the braces{ } just below it. But if the first test expression is false, it
checks the second test expression. If the second test expression is true, it executes the statement/s
inside the braces{ } just below it. This process continues. If all the test expression are false,
code/s inside else is executed and the control of program jumps below the nested if...else
#include <stdio.h>
void main(){
int numb1, numb2;
printf("Enter two integers to check\n");
scanf("%d %d",&numb1,&numb2);
if(numb1==numb2) //checking whether two integers are equal.
printf("Result: %d = %d",numb1,numb2);
else
if(numb1>numb2) //checking whether numb1 is greater than numb2.
printf("Result: %d > %d",numb1,numb2);
else
printf("Result: %d > %d",numb2,numb1);
getch();
}
Output 1
Result: 5 > 3
Output 2
-4
-4
Result: -4 = -4
Practice questions
1. Get the number inputted from the user and check for positive / negative
2. Ask user to enter number. Find its remainder. Check if it is 5, them print the appropriate message.
3. Add 3 numbers and check answer lies between 100 -200.
4. Ask user to enter any year and check whether it‟s a leap year or not.
5. Get the number from year and check for even / odd.
Prepared By:Ms.Ankita Page 45
C PROGRAMMING: UNIT I
6. Ask user to enter any number and check whether it‟s greater than or less than or equal to zero,
and print appropriate message.
7. Check whether the candidate‟s age is greater than 17 or not. If yes, display message “ eligible for
voting”
8. Find smallest/ largest from 2 numbers.
9. Find smallest/ largest from 3 numbers.
2. Switch statements
Decision making are needed when, the program encounters the situation to choose a particular
statement among many statements. If a programmer has to choose one block of statement among
many alternatives, nested if...else can be used but, this makes programming logic complex. This
type of problem can be handled in C programming using switch statement.
Syntax of switch...case
switch (n) {
case constant1:
break;
case constant2:
break;
default:
The value of n is either an integer or a character in above syntax. If the value of n matches
constant in case, the relevant codes are executed and control moves out of the switch statement.
If the n doesn't matches any of the constant in case, then the default codes are executed and
control moves out of switch statement.
Default case is executed if no other statement match is found. It can be placed at any place.
break continue
1. break is a keyword used to terminate the loop 1. continue is a keyword used for skipping the
or exit from the block. The control jumps to next current iteration and go to next iteration of the
statement after the loop or block. loop .
2.Syntax: 2.Syntax:
{ {
Statement 1; Statement 1;
Statement 2; continue;
Statement n; Statement 2;
break; }
}
3. break can be used with for, while, do- while, 3. This statement when occurs in a loop does not
and switch statements. When break is used in terminate it but skips the statements after this
nested loops i.e. within the inner most loop then continue statement. The control goes to the next
only the innermost loop is terminated. iteration. Continue can be used with for, while
and do-while.
4. Example: 4. Example:
i = 1, j = 0; i = 1, j = 0;
while(i<=5) while(i<=5)
{ {
i=i+1; i=i+1;
if(i== 2) if(i== 2) break;
j=j+1;
}
continue;
j=j+1;
}
Write a program that asks user an arithmetic operator('+','-','*' or '/') and two operands and
perform the corresponding calculation on the operands.
# include <stdio.h>
int main() {
char op;
float num1,num2;
scanf("%c",&op);
scanf("%f%f",&num1,&num2);
switch(op) {
case '+':
break;
case '-':
break;
case '*':
break;
case '/':
break;
default:
break;
return 0;
Output
4.5
The break statement at the end of each case cause switch statement to exit. If break statement is not used,
all statements below that case statement are also executed.
Practice questions:
1. Check whether the entered alphabet is vowel or not.
2. Display day of the week as per the number entered [1-7]
LOOPING STATEMENTS
A loop is defined as a block of statements which are repeatedly executed for certain number of times.
1. WHILE
2. DO-WHILE
3. FOR
This is useful where the This ensures that the loop body is run
programmer does not know in at least once.
advance how many times the
loop will be traversed.
}
Also known as entry controlled Also known as entry controlled loop Also known as exit controlled loop
loop
1. FOR LOOP
The basic syntax of the for statement is,
program statement;
Example
int sum=10;
for (i=0; i<6; ++i)
sum = sum+i;
3) Assume test expression is TRUE. Execute the program statements making up the
5) When test expression is FALSE, exit loop and move on to next line of code.
int sum=10; 1 4
for ( i=0 ; i<6 ; ++i )
{ 2
sum = sum+i; 3
}
OR
for(i=0,j=0;i<5;i++)
{
statement1;
statement2;
statement3;
}
for(i=0;i<5;)
{
statement1;
statement2;
statement3;
i++;
}
i = 0;
for(;i<5;i++)
{
statement1;
statement2;
statement3;
}
We have to set value of „i‟ before entering in the loop otherwise it will take garbage value of „i‟.
5. No condition
For(initialize; ; inc/dec)
{
statement1;
statement2;
statement3;
}
In this case, condition must be given inside the body, otherwise it will be an infinite loop.
6. No initialize, no condition
for( ; ; inc/dec)
{
statement1;
statement2;
statement3;
}
In this case, initialization musy be done before and condition must be given inside the loop.
For(initialize ; ; )
{
statement1;
statement2;
statement3;
}
Test and inc/dec must be given inside the body of the loop.
Initialization and inc/dec must be given inside the body of the loop.
Sentinel value
Used as a “stopping” value
It is like a flag or an indicator
Used to let the program know that the user has finished with inputting information.
int age;
printf (“enter an age” (-1 to stop)”);
scanf (“%d”,&age);
While (age != -1)
{
Printf ( “ enter an age( -1 to stop) ” );
Scanf ( “ %d” , &age);
2. WHILE LOOP
The C while statement creates a structured loop that executes as long as a specified condition is
true at the start of each pass through the loop
While Loop is also Entry Controlled Loop.[i.e conditions are checked if found true then and
then only code is executed ]
FOR EXAMPLE
#include <stdio.h>
void main ()
{
getch();
}
When the above code is compiled and executed, it produces the following result:
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 15
value of a: 16
value of a: 17
value of a: 18
value of a: 19
3. DO-WHILE LOOP
A do...while loop is similar to a while loop, except that a do...while loop is guaranteed to execute
at least one time.
If the condition is true, the flow of control jumps back up to do, and the statement(s) in the loop
execute again. This process repeats until the given condition becomes false
do
{
statement(s);
}while( condition );
For example
#include <stdio.h>
void main ()
{
/* local variable definition */
int a = 10;
/* do loop execution */
do
{
printf("value of a: %d\n", a);
a = a + 1;
}while( a < 20 );
getch();
}
When the above code is compiled and executed, it produces the following result:
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 15
value of a: 16
value of a: 17
value of a: 18
value of a: 19
Q1. Ask user to enter a number between 1-10. If that number is > 5, find square of that number ,
otherwise find cube of that number.
Q2. Ask user to enter height of 10 students. Find average height of students.
Q3. Sum of 1+2+3…10.
Q4. Sum of 1+1/2+1/3+1/4…..1/10.
Q5. Find remainder of first 20 numbers when divided by any number.
JUMPING STATEMENTS
C language provides us multiple statements through which we can transfer the
control anywhere in the program
By using this jumping statement, we can terminate the further execution of the
program and transfer the control to the end of any immediate loop.
To do all this we have to specify a break jumping statements whenever we
want to terminate from the loop.
Syntax:
break;
NOTE: This jumping statements always used with the control structure like switch
case, while, do while, for loop etc.
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1;
for(i=1;i<=10;i++)
{
printf(“ \t %d ”,i);
if(i>5)
{
break;
}
}
}
By using this jumping statement, we can terminate the further execution of the
program and transfer the control to the beginning of any immediate loop.
Syntax: continue;
NOTE: This jumping statements always used with the control structure like switch
case, while, do while, for loop etc.
1 2 3 4 6 7 9 10
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1;
clrscr();
for(i=1;i<=10;i++)
{
if(i==5 || i==8)
{
continue;
}
printf(" \t %d ",i);
}
getch();
}
NOTE:
The control will transfer to those label that are part of particular function, where
goto is specified.
All those labels will not included, that are not the part of a particular function
where the goto is specified.
exit()
Stops the execution of the entire program.
#include <stdio.h>
#include <stdlib.h>
void main ()
{
printf("Start of the program....\n");
getch();
}
Let us compile and run the above program that will produce the following result: