The document discusses various Python flow control statements including if/else, for loops, while loops, break and continue. It provides examples of using if/else statements for decision making and checking conditions. It also demonstrates how to use for and while loops for iteration, including using the range function. It explains how break and continue can be used to terminate or skip iterations. Finally, it briefly mentions pass, for, while loops with else blocks, and nested loops.
This document provides an overview of the C programming language, including:
- Why software is needed for embedded systems and choosing an appropriate programming language
- Key features of C like being easier/faster to develop with, portability, and efficient pointer usage
- Differences between embedded C and desktop C like writing low-level and inline assembly code
- The structure of a basic C program and a "Hello, World!" example
- C programming basics like constants, variables, data types, and arithmetic, relational, logical, and bitwise operators
- Control flow statements in C like if, if/else, and switch
This document summarizes the basic types in C including integer types, floating types, and character types. It discusses integer types like short, int, long, and their signed and unsigned variants. It also covers floating point types float, double, long double. Character types are discussed along with escape sequences and character operations. Integer constants, floating constants, and the sizeof operator are also summarized.
Programming involves instructing a computer using a programming language. It allows organizing ideas about processes and things. Programming languages let programmers develop applications and scripts for computers to execute. Programming involves understanding codes, program development, and applications like web browsers. Switch cases and looping systems are important programming concepts. Switch cases allow selecting different code blocks based on a variable. Common looping structures include for, while, do-while, and foreach loops, which repeat a block of code a specified number of times. Programming requires attention to syntax and careful coding to avoid errors.
This document discusses various loop constructs in C programming including while, do-while, for, and exiting loops. It covers:
- The while loop evaluates its controlling expression first before executing the loop body.
- The do-while loop evaluates its controlling expression after executing the loop body, so the body is always executed at least once.
- The for loop is ideal for loops with a counting variable, allowing initialization, a controlling expression, and an increment/decrement expression to be specified.
- break exits the entire loop, continue skips to the next iteration, and goto allows jumping to any statement but is rarely needed and can harm readability.
Control structures functions and modules in python programmingSrinivas Narasegouda
The document discusses control structures, functions, modules, and Python's standard library. It covers topics like conditional branching, looping, functions, modules, packages, exceptions, strings, and more. Custom functions in Python include global functions, local functions, lambda functions, and methods. Modules allow packaging functionality and importing it into other code.
The document discusses various Python flow control statements including if/else, for loops, while loops, break and continue. It provides examples of using if/else statements for decision making and checking conditions. It also demonstrates how to use for and while loops for iteration, including using the range function. It explains how break and continue can be used to terminate or skip iterations. Finally, it briefly mentions pass, for, while loops with else blocks, and nested loops.
This document provides an overview of the C programming language, including:
- Why software is needed for embedded systems and choosing an appropriate programming language
- Key features of C like being easier/faster to develop with, portability, and efficient pointer usage
- Differences between embedded C and desktop C like writing low-level and inline assembly code
- The structure of a basic C program and a "Hello, World!" example
- C programming basics like constants, variables, data types, and arithmetic, relational, logical, and bitwise operators
- Control flow statements in C like if, if/else, and switch
This document summarizes the basic types in C including integer types, floating types, and character types. It discusses integer types like short, int, long, and their signed and unsigned variants. It also covers floating point types float, double, long double. Character types are discussed along with escape sequences and character operations. Integer constants, floating constants, and the sizeof operator are also summarized.
Programming involves instructing a computer using a programming language. It allows organizing ideas about processes and things. Programming languages let programmers develop applications and scripts for computers to execute. Programming involves understanding codes, program development, and applications like web browsers. Switch cases and looping systems are important programming concepts. Switch cases allow selecting different code blocks based on a variable. Common looping structures include for, while, do-while, and foreach loops, which repeat a block of code a specified number of times. Programming requires attention to syntax and careful coding to avoid errors.
This document discusses various loop constructs in C programming including while, do-while, for, and exiting loops. It covers:
- The while loop evaluates its controlling expression first before executing the loop body.
- The do-while loop evaluates its controlling expression after executing the loop body, so the body is always executed at least once.
- The for loop is ideal for loops with a counting variable, allowing initialization, a controlling expression, and an increment/decrement expression to be specified.
- break exits the entire loop, continue skips to the next iteration, and goto allows jumping to any statement but is rarely needed and can harm readability.
Control structures functions and modules in python programmingSrinivas Narasegouda
The document discusses control structures, functions, modules, and Python's standard library. It covers topics like conditional branching, looping, functions, modules, packages, exceptions, strings, and more. Custom functions in Python include global functions, local functions, lambda functions, and methods. Modules allow packaging functionality and importing it into other code.
1) The document provides an introduction to programming with the maXbox tool. It explains the interface and how to load sample code.
2) The sample code checks if numbers are prime by using a function called checkPrim() within a procedure called TestPrimNumbers(). It saves the results to a file.
3) The main routine calls TestPrimNumbers(), saves the output list to a file, loads the file, and displays the results along with performance times. This demonstrates functions, procedures, file I/O, and other basic programming concepts.
Learn C# Programming - Decision Making & LoopsEng Teong Cheah
The document provides an overview of decision making structures and loops in C#. It discusses if, if-else, if-else if-else statements, switch statements, and how to nest conditional logic. It also covers while, for, do-while loops, nested loops, and loop control statements like break and continue. Examples are provided for each structure to demonstrate their syntax and usage.
This document discusses switch-case statements in C programming. It explains that switch-case statements provide a way to implement decision making when a variable is tested for multiple possible integral values. Each case represents a different action. The document provides the syntax of switch-case statements and explains that all code within a matched case will execute until a break statement. It includes an example program that uses a switch-case statement to output a message based on a letter grade input.
There are three main types of control structures in computer programming: sequential logic, selection logic, and iteration logic. Sequential logic executes code line-by-line. Selection logic (e.g. if/else statements) allows executing code conditionally. Iteration logic (e.g. for loops) repeats code execution in loops. The document provides examples of if/else, nested if, switch statements, and the conditional operator for implementing various control structures in C programming.
Bt0067 c programming and data structures 1Techglyphs
The document discusses various statements in the C programming language. It defines statement types such as selection/conditional statements (if-else, switch), iteration statements (for, while, do-while), jump statements (break, continue, goto, return), and label statements. It provides examples and explanations of each statement type, including nested if/else statements, the for loop variant forms, and when to use while, do-while, switch, and other statements. It also covers macros and functions in C with definitions and examples.
Types of Statements in Python Programming LanguageExplore Skilled
The slide describes the types of flow control statements in Python including conditional statement , loop statement , control statement such as break and continue .
This document discusses conditional statements and switch statements in C#. It explains the syntax and usage of if, else, else if, and ternary conditional statements. It also covers the syntax and purpose of switch statements, including the break and default keywords. Code examples are provided to demonstrate how to use if/else, else if, ternary operators, and switch statements to conditionally execute blocks of code based on simple logic checks and comparisons of variables.
C++ variables can hold different data types like numbers and characters. Variables must be declared with a name and type before use and can be assigned values. Keywords like int and double are used to declare variable types for whole numbers and decimals. Variables are output using cout and input using cin. User input and output allows the program to display prompts and receive user-entered values.
The document discusses C expressions and operators. It covers:
1. Expressions can range from simple variables and constants to more complex expressions using operators. Operators allow building expressions and include arithmetic, relational, and logical operators.
2. Arithmetic operators include unary operators like + and - as well as binary operators like +, -, *, /, and % for addition, subtraction, multiplication, division, and remainder. Compound operators like += modify variables.
3. Increment/decrement operators ++ and -- can be used as prefix or postfix and have side effects of modifying the operand. Their order of evaluation can impact expression values.
This document outlines Chapter 4 of a textbook on control structures in programming. It introduces algorithms and pseudocode, then covers various control structures like sequence, selection, and repetition structures. It discusses if, if/else, and while statements in Java. It includes examples of algorithms to calculate class averages using counter-controlled and sentinel-controlled repetition. It also covers topics like compound assignment operators, increment/decrement operators, and nested control structures.
This chapter discusses control structures in Java programs. It covers relational operators and logical expressions used for comparisons. Selection control structures like if, if-else, and switch statements are examined along with examples. The chapter also provides an example programming problem on cable company billing that demonstrates using control structures and nested conditional logic.
Loops allow blocks of code to be repeatedly executed. The three types of loops in C are while loops, for loops, and do-while loops. While loops check the condition before each iteration. For loops allow initialization, condition checking, and increment/decrement in the loop header. Do-while loops check the condition after executing the block at least once. Break and continue statements can be used to exit or skip portions of loops. Switch statements compare a value to multiple case values and execute the corresponding block.
Credits-
Dr. C.-K. Shene
Professor
Department of Computer Science
Michigan Technological University
This presentation was downloaded from this link- http://www.cs.mtu.edu/~shene/COURSES/cs201/NOTES/F90-Basics.pdf
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
The document discusses different types of loops and conditional statements in programming languages. It explains the if, if-else, and switch conditional statements, providing examples of each. It also covers different types of loops - while, do-while, for, and nested loops. Examples are given to illustrate the syntax and usage of each loop and conditional statement.
Java is a computer programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few implementation dependencies as possible.
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
This document provides an introduction to the C programming language. It covers C program structure, variables, expressions, operators, input/output, loops, decision making statements, arrays, strings, functions, pointers, structures, unions, file input/output and dynamic memory allocation. The document uses examples and explanations to introduce basic C syntax and concepts.
This document discusses how different C data types are stored in memory. It describes the basic integer and floating point types, including their storage sizes and value ranges. It also covers void, enumerated, pointer, array, structure, and union types. For integers, it provides the memory representations of char, both signed and unsigned. It explains the memory layout of a C program, including the text, data, stack, and heap segments. Finally, it briefly discusses big and little endian formats for multibyte data storage.
1) The document provides an introduction to programming with the maXbox tool. It explains the interface and how to load sample code.
2) The sample code checks if numbers are prime by using a function called checkPrim() within a procedure called TestPrimNumbers(). It saves the results to a file.
3) The main routine calls TestPrimNumbers(), saves the output list to a file, loads the file, and displays the results along with performance times. This demonstrates functions, procedures, file I/O, and other basic programming concepts.
Learn C# Programming - Decision Making & LoopsEng Teong Cheah
The document provides an overview of decision making structures and loops in C#. It discusses if, if-else, if-else if-else statements, switch statements, and how to nest conditional logic. It also covers while, for, do-while loops, nested loops, and loop control statements like break and continue. Examples are provided for each structure to demonstrate their syntax and usage.
This document discusses switch-case statements in C programming. It explains that switch-case statements provide a way to implement decision making when a variable is tested for multiple possible integral values. Each case represents a different action. The document provides the syntax of switch-case statements and explains that all code within a matched case will execute until a break statement. It includes an example program that uses a switch-case statement to output a message based on a letter grade input.
There are three main types of control structures in computer programming: sequential logic, selection logic, and iteration logic. Sequential logic executes code line-by-line. Selection logic (e.g. if/else statements) allows executing code conditionally. Iteration logic (e.g. for loops) repeats code execution in loops. The document provides examples of if/else, nested if, switch statements, and the conditional operator for implementing various control structures in C programming.
Bt0067 c programming and data structures 1Techglyphs
The document discusses various statements in the C programming language. It defines statement types such as selection/conditional statements (if-else, switch), iteration statements (for, while, do-while), jump statements (break, continue, goto, return), and label statements. It provides examples and explanations of each statement type, including nested if/else statements, the for loop variant forms, and when to use while, do-while, switch, and other statements. It also covers macros and functions in C with definitions and examples.
Types of Statements in Python Programming LanguageExplore Skilled
The slide describes the types of flow control statements in Python including conditional statement , loop statement , control statement such as break and continue .
This document discusses conditional statements and switch statements in C#. It explains the syntax and usage of if, else, else if, and ternary conditional statements. It also covers the syntax and purpose of switch statements, including the break and default keywords. Code examples are provided to demonstrate how to use if/else, else if, ternary operators, and switch statements to conditionally execute blocks of code based on simple logic checks and comparisons of variables.
C++ variables can hold different data types like numbers and characters. Variables must be declared with a name and type before use and can be assigned values. Keywords like int and double are used to declare variable types for whole numbers and decimals. Variables are output using cout and input using cin. User input and output allows the program to display prompts and receive user-entered values.
The document discusses C expressions and operators. It covers:
1. Expressions can range from simple variables and constants to more complex expressions using operators. Operators allow building expressions and include arithmetic, relational, and logical operators.
2. Arithmetic operators include unary operators like + and - as well as binary operators like +, -, *, /, and % for addition, subtraction, multiplication, division, and remainder. Compound operators like += modify variables.
3. Increment/decrement operators ++ and -- can be used as prefix or postfix and have side effects of modifying the operand. Their order of evaluation can impact expression values.
This document outlines Chapter 4 of a textbook on control structures in programming. It introduces algorithms and pseudocode, then covers various control structures like sequence, selection, and repetition structures. It discusses if, if/else, and while statements in Java. It includes examples of algorithms to calculate class averages using counter-controlled and sentinel-controlled repetition. It also covers topics like compound assignment operators, increment/decrement operators, and nested control structures.
This chapter discusses control structures in Java programs. It covers relational operators and logical expressions used for comparisons. Selection control structures like if, if-else, and switch statements are examined along with examples. The chapter also provides an example programming problem on cable company billing that demonstrates using control structures and nested conditional logic.
Loops allow blocks of code to be repeatedly executed. The three types of loops in C are while loops, for loops, and do-while loops. While loops check the condition before each iteration. For loops allow initialization, condition checking, and increment/decrement in the loop header. Do-while loops check the condition after executing the block at least once. Break and continue statements can be used to exit or skip portions of loops. Switch statements compare a value to multiple case values and execute the corresponding block.
Credits-
Dr. C.-K. Shene
Professor
Department of Computer Science
Michigan Technological University
This presentation was downloaded from this link- http://www.cs.mtu.edu/~shene/COURSES/cs201/NOTES/F90-Basics.pdf
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
The document discusses different types of loops and conditional statements in programming languages. It explains the if, if-else, and switch conditional statements, providing examples of each. It also covers different types of loops - while, do-while, for, and nested loops. Examples are given to illustrate the syntax and usage of each loop and conditional statement.
Java is a computer programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few implementation dependencies as possible.
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
This document provides an introduction to the C programming language. It covers C program structure, variables, expressions, operators, input/output, loops, decision making statements, arrays, strings, functions, pointers, structures, unions, file input/output and dynamic memory allocation. The document uses examples and explanations to introduce basic C syntax and concepts.
This document discusses how different C data types are stored in memory. It describes the basic integer and floating point types, including their storage sizes and value ranges. It also covers void, enumerated, pointer, array, structure, and union types. For integers, it provides the memory representations of char, both signed and unsigned. It explains the memory layout of a C program, including the text, data, stack, and heap segments. Finally, it briefly discusses big and little endian formats for multibyte data storage.
This document provides an introduction and overview of mechanics of materials. It defines key terms like stress, strain, normal stress, shear stress, factor of safety, and allowable stress. It also gives examples of calculating stresses in structural members subjected to various loads. The document is an introductory reading for a mechanics of materials course that will analyze the relationship between external forces and internal stresses and strains in structural elements.
All solutions appear to converge to the equilibrium solution C > œ !. For some differential equations, all solutions diverge from the equilibrium solution. The direction field and slopes of the solutions help determine whether solutions converge or diverge. Initial conditions determine whether a solution increases or decreases over time.
This document discusses solutions to higher order differential equations with constant coefficients. It begins by introducing homogeneous linear equations of order two or higher of the form y'' + ay' + by + c = 0. It then presents the method of solving such equations by finding the roots of the characteristic or auxiliary equation. Depending on whether the roots are real/distinct, real/equal, or complex conjugates, the general solution will take different forms involving exponential or trigonometric functions. Several examples are worked through. The document also discusses solving higher order differential equations and presents solutions to sample third and fourth order equations.
This document discusses storage classes in the C programming language. It begins with an introduction to the C language and its history. The main body of the document then covers the four primary storage classes in C - automatic, register, static, and external. For each class, it provides details on storage location, default initial value, scope, and lifetime. Examples are provided to illustrate the behavior and usage of variables for each storage class. The key differences between the four classes are summarized in a table at the end.
I am working as a Assistant Professor in ITS, Ghaziabad.This is very useful to U.P.Technical University,Uttrakhand Technical University students. Give feedback to rakeshroshan@its.edu.in
This document gives the class notes of Unit 2 stresses in composite sections. Subject: Mechanics of materials.
Syllabus contest is as per VTU, Belagavi, India.
Notes Compiled By: Hareesha N Gowda, Assistant Professor, DSCE, Bengaluru-78.
This document provides an overview of Chapter 2 from the textbook "Mechanics of Materials" which covers stress and strain under axial loading. The chapter discusses key topics like normal strain, stress-strain diagrams for ductile and brittle materials, Hooke's law, elastic vs plastic behavior, fatigue, deformations under axial loading, static indeterminacy, thermal stresses, and Poisson's ratio. It also includes sample problems and examples to demonstrate calculating deformations and reactions for axially loaded members.
3 torsion- Mechanics of Materials - 4th - BeerNhan Tran
This document provides an overview of chapter 3 from the textbook "Mechanics of Materials" which covers the topic of torsion. It begins with an introduction to torsional loads on circular shafts and the concept of net torque due to internal stresses. Key concepts discussed include shear strain, stresses in the elastic range using elastic torsion formulas, and failure modes under torsion. The document provides examples of solving sample problems involving statically indeterminate shafts, determining required shaft diameters, and calculating stresses and angles of twist. It concludes with discussing plastic deformations and torsion of noncircular members.
1) Ordinary differential equations relate a dependent variable to one or more independent variables by means of differential coefficients. They can be classified based on order, degree, whether they are linear or non-linear, and type (exact, separable variables, homogeneous).
2) First order differential equations can sometimes be solved by separation of variables, or by finding an integrating factor. Homogeneous equations can be transformed by substitution.
3) Second order linear differential equations can be reduced to a system of two first order equations. The complementary function and particular solutions combine to form the general solution. Unequal or equal roots of the characteristic equation determine the form of the complementary function.
This document discusses various methods for solving first order differential equations, including:
1. Variable separable methods where the equation can be written as a function of x multiplied by a function of y.
2. Homogeneous equations where both sides are homogeneous functions of the same degree.
3. Exact equations where there exists an integrating factor.
4. Equations that can be transformed to an exact or separable form through substitution.
5. Linear equations that can be solved using an integrating factor that is a function of x.
Mechanics of materials lecture 01, Engr. Abdullah KhanAbdullah Khan
This document provides information about a Mechanics of Materials course, including:
- The instructor's contact information and the course grading criteria.
- An outline of the course content which will cover topics like stresses, strains, bending of beams, torsion, and failure theories.
- Recommended study sources and learning objectives/outcomes which aim to equip students to analyze and design agricultural machinery and structures.
- An introduction to mechanics of materials and definitions of important material properties like strength, hardness, ductility, and elasticity that engineers must understand when designing with different materials.
The document discusses higher order differential equations. It defines nth order differential equations and describes their general forms. For homogeneous equations, the general solution method involves making an operator form, constructing an auxiliary equation, solving for roots, and finding the complementary solution. For non-homogeneous equations, the method of undetermined coefficients is used to find a particular solution and the general solution is the sum of the complementary and particular solutions. Examples are provided to illustrate the solution methods.
The document discusses various conditional control statements in C language including if, if-else, nested if, if-else-if, switch case statements. It provides the syntax and examples for each statement. Key conditional control statements covered are:
1) if statement - Executes code if a condition is true.
2) if-else statement - Executes one block of code if condition is true and another if false.
3) Nested if statements - if statements within other if statements allow multiple conditions to be checked.
4) if-else-if statement - Allows multiple alternative blocks to be executed depending on different conditions.
5) switch case statement - Allows efficient selection from multiple discrete choices
The document discusses different types of control statements in C programming including decision control statements, iteration statements, and transfer statements. It provides details about if, if-else, switch, while, do-while, for loops. Decision control statements like if, if-else, switch allow altering the flow of execution based on certain conditions. Iteration statements like while, do-while, for are used to repeat a block of code until the given condition is true. They allow looping in a program.
The document discusses various control flow statements in C# including conditional statements like if-else and switch statements. It explains the syntax and usage of if-else, else if, logical and relational operators, switch statement, nested if statements, short-circuit evaluation, and the dangling else problem. It also introduces repetition statements like while to repeatedly execute a block of code as long as a condition is true.
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
The document discusses various control flow statements in C programming such as decision control statements (if, if-else, switch-case), looping statements (for, while, do-while loops), break, continue, goto, and functions. It provides examples of using each statement type and explains their syntax and usage. Key aspects like scope of variables, parameter passing methods (call by value, call by reference), and storage classes (auto, static, extern) related to functions are also covered in the document.
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.
Dti2143 chap 4 control structures aka_selectionalish sha
Control structures determine the order of execution of statements in a program. There are three main types: sequential, selectional, and iterative. Selectional structures include if and switch statements. If statements allow for conditional execution of code based on boolean expressions. Switch statements select execution based on a variable's value and allow for multiple case blocks. Nested if statements involve if blocks within other if blocks.
Dti2143 chap 4 control structures aka_selectionalish sha
Control structures determine the order of execution of statements in a program. There are three main types: sequential, selectional, and iterational. Selectional structures include if/else statements and switch cases, which allow different code blocks to execute based on conditions. Iterational structures like while, do-while, and for loops repeat a block of code a specified number of times. Nested control structures can embed one type within another. Proper use of conditions and logical operators is important for control flows to work as intended.
This document contains information about programming languages and examples of programs written in C programming language. It discusses different programming concepts like variables, loops, switch statements, and provides 5 examples of programs using these concepts. The programs demonstrate how to print outputs based on user input or calculations using switch statements, loops, and variables. The document is meant to be submitted to Prof. Erwin M. Globio and provides resources to learn programming at http://eglobiotraining.com.
Fundamental of Information Technology - UNIT 8Shipra Swati
This document discusses different types of control structures in C programming including sequence control, selection/decision control, case control, and repetition/loop control. It provides examples of if, if-else, switch, for, and while loops. The if statement and if-else statement are used for decision making and branching based on a condition being true or false. Switch statements provide an alternative for nested if-else statements. Loops like for and while are used to repeat a block of code until a condition is met. Examples are given to calculate the sum of natural numbers using for and while loops.
This document provides an overview of key concepts in C programming including identifiers, keywords, data types, operators, control statements, and functions for controlling program flow. It discusses identifiers and keywords rules. It also covers basic data types and different operators used in C. The document explains various control statements like if-else, switch case, for, while, do-while loops. It provides examples of using conditional operators and break and continue statements. Finally, it discusses nested loops and references additional resources to learn C programming.
This document provides an overview of key concepts in C programming including identifiers, keywords, data types, operators, control statements, and functions for controlling program flow. It discusses identifiers and keywords rules. It also covers basic data types and different operators used in C. The document explains various control statements like if-else, switch case, for, while, do-while loops. It provides examples of using conditional operators and break and continue statements. Finally, it discusses nested loops and references additional resources to learn C programming.
C statements.ppt presentation in c languagechintupro9
The document defines different types of programming statements and control structures used in C programming. It discusses program, statements, compound statements, decision control structures like if, if-else, nested if-else, else-if ladder, switch statement. It also covers different loop constructs - while, do-while and for loops. Additionally, it provides examples to explain break and continue statements used inside loops.
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)
The document discusses different types of selection statements in C including if, if-else, and switch statements. Relational expressions are used to create conditions for if statements and can be combined using logical operators. An if statement executes a statement if a condition is true, while an if-else statement chooses between two statements depending on the condition. Nested if-else statements and switch statements provide multiway selection. Common errors include misusing assignment versus relational operators and failing to use braces with nested if statements.
computer programming Control Statements.pptxeaglesniper008
The document summarizes control statements in the C programming language. It discusses decision statements like if and switch statements. It also covers loop statements like for, do-while and while loops. The for loop is described as the most common loop in C. Examples are provided to illustrate if, switch and for statements. Key points covered include the syntax and flow of if-else, switch-case statements and for loops.
Walmart Business+ and Spark Good for Nonprofits.pdfTechSoup
"Learn about all the ways Walmart supports nonprofit organizations.
You will hear from Liz Willett, the Head of Nonprofits, and hear about what Walmart is doing to help nonprofits, including Walmart Business and Spark Good. Walmart Business+ is a new offer for nonprofits that offers discounts and also streamlines nonprofits order and expense tracking, saving time and money.
The webinar may also give some examples on how nonprofits can best leverage Walmart Business+.
The event will cover the following::
Walmart Business + (https://business.walmart.com/plus) is a new shopping experience for nonprofits, schools, and local business customers that connects an exclusive online shopping experience to stores. Benefits include free delivery and shipping, a 'Spend Analytics” feature, special discounts, deals and tax-exempt shopping.
Special TechSoup offer for a free 180 days membership, and up to $150 in discounts on eligible orders.
Spark Good (walmart.com/sparkgood) is a charitable platform that enables nonprofits to receive donations directly from customers and associates.
Answers about how you can do more with Walmart!"
A Visual Guide to 1 Samuel | A Tale of Two HeartsSteve Thomason
These slides walk through the story of 1 Samuel. Samuel is the last judge of Israel. The people reject God and want a king. Saul is anointed as the first king, but he is not a good king. David, the shepherd boy is anointed and Saul is envious of him. David shows honor while Saul continues to self destruct.
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumMJDuyan
(𝐓𝐋𝐄 𝟏𝟎𝟎) (𝐋𝐞𝐬𝐬𝐨𝐧 𝟏)-𝐏𝐫𝐞𝐥𝐢𝐦𝐬
𝐃𝐢𝐬𝐜𝐮𝐬𝐬 𝐭𝐡𝐞 𝐄𝐏𝐏 𝐂𝐮𝐫𝐫𝐢𝐜𝐮𝐥𝐮𝐦 𝐢𝐧 𝐭𝐡𝐞 𝐏𝐡𝐢𝐥𝐢𝐩𝐩𝐢𝐧𝐞𝐬:
- Understand the goals and objectives of the Edukasyong Pantahanan at Pangkabuhayan (EPP) curriculum, recognizing its importance in fostering practical life skills and values among students. Students will also be able to identify the key components and subjects covered, such as agriculture, home economics, industrial arts, and information and communication technology.
𝐄𝐱𝐩𝐥𝐚𝐢𝐧 𝐭𝐡𝐞 𝐍𝐚𝐭𝐮𝐫𝐞 𝐚𝐧𝐝 𝐒𝐜𝐨𝐩𝐞 𝐨𝐟 𝐚𝐧 𝐄𝐧𝐭𝐫𝐞𝐩𝐫𝐞𝐧𝐞𝐮𝐫:
-Define entrepreneurship, distinguishing it from general business activities by emphasizing its focus on innovation, risk-taking, and value creation. Students will describe the characteristics and traits of successful entrepreneurs, including their roles and responsibilities, and discuss the broader economic and social impacts of entrepreneurial activities on both local and global scales.
How to Setup Warehouse & Location in Odoo 17 InventoryCeline George
In this slide, we'll explore how to set up warehouses and locations in Odoo 17 Inventory. This will help us manage our stock effectively, track inventory levels, and streamline warehouse operations.
Temple of Asclepius in Thrace. Excavation resultsKrassimira Luka
The temple and the sanctuary around were dedicated to Asklepios Zmidrenus. This name has been known since 1875 when an inscription dedicated to him was discovered in Rome. The inscription is dated in 227 AD and was left by soldiers originating from the city of Philippopolis (modern Plovdiv).
Gender and Mental Health - Counselling and Family Therapy Applications and In...PsychoTech Services
A proprietary approach developed by bringing together the best of learning theories from Psychology, design principles from the world of visualization, and pedagogical methods from over a decade of training experience, that enables you to: Learn better, faster!
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxEduSkills OECD
Iván Bornacelly, Policy Analyst at the OECD Centre for Skills, OECD, presents at the webinar 'Tackling job market gaps with a skills-first approach' on 12 June 2024
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...PECB
Denis is a dynamic and results-driven Chief Information Officer (CIO) with a distinguished career spanning information systems analysis and technical project management. With a proven track record of spearheading the design and delivery of cutting-edge Information Management solutions, he has consistently elevated business operations, streamlined reporting functions, and maximized process efficiency.
Certified as an ISO/IEC 27001: Information Security Management Systems (ISMS) Lead Implementer, Data Protection Officer, and Cyber Risks Analyst, Denis brings a heightened focus on data security, privacy, and cyber resilience to every endeavor.
His expertise extends across a diverse spectrum of reporting, database, and web development applications, underpinned by an exceptional grasp of data storage and virtualization technologies. His proficiency in application testing, database administration, and data cleansing ensures seamless execution of complex projects.
What sets Denis apart is his comprehensive understanding of Business and Systems Analysis technologies, honed through involvement in all phases of the Software Development Lifecycle (SDLC). From meticulous requirements gathering to precise analysis, innovative design, rigorous development, thorough testing, and successful implementation, he has consistently delivered exceptional results.
Throughout his career, he has taken on multifaceted roles, from leading technical project management teams to owning solutions that drive operational excellence. His conscientious and proactive approach is unwavering, whether he is working independently or collaboratively within a team. His ability to connect with colleagues on a personal level underscores his commitment to fostering a harmonious and productive workplace environment.
Date: May 29, 2024
Tags: Information Security, ISO/IEC 27001, ISO/IEC 42001, Artificial Intelligence, GDPR
-------------------------------------------------------------------------------
Find out more about ISO training and certification services
Training: ISO/IEC 27001 Information Security Management System - EN | PECB
ISO/IEC 42001 Artificial Intelligence Management System - EN | PECB
General Data Protection Regulation (GDPR) - Training Courses - EN | PECB
Webinars: https://pecb.com/webinars
Article: https://pecb.com/article
-------------------------------------------------------------------------------
For more information about PECB:
Website: https://pecb.com/
LinkedIn: https://www.linkedin.com/company/pecb/
Facebook: https://www.facebook.com/PECBInternational/
Slideshare: http://www.slideshare.net/PECBCERTIFICATION
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
C language UPTU Unit3 Slides
1. UNIT 3 Conditional Program Execution: Applying if and switch statements, nesting if and else, restrictions on switch values, use of break and default with switch, Program Loops and Iteration: Uses of while, do and for loops, multiple loop variables, assignment operators, using break and continue, Modular Programming: Passing arguments by value, scope rules and global variables, separate compilation, and linkage, building your own modules.
2. The C language programs presented until now follows a sequential form of execution of statements. Many times it is required to alter the flow of the sequence of instructions. C language provides statements that can alter the flow of a sequence of instructions. These statements are called control statements. These statements help to jump from one part of the program to another. The control transfer may be conditional or unconditional. Conditional Program Execution
3. if Statement The simplest form of the control statement is the If statement. It is very frequently used in decision making and allowing the flow of program execution. The If structure has the following syntax if (condition) statement;
4. Example program # include <stdio.h> void main () { int numbers; printf ("Type a number:"); scanf ("%d", &number); if (number < 0) number = -number printf ("The absolute value is %d ", number) } Output: Type a number: -5 The absolute value is 5 The above program checks the value of the input number to see if it is less than zero. If it is then the following program statement which negates the value of the number is executed. If the value of the number is not less than zero, we do not want to negate it then this statement is automatically skipped. The absolute number is then displayed by the program, and program execution ends.
5. The If else construct: The syntax of the If else construct is as follows:- If(condition) { Statement1; } else { Statement2; } The if else is actually just on extension of the general format of if statement. If the result of the condition is true, then program statement 1 is executed, otherwise program statement 2 will be executed. If any case either program statement 1 is executed or program statement 2 is executed but not both when writing programs this else statement is so frequently required that almost all programming languages provide a special construct to handle this situation.
6. Example Program #include <stdio.h> void main () { int num; printf ("Enter the number"); scanf ("%d", &num); if (num < 0) printf ("The number is negative"); else printf ("The number is positive"); } Output: Enter the number: 10 The number is positive
7. The syntax in the statement ‘a’ represents a complex if statement which combines different conditions using the AND operator in this case if all the conditions are true only then the whole statement is considered to be true. Even if one condition is false the whole if statement is considered to be false. The statement ‘b’ uses the logical operator OR (||) to group different expression to be checked. In this case if any one of the expression if found to be true the whole expression considered to be true, we can also uses the mixed expressions using logical operators AND and OR together. Compound Relational tests: Syntax: a> if (condition1 && condition2 && condition3) b> if (condition1 || condition2 || condition3)
8. Nested if Statement The if statement may itself contain another if statement is known as nested if statement. Syntax: The if statement may be nested as deeply as you need to nest it. One block of code will only be executed if two conditions are true. Condition 1 is tested first and then condition 2 is tested. The second if condition is nested in the first. The second if condition is tested only when the first condition is true else the program flow will skip to the corresponding else statement. if (condition1) if (condition2) statement-1; else statement-2; else statement-3;
9. Example Program #include <stdio.h> main () { int a,b,c,big; printf("Enter three numbers:"); scanf("%d %d %d", &a, &b, &c); if (a > b) { if (a > c) big = a; else big = c; } else { if (b > c) big = b; else big = c; } printf("Largest of %d, %d & %d = %d", a,b,c,big); } In the above program the statement if (a>c) is nested within the if (a>b). If the first If condition if (a>b) If (a>b) is true only then the second if statement if (a>b) is executed. If the first if condition is executed to be false then the program control shifts to the statement after corresponding else statement.
10. The ELSE If Ladder When a series of many conditions have to be checked we may use the ladder else if statement which takes the following general form. This construct is known as if else construct or ladder. The conditions are evaluated from the top of the ladder to downwards. As soon on the true condition is found, the statement associated with it is executed and the control is transferred to the statement – x (skipping the rest of the ladder. When all the condition becomes false, the final else containing the default statement will be executed. if (condition1) statement – 1; else if (condition2) statement2; else if (condition3) statement3; else if (condition) statement n; else default statement; statement-x;
11. Example program #include <stdio.h> void main () { int marks; printf ("Enter marks"); scanf ("%d", &marks); if (marks <= 100 && marks >= 70) printf (" Distinction") ; else if (marks >= 60) printf(" First class"); else if (marks >= 50) printf (" second class"); else if (marks >= 35) printf (" pass class"); else printf ("Fail") ; } Marks Grade 70 to 100 60 to 69 50 to 59 40 to 49 0 to 39 DISTINCTION Ist Class Iind Class CLASS FAIL
12. The Switch Statement: Unlike the If statement which allows a selection of two alternatives, the switch statement allows a program to select one statement for execution out of a set of alternatives. During the execution of the switch statement only one of the possible statements will be executed the remaining statements will be skipped. The usage of multiple If else statement increases the complexity of the program since when the number of If else statements increase it affects the readability of the program and makes it difficult to follow the program. The switch statement removes these disadvantages by using a simple and straight forward approach. The general format of the Switch Statement is : When the switch statement is executed the control expression is evaluated first and the value is compared with the case label values in the given order. If the label matches with the value of the expression then the control is transferred directly to the group of statements which follow the label. If none of the statements matches then the statement against the default is executed. The default statement is optional in switch statement in case if any default statement is not given and if none of the condition matches then no action takes place in this case the control transfers to the next statement of the if else statement. switch (expression) { case case1; case case2; case casen; ……………… case default }
13. Example Program #include <stdio.h> void main () { int num1, num2, result; char operator; printf ("Enter two numbers"); scanf ("%d %d", &num1, &num2) ; printf ("Enter an operator") ; scanf ("%c", &operator); switch (operator) { case '+': result = num1 + num2; break; case '-': result = num1 - num2; break; case '*': result = num1 * num2; break; case '/': if (num2 != 0) result = num1 / num2; else { printf ("warning : division by zero "); result = 0; } break; default: printf (" unknown operator"); result = 0; break; } printf ("%d", result); }
14. The GOTO statement: The goto statement is simple statement used to transfer the program control unconditionally from one statement to another statement. Although it might not be essential to use the goto statement in a highly structured language like C, there may be occasions when the use of goto is desirablet The goto requires a label in order to identify the place where the branch is to be made. A label is a valid variable name followed by a colon. The label is placed immediately before the statement where the control is to be transformed. A program may contain several goto statements that transferred to the same place when a program. The label must be unique. Control can be transferred out of or within a compound statement, and control can be transferred to the beginning of a compound statement. However the control cannot be transferred into a compound statement. The goto statement is discouraged in C, because it alters the sequential flow of logic that is the characteristic of C language. a> goto label; ………… ………… ………… label: Statement; b> label: ………… ………… ………… goto label;
15. Example Program #include <stdio.h> main () { int n, sum = 0, i = 0; printf ("Enter a number"); scanf ("%d", &n) ; loop: i++; sum += i ; if (i < n) goto loop; printf (" sum of %d natural numbers = %d", n, sum) }
16. Program Loops and Iteration During looping a set of statements are executed until some conditions for termination of the loop is encountered. A program loop therefore consists of two segments one known as body of the loop and other is the control statement. The control statement tests certain conditions and then directs the repeated execution of the statements contained in the body of the loop. In looping process in general would include the following four steps 1. Setting and initialization of a counter 2. Exertion of the statements in the loop 3. Test for a specified conditions for the execution of the loop 4. Incrementing the counter The test may be either to determine whether the loop has repeated the specified number of times or to determine whether the particular condition has been met.
17. The While Statement: The simplest of all looping structure in C is the while statement. The general format of the while statement is: while (test condition) { body of the loop } Here the given test condition is evaluated and if the condition is true then the body of the loop is executed. After the execution of the body, the test condition is once again evaluated and if it is true, the body is executed once again. This process of repeated execution of the body continues until the test condition finally becomes false and the control is transferred out of the loop. On exit, the program continues with the statements immediately after the body of the loop. The body of the loop may have one or more statements. The braces are needed only if the body contained two are more statements
18. Examples Program # include < stdio.h > void main() { int n, i=0; printf(“Enter the upper limit number”); scanf(“%d”, &n); while(I < = n) { printf(“%d”,I); I++; } }
19. The Do while statement The do while loop is also a kind of loop, which is similar to the while loop in contrast to while loop, the do while loop tests at the bottom of the loop after executing the body of the loop. Since the body of the loop is executed first and then the loop condition is checked we can be assured that the body of the loop is executed at least once. The syntax of the do while loop is: do { statement; } while(expression);
20. Example Program /* Program to illustrate the do while loop*/ #include<stdio.h> #include<conio.h> void main() { int n,i=0; printf("Enter the limit:"); scanf("%d",&n); do { printf("%d",i); i++; } while(i<=n); getch(); }
21. The Break Statement: Sometimes while executing a loop it becomes desirable to skip a part of the loop or quit the loop as soon as certain condition occurs, for example consider searching a particular number in a set of 100 numbers as soon as the search number is found it is desirable to terminate the loop. C language permits a jump from one statement to another within a loop as well as to jump out of the loop. The break statement allows us to accomplish this task. A break statement provides an early exit from for, while, do and switch constructs. A break causes the innermost enclosing loop or switch to be exited immediately. Example program to illustrate the use of break statement . /* A program to find the average of the marks*/ #include < stdio.h > void main() { int I, num=0; float sum=0,average; printf(“Input the marks, -1 to end”); while(1) { scanf(“%d”,&I); if(I==-1) break; sum+=I; num++; } }
22. Continue statement: During loop operations it may be necessary to skip a part of the body of the loop under certain conditions. Like the break statement C supports similar statement called continue statement. The continue statement causes the loop to be continued with the next iteration after skipping any statement in between. The continue with the next iteration the format of the continue statement is simply: Continue; Consider the following program that finds the sum of five positive integers. If a negative number is entered, the sum is not performed since the remaining part of the loop is skipped using continue statement. #include < stdio.h > void main() { int I=1, num, sum=0; for (I = 0; I < 5; I++) { printf(“Enter the integer”); scanf(“%I”, &num); if(num < 0) { printf(“You have entered a negative number”); continue; } sum+=num; } printf(“The sum of positive numbers entered = %d”,sum); }
23. For Loop The for loop provides a more concise loop control structure. The general form of the for loop is: for (initialization; test condition; increment) { body of the loop } When the control enters for loop the variables used in for loop is initialized with the starting value such as I=0,count=0. The value which was initialized is then checked with the given test condition. The test condition is a relational expression, such as I < 5 that checks whether the given condition is satisfied or not if the given condition is satisfied the control enters the body of the loop or else it will exit the loop. The body of the loop is entered only if the test condition is satisfied and after the completion of the execution of the loop the control is transferred back to the increment part of the loop. The control variable is incremented using an assignment statement such as I=I+1 or simply I++ and the new value of the control variable is again tested to check whether it satisfies the loop condition. If the value of the control variable satisfies then the body of the loop is again executed. The process goes on till the control variable fails to satisfy the condition.
24. Additional features of the for loop We can include multiple expressions in any of the fields of for loop provided that we separate such expressions by commas. For example in the for statement that begins for( I = 0; j = 0; I < 10, j=j-10) The initialization expression field can simply be “left blank” in such a case as long as the semicolon is still included: for(;j!=100;++j) The above statement might be used if j were already set to some initial value before the loop was entered. A for loop that has its looping condition field omitted effectively sets up an infinite loop, that is a loop that theoretically will be executed for ever.
25. For loop example program: /* The following is an example that finds the sum of the first fifteen positive natural numbers*/ #include < stdio.h > void main() { int I; int sum=0,sum_of_squares=0; for(I=0;I < = 30; I+=2) { sum+=I; sum_of_squares += I*I; } printf(“Sum of first 15 positive even numbers=%d”,sum); printf(“Sum of their squares=%d”,sum_of_squares); }
26. Functions (Modular Programming) The basic philosophy of function is divide and conquer by which a complicated tasks are successively divided into simpler and more manageable tasks which can be easily handled. A program can be divided into smaller subprograms that can be developed and tested successfully. A function is a complete and independent program which is used (or invoked) by the main program or other subprograms. A subprogram receives values called arguments from a calling program, performs calculations and returns the results to the calling program. There are many advantages in using functions in a program they are: 1. It facilitates top down modular programming. In this programming style, the high level logic of the overall problem is solved first while the details of each lower level functions is addressed later. 2. the length of the source program can be reduced by using functions at appropriate places.This factor is critical with microcomputers where memory space is limited. 3. It is easy to locate and isolate a faulty function for further investigation. 4. A function may be used by many other programs this means that a c programmer can build on what others have already done, instead of starting over from scratch. 5. A program can be used to avoid rewriting the same sequence of code at two or more locations in a program. This is especially useful if the code involved is long or complicated. 6. Programming teams does a large percentage of programming. If the program is divided into subprograms, each subprogram can be written by one or two team members of the team rather than having the whole team to work on the complex program
27. Function definition [ data type] function name (argument list) { local variable declarations; statements; [return expression] } Example mul(int a,int b) { int y; y=a+b; return y; } When the value of y which is the addition of the values of a and b. the last two statements ie, y=a+b; can be combined as return(y) return(a+b);
28. Types of functions: A function may belong to any one of the following categories: 1. Functions with no arguments and no return values. 2. Functions with arguments and no return values. 3. Functions with arguments and return values. Functions with no arguments and no return values: Let us consider the following program /* Program to illustrate a function with no argument and no return values*/ #include <stdio.h> void main() { statement1(); starline(); statement2(); starline(); } /*function to print a message*/ statement1() { printf(“ Sample subprogram output”); } statement2() { printf(“ Sample subprogram output two”); } starline() { int a; for (a=1;a<60;a++) printf(“*”); printf(“”); }
29. Functions with arguments but no return values: The formal arguments may be valid variable names, the actual arguments may be variable names expressions or constants. The values used in actual arguments must be assigned values before the function call is made. When a function call is made only a copy of the values actual arguments is passed to the called function. What occurs inside the functions will have no effect on the variables used in the actual argument list. Let us consider the following program /*Program to find the largest of two numbers using function*/ #include<stdio.h> main() { int a,b; printf(“Enter the two numbers”); scanf(“%d%d”,&a,&b); largest(a,b) } /*Function to find the largest of two numbers*/ largest(int a, int b) { if(a>b) printf(“Largest element=%d”,a); else printf(“Largest element=%d”,b); } in the above program we could make the calling function to read the data from the terminal and pass it on to the called function. But function foes not return any value.
30.
31. CONTD….. 2. The called function must be declared at the start of the body in the calling function, like any other variable. This is to tell the calling function the type of data the function is actually returning. The program given below illustrates the transfer of a floating-point value between functions done in a multiple function program. #include<stdio.h> float add(float,float); double sub(double,double); void main() { float x,y; x=12.345; y=9.82; printf("%f",add(x,y)); printf("%lf",sub(x,y)); } float add(float a,float b) { return(a+b); } double sub(double p,double q) { return(p-q); } We can notice that the functions too are declared along with the variables. These declarations clarify to the compiler that the return type of the function add is float and sub is double.
32. Void functions: The functions that do not return any values can be explicitly defined as void. This prevents any accidental use of these functions in expressions. Nesting of functions: C permits nesting of two functions freely. There is no limit how deeply functions can be nested. Suppose a function a can call function b and function b can call function c and so on. Consider the following program: #include<stdio.h> float ratio(int,int,int); int difference(int,int); void main() { int a,b,c; scanf("%d%d%d",&a,&b,&c); printf("%f",ratio(a,b,c)); } float ratio(int x,int y,int z) { if(difference(y,z)) return(x/(y-z)); else return(0.0); } difference(int p,int q) { if(p!=q) return(1); else return(0); }
33. CONTD…. the above program calculates the ratio a/b-c; and prints the result. We have the following three functions: main() ratio() difference() main reads the value of a,b,c and calls the function ratio to calculate the value a/b-c) this ratio cannot be evaluated if(b-c) is zero. Therefore ratio calls another function difference to test whether the difference(b-c) is zero or not
34. The scope and lifetime of variables in functions: The scope and lifetime of the variables define in C is not same when compared to other languages. The scope and lifetime depends on the storage class of the variable in c language the variables can be any one of the four storage classes: 1. Automatic Variables 2. External variable 3. Static variable 4. Register variable. Automatic variables: Automatic variables are declared inside a particular function and they are created when the function is called and destroyed when the function exits. Automatic variables are local or private to a function in which they are defined by default all variable declared without any storage specification is automatic. The values of variable remains unchanged to the changes that may happen in other functions in the same program and by doing this no error occurs. #include<stdio.h> void main() { int m=1000; function2(); printf(“%d”,m); } function1() { int m=10; printf(“%d”,m); } function2() { int m=100; function1(); printf(“%d”,m); }
35. External variables: Variables which are common to all functions and accessible by all functions of aprogram are internal variables. External variables can be declared outside a function. Example int sum; float percentage; main() { ….. ….. } function1() { …. …. } function2() { …. …. } The variables sum and percentage are available for use in all the three functions main, function1, function2. Local variables take precedence over global variables of the same name.
36. Static variables: The value given to a variable declared by using keyword static persistes until the end of the program. A static variable is initialized only once, when the program is compiled. It is never initialized again. During the first call to stat in the example shown below x is incremented to 1. because x is static, this value persists and therefore the next call adds another 1 to x giving it a value of 2. The value of x becomes 3 when third call is made. If we had declared x as an auto then output would here been x=1 all the three times. main() { int j; for(j=1;j<3;j++) stat(); } stat() { static int x=0; x=x+1; printf(“x=%d”,x); }
37. Register variables: A variable is usually stored in the memory but it is also possible to store a varible in the compilers register by defining it as register variable. The registers access is much faster than a memory access, keeping the frequently accessed variables in the register will make the execution of the program faster. This is done as follows: register int count;