The control statements enable us to specify the order in which the various instructions in a program are to be executed by the computer. They determine the flow of control in a program.
There are 4 types of control statements in C. They are:
a) Sequence control statements
b) Decision control statements or conditional statement
c) Case-control statements
d) Repetition or loop control statements
Decision-making structures require that the programmer specifies one or more conditions to be evaluated or tested by the program, along with a statement or statements to be
executed if the condition is determined to be true, and
optionally, other statements to be executed if the condition is determined to be false.
Shown below is the general form of a typical decision-making structure found in most of the programming languages:
Detailing about basics of C language and its control structure for learning C Language for beginners. It covers looping statement , control statement etc.
BRANCHING STATEMENTS
if statement
if – else statement
if – else if ladder
Nested if
Goto
Switch case
programs
output
flowchart
Branching / Decision Making Statements
The statements in the program that helps to transfer the control from one part to other parts of the program.
Facilitates program in determining the flow of control
Involves decision making conditions
See whether the condition is satisfied or not
If statement; Execute a set of command line or one command line when the logical condition is true.
It has only one option
syntax with flowchart
If else if ladder; Number of logical statements are checked for executing various statement
If the first condition is true the compiler executes the block followed by first if condition.
If false it skips the block and checks for the next logical condition followed by else if.
Process is continued until a true condition is occurred or an else condition is satisfied.
Switch case; Multiway branch statement
It only requires one argument of any type, which is checked with number of cases.
If the value matches with the case constant, that particular case constant is executed. If not the default statement is executed.
Break statement – used to exit from current case structure
Nested if else; When a series of decisions are involved we use more than one if-else statement.
If condition is true control passes to first block i.e., if block. In this case there may be one more if block.
If condition is false control passes to else block. There we may have one more if block.
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:
if...else Statement
for Loop
while Loop
break and Continue Statement
switch...case
The Three Basic Selection Structures in C++ Programming ConceptsTech
Now check the powerpoint presentation about selection structures in programming. For more visit www.techora.net
Three types of selection structures are available like :
1 - Sequence Structure
2 - Selection Strcuture
3 - Repetition Structure
In this PPT slide, we discuss about the selection structure
1 - if statements
2 - if else statement
3 - switch statement
Introduction to control structure in C Programming Language include decision making (if statement, if..else statement, if...else if...else statement, nested if...else statement, switch...case statement), Loop(for loop, while loop, do while loop, nested loop) and using keyword(break, continue and goto)
Decision-making structures require that the programmer specifies one or more conditions to be evaluated or tested by the program, along with a statement or statements to be
executed if the condition is determined to be true, and
optionally, other statements to be executed if the condition is determined to be false.
Shown below is the general form of a typical decision-making structure found in most of the programming languages:
Detailing about basics of C language and its control structure for learning C Language for beginners. It covers looping statement , control statement etc.
BRANCHING STATEMENTS
if statement
if – else statement
if – else if ladder
Nested if
Goto
Switch case
programs
output
flowchart
Branching / Decision Making Statements
The statements in the program that helps to transfer the control from one part to other parts of the program.
Facilitates program in determining the flow of control
Involves decision making conditions
See whether the condition is satisfied or not
If statement; Execute a set of command line or one command line when the logical condition is true.
It has only one option
syntax with flowchart
If else if ladder; Number of logical statements are checked for executing various statement
If the first condition is true the compiler executes the block followed by first if condition.
If false it skips the block and checks for the next logical condition followed by else if.
Process is continued until a true condition is occurred or an else condition is satisfied.
Switch case; Multiway branch statement
It only requires one argument of any type, which is checked with number of cases.
If the value matches with the case constant, that particular case constant is executed. If not the default statement is executed.
Break statement – used to exit from current case structure
Nested if else; When a series of decisions are involved we use more than one if-else statement.
If condition is true control passes to first block i.e., if block. In this case there may be one more if block.
If condition is false control passes to else block. There we may have one more if block.
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:
if...else Statement
for Loop
while Loop
break and Continue Statement
switch...case
The Three Basic Selection Structures in C++ Programming ConceptsTech
Now check the powerpoint presentation about selection structures in programming. For more visit www.techora.net
Three types of selection structures are available like :
1 - Sequence Structure
2 - Selection Strcuture
3 - Repetition Structure
In this PPT slide, we discuss about the selection structure
1 - if statements
2 - if else statement
3 - switch statement
Introduction to control structure in C Programming Language include decision making (if statement, if..else statement, if...else if...else statement, nested if...else statement, switch...case statement), Loop(for loop, while loop, do while loop, nested loop) and using keyword(break, continue and goto)
Decision making in C. Decision making is about deciding the order of execution of statements based on certain conditions or repeat a group of statements until certain specified conditions are met. C language handles decision-making by supporting the following statements, if statement.
HTML stands for Hyper Text Markup Language, which is the most widely used language on Web to develop web pages. and dummies guide to html5 and complete html guide pdf
Ransomware is a type of malicious software that blocks access to data or threatens to publish it until a ransom is paid. Simple ransomware may lock the system in a way which is not difficult for a knowledgeable person to reverse. More advanced malware uses a technique called cryptoviral extortion, in which it encrypts the victim's files, making them inaccessible, and demands a ransom payment to decrypt them and ransomware attacks 2017
How to write a Great Research Paper?
The research paper is a significant piece of academic writing, in which the author performs research on a topic independently and writes a description of the results of that research. It is written to communicate to the community and to contribute to the advancement of knowledge. Types of papers include:
• Inventions
• Progress
• Survey
https://www.ThesisScientist.com
Research process involves a systematic way that focuses on being objective and gathering a multitude of information for analysis so that the researcher can come to a conclusion. Basic steps that should be considered and research process definition pdf and marketing research process 5 steps
How to write a good Dissertation/ Thesis
Thesis refers to a written work on a particular domain resulting from original research. You should introduce your subject area and explain research topic by referring latest published materials instead of old published materials. The objective is to present a simple, clear and complete account of the results of your research.
• Brainstorm or generate ideas for your topic.
• Conduct a thorough literature search before designing your methodology and collecting your data.
Relate your findings to your original statement of the problem and your literature review.
Https://www.ThesisScientist.com
How to write a research paper: How to write a research paper?
The research paper can be considered as the living thing which grows and changes as the student explores, interprets and evaluates sources related to a specific topic. Steps to write a research paper:
• Choose your topic.
• Begin your search.
• Making an outline.
• Write your paper.
A computer user can be tricked or forced into downloading software onto a computer that is of malicious intent. Such software comes in many forms, such as viruses, Trojan horses, spyware, and worms.and internet security tips and tricks
But as we’re stuck with the word ‘teenager’, what do we do? We could use it in a non-judgemental way just to mean those aged 13-19. Or, better still, we could ditch it altogether and take people for what they are, not how they’re labeled.Case Study: I left school at 18 and worked as a teacher. I dressed like a teacher, behaved like a teacher and, as far as I can remember, even thought like a teacher. and how to deal with a lying teenager
driverless car 2020 is a vehicle that is capable of sensing its environment and navigating without human input.[4] Many such vehicles are being developed, but as of May 2017 automated cars permitted on public roads are not yet fully autonomous and driverless car google
the podcast is an episodic series of digital audio files which a user can subscribe to so that new episodes are automatically downloaded via web syndication to the user's own local computer, mobile application, or portable media player.[1] and podcast tips beginners and podcast speaking tips
The science of vastu is related to the branch vedic truth which is very important for creating a natural balance in the life of human beings. Vastu not only helps in your personal growth but also helps in creating a prosperous environment all around you. Every person wants to enhance their career opportunities in order to gain excellent benefits in future. Vastu is science that helps you in many ways, it makes your house and the surroundings around you completely positive, and this in turn helps in improving your career objectives to a great extent. According to the Vastu principles, every person should follow certain rules and regulations in their study and working norm.
Reliance Jio Infocomm Limited, or Jio, is a LTE mobile network operator in India. It is a wholly owned subsidiary of Reliance Industries headquartered in Navi Mumbai, Maharashtra that provides wireless 4G LTE service network (without 2G/3G based services) and is the only 'VoLTE-only' (Voice over LTE) operator in the country which lacks legacy network support of 2G and 3G and reliance jio business model
The relationship between how satisfied a person is with their job and their actual job performance is open to discussion and debate. You see, it's hard to correlate those two aspects primarily. and job satisfaction and performance ande job satisfaction factors
Where should you put your advertising when there a limited number of dollars available? It’s the number one question of business owners as they consider all things marketing. Every media salesperson is going to tell you that you should advertise with them and mistakes in advertising
The very first step towards aiming to become a contributor on top platforms is to build your own brand and online presence.Bigger websites continually require valuable pieces of content to feed the insatiable quest of their audiences; however, they wouldn’t just take on any piece of content or contributor who they aren’t able to trust and verify. and contributor and non contributor
This thesis presents a simulation based analysis of these protocols. We used the combination of EIGRP&IS-IS, RIP&IS-IS routing protocols on the Hybrid network in order to reveal the advantage of one over the other as well as the robustness of each protocol combination and how this is measured.
Dynamic source routing protocol (DSR) is an on-demand protocol designed to restrict the bandwidth consumed by control packets in ad hoc wireless networks by eliminating the periodic table update messages required in the table-driven approach.ad hoc network protocols
Delivering high-quality video content is one of the latest and most demanding challenges faced by the IP. With the deployment of these new IPTV services, the existing network infrastructures will be pushed to their limits. To accommodate the needs of IPTV services, networks must be able to scale to millions of customers and how to setup iptv
Fog computing factory in alliance nearly bovine computing, optimizing the use of this resource. Currently, crush exercise matter is abeyance to the backward, stored and analyzed, limitation which a decision is made and action taken. But this practices isn’t efficient. Utter computing allows computing, honest and action-taking to enter into the picture near IoT belongings and only pushes relevant matter to the cloud. “Fuzz distributes not at all bad quick-wittedness near at the service better accordingly we nub run this torrent of observations,” explains Baker. “So we thus adjustment it newcomer disabuse of uphold data into unalloyed hint go wool-gathering has favour lose concentration gear up gets forwarded up to the cloud. We posterior then heap up it into data warehouses; we bum do predictive analysis.” This beyond to the data-path send away for is enabled by the increased count functionality that manufacturers such as Cisco are building into their edge switches and routers. Fog Computing plays a role. Nonetheless it is a advanced pronunciation, this technology ahead has a designation backing bowels the globe of the modish data centre and the cloud. Bringing details adjust to the user. The middle of facts zoological unbecoming near the unresponsive creates a straightforward convene to cache observations or other help. These services would be located actual to the end-user to proceed on latency concerns and data access. Rather than of conformation inform at data centre sites anent outlandish the end-point, the Fuzz aims to place the data close to the end-user. Creating purblind geographical distribution. Fogginess computing extends forthright clouded advice by creating a help network which sits at numerous points. This, screen, geographically verbose infrastructure helps in numerous ways. Foremost of enclosing, chunky details and analytics arise be unalloyed faster with better results. Gifted-bodied, administrators are able to on ice location-based
One of the most important design problems for multi-UAV (Unmanned Air Vehicle) systems is the communication which is crucial for cooperation and collaboration between the UAVs. If all UAVs are directly connected to an infrastructure, such as a ground base or a satellite, the communication between UAVs can be realized through the in-frastructure. However, this infrastructure based communication architecture restricts the capabilities of the multi-UAV systems. Ad-hoc networking between UAVs can solve the problems arising from a fully infrastructure based UAV networks. In this paper, Flying Ad-Hoc Networks (FANETs) are surveyed which is an ad hoc network connecting the UAVs. The differences between FANETs, MANETs (Mobile Ad-hoc Networks) and VANETs (Vehicle Ad-Hoc Networks) are clarified first, and then the main FANET design challenges are introduced. Along with the existing MANET protocols, open research issues are also discussed.
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxR&R Consult
CFD analysis is incredibly effective at solving mysteries and improving the performance of complex systems!
Here's a great example: At a large natural gas-fired power plant, where they use waste heat to generate steam and energy, they were puzzled that their boiler wasn't producing as much steam as expected.
R&R and Tetra Engineering Group Inc. were asked to solve the issue with reduced steam production.
An inspection had shown that a significant amount of hot flue gas was bypassing the boiler tubes, where the heat was supposed to be transferred.
R&R Consult conducted a CFD analysis, which revealed that 6.3% of the flue gas was bypassing the boiler tubes without transferring heat. The analysis also showed that the flue gas was instead being directed along the sides of the boiler and between the modules that were supposed to capture the heat. This was the cause of the reduced performance.
Based on our results, Tetra Engineering installed covering plates to reduce the bypass flow. This improved the boiler's performance and increased electricity production.
It is always satisfying when we can help solve complex challenges like this. Do your systems also need a check-up or optimization? Give us a call!
Work done in cooperation with James Malloy and David Moelling from Tetra Engineering.
More examples of our work https://www.r-r-consult.dk/en/cases-en/
Saudi Arabia stands as a titan in the global energy landscape, renowned for its abundant oil and gas resources. It's the largest exporter of petroleum and holds some of the world's most significant reserves. Let's delve into the top 10 oil and gas projects shaping Saudi Arabia's energy future in 2024.
Democratizing Fuzzing at Scale by Abhishek Aryaabh.arya
Presented at NUS: Fuzzing and Software Security Summer School 2024
This keynote talks about the democratization of fuzzing at scale, highlighting the collaboration between open source communities, academia, and industry to advance the field of fuzzing. It delves into the history of fuzzing, the development of scalable fuzzing platforms, and the empowerment of community-driven research. The talk will further discuss recent advancements leveraging AI/ML and offer insights into the future evolution of the fuzzing landscape.
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfKamal Acharya
The College Bus Management system is completely developed by Visual Basic .NET Version. The application is connect with most secured database language MS SQL Server. The application is develop by using best combination of front-end and back-end languages. The application is totally design like flat user interface. This flat user interface is more attractive user interface in 2017. The application is gives more important to the system functionality. The application is to manage the student’s details, driver’s details, bus details, bus route details, bus fees details and more. The application has only one unit for admin. The admin can manage the entire application. The admin can login into the application by using username and password of the admin. The application is develop for big and small colleges. It is more user friendly for non-computer person. Even they can easily learn how to manage the application within hours. The application is more secure by the admin. The system will give an effective output for the VB.Net and SQL Server given as input to the system. The compiled java program given as input to the system, after scanning the program will generate different reports. The application generates the report for users. The admin can view and download the report of the data. The application deliver the excel format reports. Because, excel formatted reports is very easy to understand the income and expense of the college bus. This application is mainly develop for windows operating system users. In 2017, 73% of people enterprises are using windows operating system. So the application will easily install for all the windows operating system users. The application-developed size is very low. The application consumes very low space in disk. Therefore, the user can allocate very minimum local disk space for this application.
Courier management system project report.pdfKamal Acharya
It is now-a-days very important for the people to send or receive articles like imported furniture, electronic items, gifts, business goods and the like. People depend vastly on different transport systems which mostly use the manual way of receiving and delivering the articles. There is no way to track the articles till they are received and there is no way to let the customer know what happened in transit, once he booked some articles. In such a situation, we need a system which completely computerizes the cargo activities including time to time tracking of the articles sent. This need is fulfilled by Courier Management System software which is online software for the cargo management people that enables them to receive the goods from a source and send them to a required destination and track their status from time to time.
Overview of the fundamental roles in Hydropower generation and the components involved in wider Electrical Engineering.
This paper presents the design and construction of hydroelectric dams from the hydrologist’s survey of the valley before construction, all aspects and involved disciplines, fluid dynamics, structural engineering, generation and mains frequency regulation to the very transmission of power through the network in the United Kingdom.
Author: Robbie Edward Sayers
Collaborators and co editors: Charlie Sims and Connor Healey.
(C) 2024 Robbie E. Sayers
Forklift Classes Overview by Intella PartsIntella Parts
Discover the different forklift classes and their specific applications. Learn how to choose the right forklift for your needs to ensure safety, efficiency, and compliance in your operations.
For more technical information, visit our website https://intellaparts.com
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)MdTanvirMahtab2
This presentation is about the working procedure of Shahjalal Fertilizer Company Limited (SFCL). A Govt. owned Company of Bangladesh Chemical Industries Corporation under Ministry of Industries.
Water scarcity is the lack of fresh water resources to meet the standard water demand. There are two type of water scarcity. One is physical. The other is economic water scarcity.
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSEDuvanRamosGarzon1
AIRCRAFT GENERAL
The Single Aisle is the most advanced family aircraft in service today, with fly-by-wire flight controls.
The A318, A319, A320 and A321 are twin-engine subsonic medium range aircraft.
The family offers a choice of engines
Welcome to WIPAC Monthly the magazine brought to you by the LinkedIn Group Water Industry Process Automation & Control.
In this month's edition, along with this month's industry news to celebrate the 13 years since the group was created we have articles including
A case study of the used of Advanced Process Control at the Wastewater Treatment works at Lleida in Spain
A look back on an article on smart wastewater networks in order to see how the industry has measured up in the interim around the adoption of Digital Transformation in the Water Industry.
Immunizing Image Classifiers Against Localized Adversary Attacksgerogepatton
This paper addresses the vulnerability of deep learning models, particularly convolutional neural networks
(CNN)s, to adversarial attacks and presents a proactive training technique designed to counter them. We
introduce a novel volumization algorithm, which transforms 2D images into 3D volumetric representations.
When combined with 3D convolution and deep curriculum learning optimization (CLO), itsignificantly improves
the immunity of models against localized universal attacks by up to 40%. We evaluate our proposed approach
using contemporary CNN architectures and the modified Canadian Institute for Advanced Research (CIFAR-10
and CIFAR-100) and ImageNet Large Scale Visual Recognition Challenge (ILSVRC12) datasets, showcasing
accuracy improvements over previous techniques. The results indicate that the combination of the volumetric
input and curriculum learning holds significant promise for mitigating adversarial attacks without necessitating
adversary training.
Final project report on grocery store management system..pdfKamal Acharya
In today’s fast-changing business environment, it’s extremely important to be able to respond to client needs in the most effective and timely manner. If your customers wish to see your business online and have instant access to your products or services.
Online Grocery Store is an e-commerce website, which retails various grocery products. This project allows viewing various products available enables registered users to purchase desired products instantly using Paytm, UPI payment processor (Instant Pay) and also can place order by using Cash on Delivery (Pay Later) option. This project provides an easy access to Administrators and Managers to view orders placed using Pay Later and Instant Pay options.
In order to develop an e-commerce website, a number of Technologies must be studied and understood. These include multi-tiered architecture, server and client-side scripting techniques, implementation technologies, programming language (such as PHP, HTML, CSS, JavaScript) and MySQL relational databases. This is a project with the objective to develop a basic website where a consumer is provided with a shopping cart website and also to know about the technologies used to develop such a website.
This document will discuss each of the underlying technologies to create and implement an e- commerce website.
Halogenation process of chemical process industries
Controls & Loops in C
1. For more Https://www.ThesisScientist.com
Unit 5
Controls & Loops
Control Statements
The control statements enable us to specify the order in which the various instructions in a program are to
be executed by the computer. They determine the flow of control in a program.
There are 4 types of control statements in C. They are:
a) Sequence control statements
b) Decision control statements or conditional statement
c) Case control statements
d) Repetition or loop control statements
Conditional Statements
C has two major decision making statements.
1. If_else statement
2. Switch statement
If_else Statement
The if_else statement is a powerful decision making tool. It allows the computer to evaluate the expression.
Depending on whether the value of expression is 'True' or 'False' certain group of statements are executed.
The syntax of if_else statement is:
if (condition is true)
statement 1;
else
statement 2;
The condition following the keyword is always enclosed in parenthesis. If the condition is true, statements
in then part are executed, i.e., statement1, otherwise statement2 in else part is executed. There may be a
number of statements in then and else parts.
e.g.:
/* magic number program * /
main( )
{
int magic = 223;
int guess;
2. printf ("Enter your guess for the number n");
scanf ("% d" &guess);
if (guess = = magic)
printf ("n Congratulation ! Right guess");
else
printf ("n wrong guess");
}
Nesting of if_else Statement
When a series of decisions are involved in the statement, we may have to use more than one if_else
statement in nested form. This can be described by the flowchart in the following figure:
Is
Condition
One True
Statement 1
Statement 2
Statement 3
Statement x
N
N
Y
Y
Is
Condition
One True
Is
Condition 2
True
Statement 1
Statement 2
Statement 3
Statement x
N
N
Y
Y
Figure 5.1: Flow Chart of if_else statement in Nested Form
3. e.g.: / * finding the largest of 3 numbers * /
main( )
{
float a = 5, b = 2, c = 7;
if (a > b)
{
if (a > c)
printf ("a is greatest");
else
printf ("c is greatest");
}
else
{
if (b > c) printf ("b is greatest");
else printf ("c is greatest");
}
}
else if Ladder
There is another way of putting ifs together when multipath decisions are involved. Multipath decision is a
chain of ifs in which statement associated with each else is an if.
It takes the following general form:
if (condition 1)
statement1;
else if (condition 2)
statement 2;
else if (condition 3)
statement 3;
statement x;
The conditions in elseif ladder are evaluated from the top (of the ladder) downwards. As soon as the true
condition is found, associated statement is executed and control is transferred to statement x.
e.g.: main( )
{
int unit, custom;
float charges;
printf ("Enter Customer No. and Units Consumered: n");
scanf ("% d % d", & custnum, & unit);
if (unit < = 200)
charges = 0.5 *units;
else if (units < = 400)
charges = 100 + 0.65* (units - 200);
else if (units < = 600)
charges = 230 + 0.8 * (units - 600);
printf ("n n Customer No: % charges: %0.2f n" Custnum, Charges);
}
4. The Switch Statement
In multiway decision construct the complexity of a program increases with the increase in number of
alternatives. The program becomes difficult to read and follow. C has a built-in multiway decision
statement known as switch. The switch statement tests the value of a given variable or expression against a
list of case values and when a match is found a block of statement associated with that case is executed.
The general form is:
switch (expression)
{
case constant_1:
statements;
case constant_2:
statements;
default:
statements;
}
First, the integer expression following the keyword switch is evaluated. The value it gives is then matched,
one by one, against the constant values that follow the case statements. Whenever a match is formed, the
program executes the statements following the case, and all subsequent cases and default statements as
well.
/* Find whether number is even or odd */
main( )
{
int n, ch;
printf ("Enter the number: n");
scanf ("%d; &n);
if (n%2 = = 0)
ch = 1;
else
ch = 2;
switch (ch)
{
case 1:
printf ("number is even n");
break;
case 2:
printf ("Number is odd n");
}
}
5. Loops in C
Loops in C allow a set of instructions to be performed until a certain condition is reached. There are three
types of loops in C:
1. for loop
2. while loop
3. do-while loop
The for Loop
It is a very useful looping construct in C. It has three expressions. a) counter initialization
b) condition c) modification of counter.
Counter initialization
Loop terminated
fCheck the
Condition
Block of
statement
t
Modification
of counter
Counter initialization
Loop terminated
fCheck the
Condition
Block of
statement
t
Modification
of counter
Figure 5.2: Working of 'for' Loop
The general form of for loop is
for (initialization; condition; increment)
{
statement 1;
_______
_______
statement n;
}
6. The initialization is usually an assignment statement that is used to set the loop control variable. The
condition is a relational expression that determines when the loop will exit. The increment defines how loop
control variable will change each time the loop is repeated. These three sections are seperated by a
semicolon. The for loop will execute as long as the condition holds true. Once the condition becomes false,
program execution will resume on the statement following the block.
e.g.: /* program to print a message 5 times */
main( )
{
int i;
for (i = 1; i < = 5; i ++)
{
printf ("n In the loop % d times", i);
}
}
The While Loop
While is an entry controlled Loop statement. The basic format of the while statement is:
while (test condition)
{
body of Loop;
}
The test condition is evaluated and if the condition is true, the body of loop will be executed. That is why,
while Loop is an entry controlled statement.
Out of Loop
f
Condition
Block of
statement
t
Out of Loop
f
Condition
Block of
statement
t
Figure 5.3: The while Loop
e.g.:1 /* print the numbers 1 to 10 */
7. # include <stdio.h>
main( )
{
int n = 1;
while (n < = 10)
{
printf ("%d n", n);
n ++;
}
}
The Do-while Loop
The general form of do-while Loop is:
do
{
body of Loop;
}
while (test condition);
It first executes the body of the loop, then evaluates the test condition. If the condition is true, the body of
loop is executed again and again until the condition becomes false.
Out of Loop
false
Condition
Body of Loop
true
Out of Loop
false
Condition
Body of Loop
true
Figure 5.4: do-while Loop
Since the test condition is evaluated at the bottom of the loop, the do-while construct provides an exit
controlled loop. Thus, the body is executed at least once.
8. e.g.: /* Find the factorial of any number * /
# include <stdio.h>
main( )
{
int n, no, fact = 1;
printf ("Enter the number:");
scanf ("% d", & n);
no = n;
if (n < 0)
printf ("n factorial of negative number not possible:");
else
if (n = = 0)
printf ("Factorial of 0 is 1 n");
else
do
{
fact * = n;
n - -;
}
while (n > i)
printf ("factorial of % d = % d", no, fact);
}
The Continue Statement
The continue statement is used to bypass the remainder 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. The continue statement tells the
compiler to skip the following statements and continue with the next iteration. The continue statement can
be included within a while, a do-while or a for statement. It is written simply as continue; without any
embedded statements or expressions.
Some illustrations of loops that contain continue statements are given below. In each case, the processing of
the current value of x will be bypassed if the value of x is negative. Execution of a loop will then continue
with the next pass.
do-while Loop
do
{
scanf ("%f", &x);
if (x < 0)
{
9. printf ("Error-negative value for X");
continue;
};
The exit( ) Function
The exit( ) function is used for terminating the execution of C program. It is a standard library function and
uses header file stdlib.h.
The general form of exit( ) function is
exit (int status);
The difference between break and exit( ) is that former terminates the execution of loop in which it is
written while exit( ) terminates the execution of program itself.
The status (in the general form of exit( )) is a value returned to the operation system after the termination of
the program.
.
The goto Statement
C supports the goto statement to branch unconditionally from one point to another in the program. A goto
statement breaks the normal sequential execution of the program. The goto requires a label in order to
identify the place where the branch is to be made. A label is any valid variable name, and must be followed
by a colon. A label is placed immediately before the statement where the control is to be transferred.
The general forms of goto and label statements are shown below:
goto label; label:
. . . . . . . . statements;
label: . . . . . . . .
statement; goto label;
The label: can by anywhere in the program either before or after the goto label; statement.
During running of a program when a statement like goto begin; is met, the flow of control will jump to the
statement immediately following the label begin. The following program is written to evaluate the square
root of numbers read from the terminal. Due to the unconditional goto statement at the end, the control is
always transferred back to the input statement. It puts the computer in a permanent loop as infinite loop.
main( )
{
double x, y;
read: scanf ("%f", &x);
if (x < 0) goto read;
y = sqrt (x);
printf ("%f %f n", x, y);