Learn C Programming interactively.
Learn C practically and Get Certified .

Popular Tutorials
Popular examples, reference materials.
Learn C Interactively
Interactive C Course
C introduction.
- Keywords & Identifier
- Variables & Constants
- C Data Types
- C Input/Output
- C Operators
- C Introduction Examples
C Flow Control
- C if...else
- C while Loop
- C break and continue
- C switch...case
- C Programming goto
- Control Flow Examples
C Functions
- C Programming Functions
- C User-defined Functions
- C Function Types
- C Recursion
- C Storage Class
- C Function Examples
- C Programming Arrays
- C Multi-dimensional Arrays
- C Arrays & Function
- C Programming Pointers
- C Pointers & Arrays
- C Pointers And Functions
- C Memory Allocation
- Array & Pointer Examples
C Programming Strings
- C Programming String
- C String Functions
- C String Examples
Structure And Union
- C Structure
- C Struct & Pointers
- C Struct & Function
- C struct Examples
C Programming Files
- C Files Input/Output
- C Files Examples
Additional Topics
- C Enumeration
- C Preprocessors
- C Standard Library
- C Programming Examples
Related Topics
- Add Two Integers
C switch Statement
- Find the Largest Number Among Three Numbers
C while and do...while Loop
- C goto Statement
C if...else Statement
In this tutorial, you will learn about the if statement (including if...else and nested if..else) in C programming with the help of examples.
Video: C if else Statement
C if Statement
The syntax of the if statement in C programming is:
How if statement works?
The if statement evaluates the test expression inside the parenthesis () .
- If the test expression is evaluated to true, statements inside the body of if are executed.
- If the test expression is evaluated to false, statements inside the body of if are not executed.

To learn more about when test expression is evaluated to true (non-zero value) and false (0), check relational and logical operators .
Example 1: if statement
When the user enters -2, the test expression number<0 is evaluated to true. Hence, You entered -2 is displayed on the screen.
When the user enters 5, the test expression number<0 is evaluated to false and the statement inside the body of if is not executed
The if statement may have an optional else block. The syntax of the if..else statement is:
How if...else statement works?
If the test expression is evaluated to true,
- statements inside the body of if are executed.
- statements inside the body of else are skipped from execution.
If the test expression is evaluated to false,
- statements inside the body of else are executed
- statements inside the body of if are skipped from execution.

Example 2: if...else statement
When the user enters 7, the test expression number%2==0 is evaluated to false. Hence, the statement inside the body of else is executed.
C if...else Ladder
The if...else statement executes two different codes depending upon whether the test expression is true or false. Sometimes, a choice has to be made from more than 2 possibilities.
The if...else ladder allows you to check between multiple test expressions and execute different statements.
Syntax of if...else Ladder
Example 3: c if...else ladder.
- Nested if...else
It is possible to include an if...else statement inside the body of another if...else statement.
Example 4: Nested if...else
This program given below relates two integers using either < , > and = similar to the if...else ladder's example. However, we will use a nested if...else statement to solve this problem.
If the body of an if...else statement has only one statement, you do not need to use brackets {} .
For example, this code
is equivalent to
Table of Contents
- if Statement
- if...else Statement
- if...else Ladder
Sorry about that.
Related Tutorials
C Ternary Operator
Try PRO for FREE
- C programming
- c programming intro
- c programming history
- setting up compiler
- my first c program
- c programming keywords
- c programming variables
- c programming datatypes
- c programming operators
C programming flow control
- c programming if else
- c programming while loop
- c programming for loop
- c break & continue
- c switch statement
- c goto statement
C programming functions
- c programming functions
- c function arguments
- c user defined functions
- c function types
- c programming recursion
- c storage class
C programming arrays
- c programming arrays
- c multidimensional arrays
- c arrays & functions
C strings and pointers
- c programming pointers
- c arrays and pointers
- c programming strings
- string manipulation
C programming structures
- c programming structures
- Arrays and structures
C programming files I/O
- c programming files
Additional topics
- c preprocessor directives
- c math library functions
- c character library functions
- c programming examples
How to write a C program: Step by step guideline
In this article, you will learn about how to write a C program with our step by step guidelines. Till now we have learned various concepts of C programming and are ready to write programs of modest complexity or develop projects.
This is our comprehensive step by step guidelines about how to write a C program.
How to write a C program?
Martin Fowler once said:
“ Any fool can write code that a computer can understand. Good programmers write code that humans can understand. ”
A programmer can write complex codes to solve the task but only a brilliant programmer write programs that can be interpreted by others and can be maintained if any errors come down the line.
Therefore, before writing complex programs, it is a good idea to follow some programming techniques because well-written programs possess several traits.
- Well-written and indented programs are easier to understand, debug or maintain.
- Well-written and indented programs are designed to efficient, flexible and robust.
So, how should I begin to write code and what steps should I follow then?
Don’t worry!
In this article, We will guide you through important stages of program development that will possess above characteristics.
The major steps are:
Program Design
Program coding, program testing and debugging.
Program design is the foundation that is at the heart of program development cycle.
Before getting your hands on the source code, it is crucial to understand the program from all sides and develop program development strategy.
You can break down program design into four steps:
Problem Analysis
Generating the program structure or blue print, algorithm development of the program, proper selection of control statements.
The first step is to get the clear idea of the problem and what you want the program to do. So ask yourself the following questions:
- What will be the input of your program?
- What will be the output?
- What are the different conditions that will be applied during the program?
Once you have got the answers to the above questions, you should decide how to accomplish the task.
How should the program be organized?
Since C is a structured language it follows the top-down approach that means break the whole problem into smaller tasks. Now it is easier to code smaller subtasks.
This will produce a readable and modular code which is very important for others to understand your code.
This is the important step of the program design. Once you have got the overall idea and broke the problem into smaller subtasks, it’s time to scratch details and step by step procedure, that is known as Algorithm in programming.
This is also known as pseudocode.
After the development of the algorithm, you should draw flowchart, pictorial representation of the algorithm.
I already mentioned this as an important step because there are several ways to solve the problem and it’s up to you which way you are going.
For example, for sorting an array you can use bubble sort , insertion sort or selection sort .
In a complex C program or project, you will have to use a huge number of control statements such as if ... else , while or for to direct the flow of execution.
Any algorithm or decision making can be accomplished using sequence structure, selection structure, and looping structure. Use proper control statements that will make your code easy and error-free.
Choosing a good way to represent the information can often make designing the program easy and simple.
Try avoiding the use of goto statements.
Once you have developed the full blue print of the program, it’s time to write source code according to the algorithm. That means be ready to translate your flowchart into a set of instruction.
It’s time to use your knowledge of C programming to work and try to write your code as simple as you can.
Following are the elements of program coding:
Proper documentation or commenting
Proper way for construction of statements, clear input/output formats, generality of the program.
The main goal of this step is to make code readable and understandable to others.
Selection of meaningful variable name and proper use of comments are an integral part of this step. Comments are necessary, but they must be good comments.
Let us see the example:
Although above program is syntactically correct, it can be written with proper variable names which is more meaningful.
While writing code, your statement should be simple and direct with proper indentation.
- Try to use one statement per line.
- Use parentheses and proper indentation
- Use simple loopings and avoid heavy nesting of loops
Observe following coding styles:
Although above program is syntactically correct, it can be written with proper indentation and commenting.
Both codes are syntactically right but consider proper way of statement construction.
The user should understand what to input and output of the program.
Always mention input requests clearly and label all outputs.
We should always try to minimize the dependence of the program on particular data.
For example: While defining the size of an array use macro so that it’s easy for the programmer to change the size later in the program.
In this phase, you will review your source code for error checking.
Errors may be:
- Syntax errors
- Run-time errors
- Logical errors
- Latent errors
Compiler helps to detect syntax and semantic errors. It is a computer program that converts source code into executable code or machine language.
Please check out the typical development of C program for detail understanding.
The compiler is unable to detect run-time and logical errors, so there is need of human testing as well.
Debugging means correcting the programming errors. There are different methods of debugging a source code.
- Place printf statements at various steps to see the values of variable or output. This helps to identify an error.
- Another way is the process of deduction. Eliminate possible error code from the program.
- Many coder use method called backtrack for debugging. In this method source code is tracked backward until the error is detected.
Program Efficiency
Program efficiency relates to the execution time of the program and memory consumption.
If you follow all of the above-mentioned techniques, your program will be efficient as well as effective.
Last but not least, following are some of the tips to improve program efficiency.
- Be wise to select a simple and effective algorithm, arithmetic and logical expressions.
- Declare arrays and string with appropriate size and if possible, avoid the use of the multidimensional array.
- Keep pointer in your priority list while dealing with arrays and string.

Loops in C: For, While, Do While looping Statements [Examples]
- What is Loop in C?
Looping Statements in C execute the sequence of statements many times until the stated condition becomes false. A loop in C consists of two parts, a body of a loop and a control statement. The control statement is a combination of some conditions that direct the body of the loop to execute until the specified condition becomes false. The purpose of the C loop is to repeat the same code a number of times.
In this tutorial, you will learn-
Types of Loops in C
While loop in c, do-while loop in c, for loop in c, break statement in c, continue statement in c, which loop to select.
Depending upon the position of a control statement in a program, looping statement in C is classified into two types:
1. Entry controlled loop
2. Exit controlled loop
In an entry control loop in C, a condition is checked before executing the body of a loop. It is also called as a pre-checking loop.

The control conditions must be well defined and specified otherwise the loop will execute an infinite number of times. The loop that does not stop executing and processes the statements number of times is called as an infinite loop . An infinite loop is also called as an “ Endless loop .” Following are some characteristics of an infinite loop:
1. No termination condition is specified.
2. The specified conditions never meet.
The specified condition determines whether to execute the loop body or not.
‘C’ programming language provides us with three types of loop constructs:
1. The while loop
2. The do-while loop
3. The for loop
A while loop is the most straightforward looping structure. While loop syntax in C programming language is as follows:
Syntax of While Loop in C:
It is an entry-controlled loop. In while loop, a condition is evaluated before processing a body of the loop. If a condition is true then and only then the body of a loop is executed. After the body of a loop is executed then control again goes back at the beginning, and the condition is checked if it is true, the same process is executed until the condition becomes false. Once the condition becomes false, the control goes out of the loop.
After exiting the loop, the control goes to the statements which are immediately after the loop. The body of a loop can contain more than one statement. If it contains only one statement, then the curly braces are not compulsory. It is a good practice though to use the curly braces even we have a single statement in the body.
In while loop, if the condition is not true, then the body of a loop will not be executed, not even once. It is different in do while loop which we will see shortly.
Following program illustrates while loop in C programming example:
The above program illustrates the use of while loop. In the above program, we have printed series of numbers from 1 to 10 using a while loop.

While Loop in C Programming
- We have initialized a variable called num with value 1. We are going to print from 1 to 10 hence the variable is initialized with value 1. If you want to print from 0, then assign the value 0 during initialization.
- In a while loop, we have provided a condition (num<=10), which means the loop will execute the body until the value of num becomes 10. After that, the loop will be terminated, and control will fall outside the loop.
- In the body of a loop, we have a print function to print our number and an increment operation to increment the value per execution of a loop. An initial value of num is 1, after the execution, it will become 2, and during the next execution, it will become 3. This process will continue until the value becomes 10 and then it will print the series on console and terminate the loop.
A do…while loop in C is similar to the while loop except that the condition is always executed after the body of a loop. It is also called an exit-controlled loop.
Syntax of do while loop in C programming language is as follows:
Syntax of Do-While Loop in C:
As we saw in a while loop, the body is executed if and only if the condition is true. In some cases, we have to execute a body of the loop at least once even if the condition is false. This type of operation can be achieved by using a do-while loop.
In the do-while loop, the body of a loop is always executed at least once. After the body is executed, then it checks the condition. If the condition is true, then it will again execute the body of a loop otherwise control is transferred out of the loop.
Similar to the while loop, once the control goes out of the loop the statements which are immediately after the loop is executed.
The critical difference between the while and do-while loop is that in while loop the while is written at the beginning. In do-while loop, the while condition is written at the end and terminates with a semi-colon (;)
The following loop program in C illustrates the working of a do-while loop:
Below is a do-while loop in C example to print a table of number 2:
In the above example, we have printed multiplication table of 2 using a do-while loop. Let’s see how the program was able to print the series.

Do-While Loop in C Programming
- First, we have initialized a variable ‘num’ with value 1. Then we have written a do-while loop.
- In a loop, we have a print function that will print the series by multiplying the value of num with 2.
- After each increment, the value of num will increase by 1, and it will be printed on the screen.
- Initially, the value of num is 1. In a body of a loop, the print function will be executed in this way: 2*num where num=1, then 2*1=2 hence the value two will be printed. This will go on until the value of num becomes 10. After that loop will be terminated and a statement which is immediately after the loop will be executed. In this case return 0.
A for loop is a more efficient loop structure in ‘C’ programming. The general structure of for loop syntax in C is as follows:
Syntax of For Loop in C:
- The initial value of the for loop is performed only once.
- The condition is a Boolean expression that tests and compares the counter to a fixed value after each iteration, stopping the for loop when false is returned.
- The incrementation/decrementation increases (or decreases) the counter by a set value.
Following program illustrates the for loop in C programming example:
The above program prints the number series from 1-10 using for loop.

For Loop in C Programming
- We have declared a variable of an int data type to store values.
- In for loop, in the initialization part, we have assigned value 1 to the variable number. In the condition part, we have specified our condition and then the increment part.
- In the body of a loop, we have a print function to print the numbers on a new line in the console. We have the value one stored in number, after the first iteration the value will be incremented, and it will become 2. Now the variable number has the value 2. The condition will be rechecked and since the condition is true loop will be executed, and it will print two on the screen. This loop will keep on executing until the value of the variable becomes 10. After that, the loop will be terminated, and a series of 1-10 will be printed on the screen.
In C, the for loop can have multiple expressions separated by commas in each part.
For example:
Also, we can skip the initial value expression, condition and/or increment by adding a semicolon.
Notice that loops can also be nested where there is an outer loop and an inner loop. For each iteration of the outer loop, the inner loop repeats its entire cycle.
Consider the following example with multiple conditions in for loop, that uses nested for loop in C programming to output a multiplication table:
The nesting of for loops can be done up-to any level. The nested loops should be adequately indented to make code readable. In some versions of ‘C,’ the nesting is limited up to 15 loops, but some provide more.
The nested loops are mostly used in array applications which we will see in further tutorials.
The break statement is used mainly in the switch statement. It is also useful for immediately stopping a loop.
We consider the following program which introduces a break to exit a while loop:
When you want to skip to the next iteration but remain in the loop, you should use the continue statement.
So, the value 5 is skipped.
Selection of a loop is always a tough task for a programmer, to select a loop do the following steps:
- Analyze the problem and check whether it requires a pre-test or a post-test loop.
- If pre-test is required, use a while or for a loop.
- If post-test is required, use a do-while loop.
- Define loop in C: A Loop is one of the key concepts on any Programming language . Loops in C language are implemented using conditional statements.
- A block of loop control statements in C are executed for number of times until the condition becomes false.
- Loops in C programming are of 2 types: entry-controlled and exit-controlled.
- List various loop control instructions in C: C programming provides us 1) while 2) do-while and 3) for loop control instructions.
- For and while loop C programming are entry-controlled loops in C language.
- Do-while is an exit control loop in C.
You Might Like:
- Powershell Tutorial for Beginners: Learn Powershell Scripting
- Type Casting in C: Type Conversion, Implicit, Explicit with Example
- Top 100 C Programming Interview Questions and Answers (PDF)
- free() Function in C library: How to use? Learn with Example
- Difference Between malloc() and calloc()

- Stack Overflow Public questions & answers
- Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
- Talent Build your employer brand
- Advertising Reach developers & technologists worldwide
- About the company
Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Statement with ? in C [duplicate]
Possible Duplicate: How do I use the conditional operator?
I’m new to C language, and in one of the sample codes I was reviewing I faced the statement:
I was just wondering what the task of the previous statement is and what will be the result after execution of the mentioned statement.
- ternary-operator
- Same as [How do I use the conditional operator? ]( stackoverflow.com/questions/392932/… ). – Matthew Flaschen Nov 25, 2010 at 11:29
6 Answers 6
It's called a ternary operator . expr ? a : b returns a if expr is true, b if false. expr can be a boolean expression (e.g. x > 3 ), a boolean literal/variable or anything castable to a boolean (e.g. an int).
int ret = expr ? a : b is equivalent to the following:
The nice thing about the ternary operator is that it's an expression, whereas the above are statements, and you can nest expressions but not statements. So you can do things like ret = (expr ? a : b) > 0;
As an extra tidbit, Python >=2.6 has a slightly different syntax for an equivalent operation: a if expr else b .
It assigns to A the value of B if A is true, otherwise C[0] .
result = a > b ? x : y; is identical to this block:
It's the same as an if else statement.
It could be rewritten as:
A gets assigned to B if A exists (not NULL), otherwise C[0].
- -1 the inexistence of A makes the code not even compile. A can be NULL , 0 (int), 0.0 (double), etc ... – pmg Nov 25, 2010 at 11:21
- And it's B gets assigned to A. – Matthew Flaschen Nov 25, 2010 at 11:26
- Thought it was implied that if I said not NULL that I was refering to a pointer, not a double, int, etc. And A gets assigned to B, not vice versa. – Neil Nov 25, 2010 at 11:32
- @Neil: B does not change value with the expression in this question. Neither does C ... A (possibly) changes value. – pmg Nov 25, 2010 at 11:35
- A gets assigned to B. At what point did I say that B changes (or even C for that matter)? A takes on the value of B is what I meant by that. – Neil Nov 25, 2010 at 11:48
if A equal 0 then A = C[0] else A = B
Not the answer you're looking for? Browse other questions tagged c syntax ternary-operator or ask your own question .
- The Overflow Blog
- From writing code to teaching code sponsored post
- After the buzz fades: What our data tells us about emerging technology sentiment
- Featured on Meta
- We've added a "Necessary cookies only" option to the cookie consent popup
- The Stack Exchange reputation system: What's working? What's not?
- Launching the CI/CD and R Collectives and community editing features for...
- The [amazon] tag is being burninated
- Temporary policy: ChatGPT is banned
- Staging Ground Beta 1 Recap, and Reviewers needed for Beta 2
Hot Network Questions
- Science fiction movie featuring a gynoid that becomes conscious and escapes her place of work
- Quest objectives not updating, even though the quest is already completed
- RegionFunction inside Show
- How to reduce multiattack penalty for bombs?
- Will a whole house surge protector save energy?
- Adjust side-by-side equations to the center and their equation number to the right
- What feature of Earth would be most likely attract the interest of aliens?
- Problem with multicolumn table
- Applying Ohm's law to household AC
- Does using the Archer ability with Circle of the Stars Druid require a free hand?
- How can I store the the IP and Port that are separated by ":" to two variables?
- Are 100% of statements undecidable, in Gödel's numbering?
- Will a CNN that is Group Equivariant always be better than a regular CNN?
- Would there be any side-effects of modded humans breeding with vanilla humans
- Schengen Visa "member state of first entry"
- Here comes the sun auf Deutsch?
- Must a man divorce an adulterous wife
- Sumset-distinct numbers
- Positions where pawn promotion to queen is worse than to other piece
- When speaking openly with a group of people, is it okay to speak casually with some and formally with others?
- Is it ok to say "When we would go to a restaurant ......." instead of "When we went to a restaurant, ....."?
- Why does my "grep" stop filtering?
- Can you be issued a trespass warning on public property for no reason at all?
- EventBus in C++
Your privacy
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy .
C++ Tutorial
C++ functions, c++ classes, c++ examples, c++ if ... else, c++ conditions and if statements.
You already know that C++ supports the usual logical conditions from mathematics:
- Less than: a < b
- Less than or equal to: a <= b
- Greater than: a > b
- Greater than or equal to: a >= b
- Equal to a == b
- Not Equal to: a != b
You can use these conditions to perform different actions for different decisions.
C++ has the following conditional statements:
- Use if to specify a block of code to be executed, if a specified condition is true
- Use else to specify a block of code to be executed, if the same condition is false
- Use else if to specify a new condition to test, if the first condition is false
- Use switch to specify many alternative blocks of code to be executed
The if Statement
Use the if statement to specify a block of C++ code to be executed if a condition is true .
Note that if is in lowercase letters. Uppercase letters (If or IF) will generate an error.
In the example below, we test two values to find out if 20 is greater than 18. If the condition is true , print some text:
We can also test variables:
Example explained
In the example above we use two variables, x and y , to test whether x is greater than y (using the > operator). As x is 20, and y is 18, and we know that 20 is greater than 18, we print to the screen that "x is greater than y".
C++ Exercises
Test yourself with exercises.
Print "Hello World" if x is greater than y .
Start the Exercise

COLOR PICKER

Get your certification today!

Get certified by completing a course today!

Report Error
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
[email protected]
Your Suggestion:
Thank you for helping us.
Your message has been sent to W3Schools.
Top Tutorials
Top references, top examples, web certificates, get certified.

- Data Structure
- Coding problems
- Kotlin programs
- C Interview programs
- C++ Aptitude
- Java Aptitude
- C# Aptitude
- PHP Aptitude
- Linux Aptitude
- DBMS Aptitude
- Networking Aptitude
- AI Aptitude
- MIS Executive
- HR Interview Que.
- Web Technologie MCQs
- CS Subjects MCQs
- Databases MCQs
- Programming MCQs
- Testing Software MCQs
- Commerce MCQs
- More MCQs...
- CS fundamental
- Operating systems
- Computer networks
- Software Engineering
- Discrete Mathematics
- Digital Electronics
- Data Mining
- Embedded systems
- Cloud computing
- Cryptography
- Big Data & Hadoop
- Machine Learning
- More Tutorials...
- Tech Articles
- Code Examples
- Programmer's Calculator
- XML Sitemap Generator

Home » C programming language
Logical OR (||) operator with example in C language
C language Logical OR (||) operator : Here, we are going to learn about the Logical OR (||) operator in C language with its syntax, example . Submitted by IncludeHelp , on April 14, 2019
Logical operators work with the test conditions and return the result based on the condition's results, these can also be used to validate multiple conditions together.
In C programming language, there are three logical operators Logical AND (&&) , Logical OR (||) and Logician NOT (!) .
Logical OR (||) operator in C
Logical OR is denoted by double pipe characters ( || ), it is used to check the combinations of more than one conditions; it is a binary operator – which requires two operands.
If any of the operand's values is non-zero (true), Logical OR (||) operator returns 1 ("true"), it returns 0 ("false") if all operand's values are 0 (false).
Syntax of Logical OR operator:
Truth table of logical OR operator:
C examples of Logical OR (||) operator
Example 1: Take a number and apply some of the conditions and print the result of expression containing logical OR operator.
Example 2: Input gender in single character and print full gender (Ex: if input is 'M' or 'm' – it should print "Male").
Example 3: Input an integer number and check whether it is divisible by 9 or 7.
Related Tutorials
- Precedence and associativity of Arithmetic Operators
- Difference b/w operators and operands in C
- Unary Operators in C with Examples
- Equality Operators in C,C++
- Logical AND (&&) operator with example
- Logical NOT (!) operator with example
- Modulus on negative numbers in C language
- How expression a=b=c (Multiple Assignment) evaluates in C programming?
- How expression a==b==c (Multiple Comparison) evaluates in C programming?
- Complex return statement using comma operator in c programming language
- Explain comma operator with an example
- Bitwise Operators and their working
- Bitwise One's Compliment (Bitwise NOT Operator) in C
- Modulus of two float or double numbers in C language
- Switch Case Tutorial, Syntax, Examples and Rules in C language
- Switch Statements (features, disadvantages and difference with if else)
- Using range with switch case statement
- 'goto' Statement in C language
- Use of break and continue within the loop in c
- Print numbers from 1 to N using goto statement
- Looping Tutorial in C programming
- Nested Loops in C programming language
- How to use for loop as infinite loop in C?
Preparation
What's New (MCQs)
- C Language MCQs
- Python MCQs
- MongoDB MCQs
- Blockchain MCQs
- AutoCAD MCQs
- ASP.Net MCQs
- JavaScript MCQs
- jQuery MCQs
- ReactJS MCQs
- AngularJS MCQs
- Advanced CSS MCQs
- PL/SQL MCQs
- Oracle MCQs
- SQLite MCQs
- CouchDB MCQs
- MariaDB MCQs
- MS Word MCQs
- MS Excel MCQs
- MS PowerPoint MCQs
- Google Sheets MCQs
- Software Engineering MCQs
- Operating System MCQs
- Data Analytics and Visualization MCQs
- WordPress MCQs
- Blogging MCQs
- Digital Marketing MCQs
- Online Marketing MCQs
- Adobe After Effects MCQs
- Adobe Dreamweaver MCQs
- Adobe Illustrator MCQs
- CorelDRAW MCQs
- Google Chrome MCQs
- Bugzilla MCQs
- OpenStack MCQs
- JMeter MCQs
- ETL Testing MCQs
- Appium MCQs
- Control Systems MCQs
- PySpark MCQs
- Cucumber Testing MCQs
- UiPath MCQs
- TestNG MCQs
- Software Architecture MCQs
- Software Testing MCQs
- Selenium MCQs
- Agile Methodology MCQs
- AWS (Amazon Web Services) MCQs
- Microsoft Azure MCQs
- Energy & Environment Engineering MCQs
- Project Management MCQs
- Marketing MCQs
- Generally Accepted Accounting Principles MCQs
- Bills of Exchange MCQs
- Business Environment MCQs
- Sustainable Development MCQs
- Marginal Costing and Absorption Costing MCQs
- Globalisation MCQs
- Indian Economy MCQs
- Retained Earnings MCQs
- Depreciation MCQs
- Partnership MCQs
- Sole Proprietorship MCQs
- Goods and Services Tax (GST) MCQs
- Cooperative Society MCQs
- Capital Market MCQs
- Business Studies MCQs
- Basic Accounting MCQs
- MIS Executive Interview Questions
- Go Language Interview Questions
Top Interview Coding Problems/Challenges!
- Run-length encoding (find/print frequency of letters in a string)
- Sort an array of 0's, 1's and 2's in linear time complexity
- Checking Anagrams (check whether two string is anagrams or not)
- Relative sorting algorithm
- Finding subarray with given sum
- Find the level in a binary tree with given sum K
- Check whether a Binary Tree is BST (Binary Search Tree) or not
- 1[0]1 Pattern Count
- Capitalize first and last letter of each word in a line
- Print vertical sum of a binary tree
- Print Boundary Sum of a Binary Tree
- Reverse a single linked list
- Greedy Strategy to solve major algorithm problems
- Job sequencing problem
- Root to leaf Path Sum
- Exit Point in a Matrix
- Find length of loop in a linked list
- Toppers of Class
- Print All Nodes that don't have Sibling
- Transform to Sum Tree
- Shortest Source to Destination Path
Comments and Discussions!
IncludeHelp's Blogs
- Do's and Don'ts For Dressing Up For Interviews
- Tips To Improve Spoken English
- 20 Smart Questions To Ask During An Interview
- Common Body Language Mistakes to Avoid During Interviews
- Is it important to have a college degree in today's world?
Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML Solved programs: » C » C++ » DS » Java » C# Aptitude que. & ans.: » C » C++ » Java » DBMS Interview que. & ans.: » C » Embedded C » Java » SEO » HR CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS More: » Articles » Puzzles » News/Updates
ABOUT SECTION » About us » Contact us » Feedback » Privacy policy
STUDENT'S SECTION » Internship » Certificates » Content Writers of the Month
SUBSCRIBE » Facebook » LinkedIn » Subscribe through email
© https://www.includehelp.com some rights reserved.
Note: You are looking at a static copy of the former PineWiki site, used for class notes by James Aspnes from 2003 to 2012. Many mathematical formulas are broken, and there are likely to be other bugs as well. These will most likely not be fixed. You may be able to find more up-to-date versions of some of these notes at http://www.cs.yale.edu/homes/aspnes/#classes .
- Simple statements
- Conditionals
- The while loop
- The do..while loop
- The for loop
- Loops with break, continue, and goto
- Choosing where to put a loop exit
1. Simple statements
2. compound statements, 2.1. conditionals, 2.2.1. the while loop, 2.2.2. the do..while loop, 2.2.3. the for loop, 2.2.4. loops with break, continue, and goto, 2.3. choosing where to put a loop exit.
C Programming/Statements
A statement is a command given to the computer that instructs the computer to take a specific action, such as display to the screen, or collect input. A computer program is made up of a series of statements.
- 1 Labeled Statements
- 2 Compound Statements
- 3 Expression Statements
- 4 Selection Statements
- 5 Iteration Statements
- 6 Jump Statements
In C, a statement can be any of the following:
Labeled Statements [ edit | edit source ]
A statement can be preceded by a label. Three types of labels exist in C.
A simple identifier followed by a colon ( : ) is a label. Usually, this label is the target of a goto statement.
Within switch statements, case and default labeled statements exist.
A statement of the form
case constant-expression : statement
indicates that control will pass to this statement if the value of the control expression of the switch statement matches the value of the constant-expression . (In this case, the type of the constant-expression must be an integer or character.)
default : statement
indicates that control will pass to this statement if the control expression of the switch statement does not match any of the constant-expressions within the switch statement. If the default statement is omitted, the control will pass to the statement following the switch statement. Within a switch statement, there can be only one default statement, unless the switch statement is within another switch statement.
Compound Statements [ edit | edit source ]
A compound statement is the way C groups multiple statements into a single statement. It consists of multiple statements and declarations within braces (i.e. { and } ). In the ANSI C Standard of 1989-1990, a compound statement contained an optional list of declarations followed by an optional list of statements; in more recent revisions of the Standard, declarations and statements can be freely interwoven through the code. The body of a function is also a compound statement by rule.
Expression Statements [ edit | edit source ]
An expression statement consists of an optional expression followed by a semicolon ( ; ). If the expression is present, the statement may have a value. If no expression is present, the statement is often called the null statement .
The printf function calls are expressions, so statements such as printf ("Hello World!\n"); are expression statements.

Selection Statements [ edit | edit source ]
Three types of selection statements exist in C:
if ( expression ) statement
In this type of if-statement, the sub-statement will only be executed iff the expression is non-zero.
if ( expression ) statement else statement
In this type of if-statement, the first sub-statement will only be executed iff the expression is non-zero; otherwise, the second sub-statement will be executed. Each else matches up with the closest unmatched if , so that the following two snippets of code are not equal:
because in the first, the else statement matches up with the if statement that has secondexpression for a control, but in the second, the braces force the else to match up with the if that has expression for a control.
Switch statements are also a type of selection statement. They have the format
switch ( expression ) statement
The expression here is an integer or a character. The statement here is usually compound and it contains case-labeled statements and optionally a default-labeled statement. The compound statement should not have local variables as the jump to an internal label may skip over the initialization of such variables.
Iteration Statements [ edit | edit source ]
C has three kinds of iteration statements. The first is a while-statement with the form
while ( expression ) statement
The substatement of a while runs repeatedly as long as the control expression evaluates to non-zero at the beginning of each iteration. If the control expression evaluates to zero the first time through, the substatement may not run at all.
The second is a do-while statement of the form
do statement while ( expression ) ;
This is similar to a while loop, except that the controlling expression is evaluated at the end of the loop instead of the beginning and consequently the sub-statement must execute at least once.
The third type of iteration statement is the for-statement. In ANSI C 1989, it has the form
for ( expression opt ; expression opt ; expression opt ) statement
In more recent versions of the C standard, a declaration can substitute for the first expression. The opt subscript indicates that the expression is optional.
The statement
is the rough equivalent of
except for the behavior of continue statements within s .
The e1 expression represents an initial condition; e2 a control expression; and e3 what to happen on each iteration of the loop. If e2 is missing, the expression is considered to be non-zero on every iteration, and only a break statement within s (or a call to a non-returning function such as exit or abort ) will end the loop.
Jump Statements [ edit | edit source ]
C has four types of jump statements. The first, the goto statement, is used sparingly and has the form
goto identifier ;
This statement transfers control flow to the statement labeled with the given identifier. The statement must be within the same function as the goto .
The second, the break statement, with the form
is used within iteration statements and switch statements to pass control flow to the statement following the while, do-while, for, or switch.
The third, the continue statement, with the form
is used within the substatement of iteration statements to transfer control flow to the place just before the end of the substatement. In for statements the iteration expression ( e3 above) will then be executed before the controlling expression ( e2 above) is evaluated.
The fourth type of jump statement is the return statement with the form
return expression opt ;
This statement returns from the function. If the function return type is void , the function may not return a value; otherwise, the expression represents the value to be returned.
- C Programming Tutorial
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Functions
- C - Scope Rules
- C - Pointers
- C - Strings
- C - Structures
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
C - switch statement
A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each switch case .
The syntax for a switch statement in C programming language is as follows −
The following rules apply to a switch statement −
The expression used in a switch statement must have an integral or enumerated type, or be of a class type in which the class has a single conversion function to an integral or enumerated type.
You can have any number of case statements within a switch. Each case is followed by the value to be compared to and a colon.
The constant-expression for a case must be the same data type as the variable in the switch, and it must be a constant or a literal.
When the variable being switched on is equal to a case, the statements following that case will execute until a break statement is reached.
When a break statement is reached, the switch terminates, and the flow of control jumps to the next line following the switch statement.
Not every case needs to contain a break . If no break appears, the flow of control will fall through to subsequent cases until a break is reached.
A switch statement can have an optional default case, which must appear at the end of the switch. The default case can be used for performing a task when none of the cases is true. No break is needed in the default case.
Flow Diagram

When the above code is compiled and executed, it produces the following result −
Write in c language please: write a statement that calls the function IncreaseItemQty with parameters computerInfo and addStock. Assign computerInfo with the returned value. #include typedef struct ProductInfo_struct { char itemName[50]; int itemQty; } ProductInfo; ProductInfo IncreaseItemQty(ProductInfo productToStock, int increaseValue) { productToStock.itemQty = productToStock.itemQty + increaseValue; return productToStock; } int main(void) { ProductInfo computerInfo; int addStock; scanf("%s", computerInfo.itemName); scanf("%d", &computerInfo.itemQty); scanf("%d", &addStock); /* Your code goes here */ printf("Name: %s, stock: %d\n", computerInfo.itemName, computerInfo.itemQty); return 0; } thank you in advance
Write in c language please: write a statement that calls the function IncreaseItemQty with parameters computerInfo and addStock. Assign computerInfo with the returned value.
#include <stdio.h>
typedef struct ProductInfo_struct { char itemName[50]; int itemQty; } ProductInfo;
ProductInfo IncreaseItemQty(ProductInfo productToStock, int increaseValue) { productToStock.itemQty = productToStock.itemQty + increaseValue;
return productToStock; }
int main(void) { ProductInfo computerInfo; int addStock;
scanf("%s", computerInfo.itemName); scanf("%d", &computerInfo.itemQty); scanf("%d", &addStock);
/* Your code goes here */
printf("Name: %s, stock: %d\n", computerInfo.itemName, computerInfo.itemQty);
return 0; }
thank you in advance

Want to see the full answer?

Related Computer Science Q&A
Find answers to questions asked by students like you.
Q: A deadlock occurs when two or more processes wait an excessive amount of time for a shared resource…
A: Deadlock prevention steps are described in depth in When two or more processes wait for resources…
Q: Determine the running time for each recursive functions 1. T(n) = T([n/2]) + 1 2. T(n) = T(n-1) +…
A: Introduction: The running time of a recursive function is the amount of time it takes to execute the…
Q: 1. Your manager has asked you to implement a wired network infrastructure that will accommodate…
A: Click to see the answer
Q: When you initially start out in the field as a system analyst, what do you believe are the most…
A: fundamentals for creating an organization's successful and efficient information system. underlying…
Q: Write a recursive method called digitCount() that takes a positive integer as a parameter and…
A: recursive program with output is follows:
Q: In Principal Component analysis, the eigenvalues calculated during the transformation quantify the…
A: Introduction: Principal Component Analysis (PCA) is a commonly used statistical technique that…
Q: Write a python program with two functions/modules that does the following: .main() accepts input and…
A: Algorithm: Define a function called 'num_Test()' that takes an input string as its argument. Within…
Q: Open-source software such as Linux is a good illustration of this kind of program. In your own…
A: Introduction: Open-source software and how it differs from proprietary software.
Q: Provide four reasons why you think discrete event simulation is beneficial.
A: Simulation of Isolated Events: A system's various operations may be represented numerically as an…
Q: To what extent do formal methods really help achieve their goals? The use of specifications in…
A: Explain formal methods. Formal methods are used: Formal methods structure and rigorize all software…
Q: Find the places where your personal information is stored. How often and from which databases can…
A: Our personal information can be stored in many places, including: Social media platforms like…
Q: Why is continuous event simulation so crucial, and what are the four key reasons?
A: Your answer is given below.
Q: Wireless LAN access points are often mounted on doorknobs, tables, ceilings, and racks.
A: The answer is given in the below step
Q: When it comes to software, what exactly is the difference between V&V and V&V? Given their…
A: Validation: The process of assessing the finished product to see whether the software satisfies…
Q: Engineers creating system requirements specifications often find it difficult to keep track of the…
A: The exemplary instrument is a prerequisites detectability (sic) grid. There are even instruments…
Q: Which of the following control structures do the keywords DO WHILE and ENDDO indicate?
A: The following "3" kinds of control structures may be used to create any sort of computer programme.…
Q: provide three instances of discrete-event simulations
A: Discrete event simulation is a type of simulation that models the behavior of a system based on the…
Q: ntelligent modems can make and take calls on the user's behalf. In other words, who sends the…
A: Intelligent modems can be programmed to make and take calls based on specific instructions provided…
Q: 4. Rewrite the following program using a for loop: count = 0 i = 0 n = 10 while i < n: x =…
A: We have been given a code using while lopp we have to recreate the code using for loop.
Q: Provide a brief explanation of source data automation (SDA), focusing on at least two (2) benefits…
A: Introduction: Automation of Source Data (SDA): The term "Source Data Automation" (SDA) refers to the…
Q: what do you think are the most important considerations to keep in mind while creating an…
A: Business Information Systems are an important tool for all decision-making businesses. It provides…
Q: I'd be grateful if someone could explain data encapsulation in Java and how it relates to…
A: Introduction: Object-oriented programming, or OOP A paradigm for computer programming known as…
Q: Most individuals either don't know about or don't care about the potential problems associated with…
A: Many computer services, including as servers, storage, databases, networking, software, analytics,…
Q: What type of changes does adopting an agile approach bring to the standard SDLC?
A: Agile Methodology First off, the Software Development Life Cycle (SDLC) is what we're talking about.…
Q: With what terminology do you describe the router's startup process?
A: With what terminology do you describe the router's startup process
Q: Please detail the Assembly Registers and explain why they must be used during the whole procedure.
A: Register in assembly: The register in assembly is used to communicate with the processor so it may…
Q: Is it feasible to provide a comprehensive description of the four primary advantages of continuous…
A: 4 reasons why continuous-event simulation is so crucial: Assurance of complete safety: Safely…
Q: examination of computer and network infrastructure Do problems with computers and their operating…
A: The dining philosophers' problem is an important topic for us to examine because of its connection…
Q: s database-as-a-service the best fit for your library, and what factors should you consider
A: Introduction: On the other side, databases may easily become unmanageable if they aren't properly…
Q: The MBA program at State University has approximately 260 incoming students each fall semester.…
A: Explanation:
Q: Don't forget to include everything that goes into making up an internet connection.
A: HOW THE INTERNET WORKS: The computer network known as the internet is described as transmitting…
Q: These are three good arguments for why it's best to design the app's user experience before diving…
A: Lower development costs A well-planned design prevents problems. This includes interface support and…
Q: Thank you but Im sorry I forgot to mention its c language.
A: Solution: Given, In C language Write a statement to print the data members of InventoryTag. End…
Q: When it comes to the IoT, what are some of the most recent examples of attacks?
A: Clever Deadbolts Put Houses at Risk Researchers found weaknesses in a popular smart deadbolt that…
Q: Is there a substantial distinction between computer architecture and computer organization in the…
A: Introduction: Computer architecture and computer organization are two important terms that are often…
Q: A wavy line will appear at the cursor's current position in the code editor.
A: A code editor is a unique kind of content management tool made for creating and modifying computer…
Q: Which cable links the computers and servers in a local area network? Why does picking the right…
A: The cable that typically links computers and servers in a local area network (LAN) is an Ethernet…
Q: and Scientific Staff Management (PSSM) is a unique type of temporary staffing agency. Many…
A: The solution is an given below : Introduction Professionals and Scientific Staff Management (PSSM):…
Q: "Cloud computing" refers to a kind of computing that makes use of distant servers and communal…
A: Introduction: Shared resources, sometimes referred to as network resources, are computer files,…
Q: To interrupt: please elaborate on why it is expected that there will be no hardware disruptions of…
A: This is my own opinion, some common types of hardware disruptions are outages from natural…
Q: To answer this question, we must first examine why it is so important to take a methodical approach…
A: Creating an information system is a complex process that requires the integration of several…
Q: Since its debut, it has found widespread use in both 3rd- and 4th-generation DBMSs (DBMS). Do you…
A: Introduction: The Three Schema Architecture is a popular database design technique that was…
Q: What does peer-to-peer communication include in the OSI Model?
A: Peer-to-peer communication involves direct communication between two or more devices without the…
Q: Explain what a write-through cache modification and a write-back cache modification are, how they…
A: When a computer wants to save a word, it first looks in its cache to see whether it already exists.…
Q: Design and write a modular python program for chapter 7 programming exercise #12 from your textbook,…
A: In this question we have to write a python code for prime number generation Let's code and hope…
Q: the four main advantages of using continuous event simulation
A: Answer Continuous event simulation is a type of computer simulation that models the behavior of a…
Q: When the cursor is on the first letter of a word in vim, you may capitalize it by typing x, then p.…
A: Solution: Given, When the cursor is on the first letter of a word in vim, you may capitalise it by…
Q: When we say something is "IT," what exactly do we mean
A: Information technology (IT) is the utilization of any PCs, stockpiling, organizing and other actual…
Q: In a computer network with a star architecture, each individual node has a direct connection to a…
A: Introduction: A computer network is a collection of interconnected devices that are capable of…
Q: What does it mean to "debug" a program when talking about software development?
A: According to the information given:- We have to define What does it mean to "debug" a program when…
- 2 . The statement in a called function is used to pass the value of an expressionback to the calling function. True False 3 . Evaluate !(1 && !(0 || 1)). a. True b. False c. Unevaluatable 4 . _____ Keyword introduces a structure declaration. True False 5 . A function may contain more than one return statements. True False 6 . _____ Keyword introduces a structure declaration. True False 7 . Same names can be used for different functions without any conflict. True False 8 . The variables commonly used in C functions are availableto all the functions in a program. True False 9 . Members of different structures must have unique names. True False 10 . How can we return control from a called function to the caller function a. struct b. return c. printf arrow_forward Language: JAVA Script write a function called 'dynamicAdder (num). The dynamicAdder function will return a new function that will allow us to create new separate customadding functions. Look below to see how this function is invoked: const addTwo = dynamicAdder (2); // returns a functionconsole.log(addTwo (5)); // 7 const addTen = dynamicAdder (10); // returns a functionconsole.log(adden(5)); // 15 const addNinety= dynamicAdder (90); // returns a functionconsole.log(addNinety (5)); // 95 *********************************************************/ function dynamicAdder(num) { |// Your code here} /****DO NOT MODIFY ANYTHING UNDER THIS LINE****/ try{| module.exports = dynamicAdder;}catch (e) {|module.exports=null;} arrow_forward In C programming Create a structure called Car with the fields string brand int speed in km/hr. Create a function timeCar that accepts a Car type of parameter and a distance in km. Return the time needed for the car to reach the distance in minutes. In the main function, create a Car instance called car1 and ask the user to input the details for the car1's brand and speed. Also ask for an integer input, distance, then call the timeCar function while passing in the car1 instance and the inputted value of distance. Print the return value and interpolate it in this sentence: "It will take a Lopus car [ time_in_minutes ] minutes to reach a distance of [ distance ] ." Input 1. One line containing a string brand 2. One line containing an integer speed in km/hr 3. One line containing an integer distance in km Output Enter brand: Lopus Enter speed: 70 Enter distance: 140 It will take a Lopus car 120 minutes to reach a distance of 140. arrow_forward
- In C++Using the code provided belowDo the Following: Modify the Insert Tool Function to ask the user if they want to expand the tool holder to accommodate additional tools Add the code to the insert tool function to increase the capacity of the toolbox (Dynamic Array) USE THE FOLLOWING CODE and MODIFY IT: #define _SECURE_SCL_DEPRECATE 0 #include <iostream> #include <string> #include <cstdlib> using namespace std; class GChar { public: static const int DEFAULT_CAPACITY = 5; //constructor GChar(string name = "john", int capacity = DEFAULT_CAPACITY); //copy constructor GChar(const GChar& source); //Overload Assignment GChar& operator=(const GChar& source); //Destructor ~GChar(); //Insert a New Tool void insert(const std::string& toolName); private: //data members string name; int capacity; int used; string* toolHolder; }; //constructor GChar::GChar(string n, int cap) { name = n; capacity = cap; used = 0; toolHolder = new… arrow_forward done in c++ Program Specifications: Write a program that asks for a user's name and age, finds the ticket price based on the age, and prints out the user's name, age, and ticket price. The program must define the following 3 functions and call them in the main function. Create a function called getName that takes in no arguments and returns the name of the user. Create a function called getAge that takes in the argument age and uses pass-by-reference to set the age of the user. Ensure that the user cannot put in an age that is negative or greater than 100. Create a function called printTicket that takes in the user's name and age and does the following ○ If they are less than or equal to 13 years old set ticket_Price to 9.99. ○ If their age is greater than 13 and less than 65, set ticket_Price to 19.99. ○ If their age is greater than or equal to 65, set ticket_Price to 12.99. ○ Output to the console the user's name, age and ticket price. arrow_forward C Programming: Need help in how to create the code instrumentation in c. We will rely on gcc's option -finstrument-functions to execute code to collect data at the start and end of invoking any function in a program. This is also called code profiling. For this, you need to implement the following functions in this unit: void __cyg_profile_func_enter(void *this_fn, void *call_site); void __cyg_profile_func_exit(void *this_fn, void *call_site); When we compile our programs with the above-mentioned option, function__cyg_profile_func_enter() will be called at the beginning of all functions in our program and function __cyg_profile_func_exit() will be called at the end of those functions. Parameters this_fn and call_site indicate pointers to the code segment that refer to the profiled function and the instruction that has invoked the profiled function. We can implement various functionalities using these enter/exit functions to help us analyze the function calls in our program. In this… arrow_forward
- Create a structure RationalNumber with two member variables p and q. Write the following functions for manipulating the rational numbers. 1. Add: Returns the sum of two rational numbers in reduced form. 2. Subtract : Returns the difference of two rational numbers in reduced form. 3. Multiply : Returns the product of two rational numbers in reduced form. Do not print anything insdie the function. IN C++ arrow_forward In C++, please write a program according to the instructions and all the criteria. Thank you. Instruction Write and test a function that returns a copy of its string parameter with no repeated characters. The functions ignore case when they compare letters. The functions return strings whose letters are upper case. Write 2 versions of the function: string remDups(const string& original); void remDups(const string& original, string& nodups); Suppose the original string is “Myrtle has big feet” The function returns MYRTLE HASBIGF Test the functions thoroughly. Criteria compile, run, test the test program compiles, runs, and calls both versions of the function without crashingthe test program tests the functions thoroughly function parameters and returns one function has one constant string reference parameter and returns a stringone function has one constant string reference parameter, one string reference parameter and returns void. function operations the function removes… arrow_forward 5 . A function may contain more than one return statements. True False 6 . _____ Keyword introduces a structure declaration. True False 7 . Same names can be used for different functions without any conflict. True False 8 . The variables commonly used in C functions are availableto all the functions in a program. True False 9 . Members of different structures must have unique names. True False 10 . How can we return control from a called function to the caller function a. struct b. return c. printf arrow_forward
- Write in c language: Given main(), build a struct called BankAccount that manages checking and savings accounts. The struct has three data members: a customer name (string), the customer's savings account balance (double), and the customer's checking account balance (double). Assume customer name has a maximum length of 20. Implement the BankAccount struct and related function declarations in BankAccount.h, and implement the related function definitions in BankAccount.c as listed below BankAccount InitBankAccount(char* newName, double amt1, double amt2) - set the customer name to parameter newName, set the checking account balance to parameter amt1 and set the savings account balance to parameter amt2. (amt stands for amount) BankAccount SetName(char* newName, BankAccount account) - set the customer name void GetName(char* customerName, BankAccount account) - return the customer name in customerName BankAccount SetChecking(double amt, BankAccount account) - set the checking account… arrow_forward Invoking a function that takes many arguments, the order in which parameters are supplied is crucial. arrow_forward Write a C program thatdemonstrates nested structures and passing a structure to a function.Create a structure called Members. The structure should have the following variables: a. Member ID (Student ID)b. Namec. Aged. Email addresse. Phone numberf. Programme codeg. Programme nameh. Programme major (Programming, Networking, etc.) Create a function named “GetMemberData” which is to be passed an instance of theMember structure as its argument value. The structure instance is to be initialized withvalues and returned to the main function.Create another function which is to display the values in the returned structure if themember’s age is greater than 21. arrow_forward
- printf scanf
- Preprocessor
- Data Structure
- Search Sort
- Wide Character String
For statement « Statement « C Tutorial
- For statement
How can I get my program to print out its statements correctly?

I'm writing a program that asks how many pennies, nickels, dimes, and quarters a user has. The user will then put in how much they have and the program will print how much money they have in total and then a statement right after that. For some reason, my program is not outputting the statement and I don't know why. Can someone help, please?
How many pennies do you have? 3 How many nickels do you have? 2 How many dimes do you have? 1 How many quarters do you have? 2
The dollar value is $0.73 You can barely buy a soda.
Here is my code so far:

Is the program waiting for you to type another number?
Oh, wow I didn't see that. Thank you!
I know you've resolved you question, but as a few small things I noticed:
You're have the statement using namespace std; at line 2. This incorporates an "unqualified lookup" to the "C++ Standard Library" "namespace". In basic terms, this means you don't have to use std:: in front of all the function calls you're using (e.g. cin => std::cin ; endl => std::endl ) because these calls are grouped by the "namespace" std . At this point in your learning you can think of the using statement as a contraction (i.e. you don't have to type std:: ).
By how your program reads, you could replace all std::cin statements with simply cin . I will note that there is some agreement that the statement using namespace std; is bad practice and that all "C++ Standard Library" should always be prefixed by the std namespace.
The second is the chain of if else statements at the bottom. Consider that, if you checked for total >= 5 first, you wouldn't have to check for total >= 2.00 && total < 5.00 --rather you could simply check total >= 2.00 . Just some small flavor to consider.
Best of luck.
I strongly suggest to keep your money in some large integer, as cents, and convert to dolars ( by dividing by 100) and cents (modulo 100) only for printing. Floating point numbers are unreliable. 0.05 *2 MIGHT NOT be 0.10 but something close
About Community

Master Coders
Reading Holy Scripts
Ranked by Size

Using MySQL with SQLAlchemy: Hands-on examples
SQLAlchemy is a popular Python library that gives you many tools to interact with SQL databases. With SQLAlchemy, you can do things like send raw queries to a database, programmatically construct SQL statements, and even map Python classes to database tables with the object-relational mapper (ORM). SQLAlchemy doesn't force you to use any particular features, so it has the flexibility to support many different approaches to working with databases. You can use SQLAlchemy for one-off scripts, web apps, desktop apps, and more. Anywhere that you'd use a SQL database along with Python, you can use SQLAlchemy.
This tutorial will cover setting up an engine object in SQLAlchemy 2.0, which is the first step to using SQLAlchemy. Then it will cover two specific ways of interacting with a database: with raw SQL statements and by using the object-relational mapper.
This tutorial covers the most recent version of SQLAlchemy, which is now 2.0. After running pip install sqlalchemy , you can run pip list to verify your SQLAlchemy version is greater than 2.0.
Set up PlanetScale database #
To demonstrate the examples in this tutorial, you'll need a MySQL-compatible database. If you don't have one already, you can get a free database by signing up for a PlanetScale account .
Once you have an account and are on the dashboard, create a new database by doing the following:
- Click the "Create" link at the bottom of the dashboard.
- Give your database a name.
- Select a region.
- Click the "Create database" button.
- Finally, you can click on the "Connect" button and select "General" in the dropdown to see your database credentials. You'll need these credentials to create an engine in SQLAlchemy.

PlanetScale uses a branching workflow , similar to git, so you can branch off of your production database when you need to make schema changes. This workflow lets you easily test changes before merging them into your production schema (again, very similar to what we're used to when deploying code changes). For this tutorial, you can just use the default initial branch, main , for development.
Set up the engine object #
The first thing to do when using SQLAlchemy is to set up the engine object. The engine object is used by SQLAlchemy to manage connections to your database. Later, when you go to perform some action on the database, a connection will be requested from the engine and used to send the request.
Before creating the engine, you first need to know the credentials of your database along with the database driver you'll use to connect to the database. For MySQL, connection strings look like this:
Install the database driver
Since SQLAlchemy works with many different database types, you'll need an underlying library, called a database driver, to connect to your database and communicate with it. You don't have to use this driver directly, because as long as SQLAlchemy has the correct driver, it will automatically use it for everything. MySQL Connector is used as the driver in this tutorial, but other good ones are PyMySQL and MySQLdb .
You'll need to install your driver with pip.
So let's say your username, password, hostname, port, and database name are user1 , pscale_pw_abc123 , us-east.connect.psdb.cloud , and 3306 , respectively. Your connection string would look like the following if you were using mysqlconnector as your driver to connect to a database named sqlalchemy.
Create SQLAlchemy engine object
Once you have your driver installed and your connection string ready to go, you can create an engine like this:
Typically, you don't need echo set to True , but it's here so you can see the SQL statements that SQLAlchemy sends to your database.
If you run the code and get no errors, then SQLAlchemy has no trouble connecting to your database. If you get an error like "access denied" or "server not found," then you'll need to fix your connection string before proceeding.
With the engine object working, you can then continue with SQLAlchemy in various ways. This article covers how to use it to send raw queries to your database and how to use it as an ORM.
Raw SQL statements in SQLAlchemy #
Now that we have our engine object working let's use it to send raw SQL statements to the database and receive the results in return.
Create a connection object
To start sending queries over, you'll need to create a connection object. Since the engine manages connections, you need to ask the engine for a connection before you can send statements over to the database.
We need to call engine.connect() to get a connection, and because the connect method is defined with a context manager, we can use a with statement to work with the connection.
Now that you have the connection, you can execute any SQL statement that works on your database by importing the text function from SQLAlchemy. You then pass the query as a string to the text function and then finally pass the text function to connection.execute() .
Create a table
To create a table, you can run the following code:
If you run that and get no errors, that means the table was created. If you try to run the code again, you'll get an error saying the table already exists.
You can also go back to your PlanetScale dashboard to confirm the table was added. Click on your database, click "Console", connect to your branch, and run the following:

Add data to a table
Next, let's insert some data into our new table.
The first execute statement will create just one row because a single dictionary was passed. But the second statement will create two rows since a list of two dictionaries was passed. Just make sure the keys in the dictionary match the placeholders you have with a colon in front of the name.
Even though we aren't dealing with user input here, it's still a good idea to make a habit of passing in parameters instead of the data directly inside of an insert statement or select statement.
Unlike CREATE statements, INSERT statements happen in transactions, so we have to save them to the database by calling .commit() after we execute our insert statements.
Finally, now that we have some data in the database, let's go ahead and query that data so we can see it again. We can assign the result of connection.execute() to a variable called result, and if we loop over result.mappings() , we'll see that we get dictionaries for each row, where the key in each dictionary represents the column name. This makes it easy for us to retrieve the data and display it in a loop.
As you can see, you only need to know a few things to write raw queries using SQLAlchemy. If you want to use it as an ORM, you can do that as well.
Using SQLAlchemy ORM to write queries #
The idea behind ORM (object-relational mapping) is to create a code representation of your database using classes and objects instead of writing raw SQL statements. The classes represent the tables in your database, and the objects of those classes represent rows. So the first step to using ORM is to define classes that map to your tables. Classes that represent tables in an ORM are called models.
Before we can do the mapping, we need something called the DeclarativeBase from SQLAlchemy. Even though our classes could inherit directly from DeclarativeBase , we will instead create our own Base class that inherits it and then call pass . This makes it easy to add additional settings to our Base class in the future since all of our models will inherit from this one.
Create models
Now we can create our models. Let's first create an Author model which will map to an author table. The idea here is to first define a tablename, which is the attribute __tablename__.
Define the columns
Next, we need to define the columns. Starting in SQLAlchemy 2.0, we can use the Python typing system to define the columns for us. So the format of each column is the name of the column, followed by a class called Mapped with the Python type that closest matches the type you want in the database.
So for an ID column, we would have id: Mapped[int] . Next, that attribute is going to be set equal to the mapped_column function call, where we could set additional properties on our column like primary key, max length, nullable, etc.
So let's create an Author model with two fields: id and name , which means we'll have a table with two columns. SQLAlchemy requires each model to have a primary key so it can internally keep track of each object, so let's make ID the primary key.
Handling relationships and foreign keys
Next, let's create a Post model, which will have a relationship to the Author model. We can create an author_id column inside of Post that holds the reference to the author who created the post. For most database systems, you'd pass ForeignKey to mapped_column to create an actual foreign key restraint in the database. But with PlanetScale, we can't use foreign key constraints . However, we can still use SQLAlchemy to manage the relationship for us.
Since databases with foreign keys are very common, variations for those databases are included in the commented-out lines.
The advantages of having no foreign keys are we can have multiple versions of our database schema in the same way we have multiple versions of code through things like git branches. It also allows us to make schema changes to production databases without any downtime. And finally, it makes it easier to scale the database through sharding.
But even without a foreign key, we can still have a relationship between two tables. To get SQLAlchemy to manage the relationship for us, we can create a relationship attribute. Unlike the attributes for the columns, no column gets created in the database. Instead, the relationship only exists in our code while it's running.
So we can add a relationship attribute and the type will be a list of Author classes, which we can pass to the Mapped class as the type.
Since we're not using ForeignKey , we need to tell SQLAlchemy how to handle our relationship. We can do that we the primaryjoin argument to relationship. If we used a database with foreign keys, then the ForeignKey being passed to the mapped_column would be enough.
We can also create a Tag model in a similar way. This Tag model represents tags that each post could have.
Because one post can have many tags and one tag can belong to many posts, we need to create a many-to-many relationship. We can create a post_tag table to represent this relationship. Many-to-many relationships have the foreign key stored in a separate table called an association table. We can create that table directly in SQLAlchemy. You could also use a model for this, but it's better to use a table because you won't be working with this table directly. Instead, SQLAlchemy will automatically manage the data in this table for you by using the relationships you define.
You can create the table like this:
Create tables with create_all()
Now that we have the Tag table defined, to create the tables in the database, you can call create_all on your Base class. The create_all call takes an engine object, so you can reuse the one we created earlier.
Create_all will take about DeclarativeBase and instruct it to create statements for each one of our tables and add them to the database. You'll see that printed to your terminal when you run.
With our tables created, we can go ahead and insert data into the tables and then query the tables.
Since we're working with the ORM, the way to create new rows is first by creating objects. So for example, to create a new Author , we can instantiate an author object.
For relationships, we can set one object to be related to another when we instantiate the related object. We want to use the relationship attribute instead of the _id field directly because SQLAlchemy will take care of the ID field for us. For many-to-many relationships, we append to the relationship attribute like it's a Python list. We only need to append children of the relationship.
To add them to the database, we need to first add them to the session. Finally, we need to call commit to save them to the database. When you run the script, you'll see the actual insert statements being printed.
Query the data
Now that we have some data in the database, we can go ahead and query that data. First, we write our query statement.
Start by passing your Model call to the select function. Then you have the option to use the where attribute on the resulting object. We can then pass all of that to session.scalar to run the query. With the result of scalar, we can print out the results to the terminal. We can also look at the values in the relationship. For each post, we can look at the tags as well.
If you want to leave out the where and get all of the posts, you will use scalars instead of scalar . Then we can loop over the object returned and print out all the titles.
Conclusion #
With your new knowledge of SQLAlchemy, you should have a good starting point to continue using it in any Python project that uses a SQL database. As long as you can set up the engine object, you'll be able to decide whether you want to simply send raw SQL statements, construct SQL statements using the SQLAlchemy API, or map your Python classes and objects to your database tables and data.
Want a performant MySQL database that branches, scales, and reverts?
Improvements to database branch pages
Your business deserves a predictable database.
Never worry about another 3am wake-up call saying the site is down. Give your engineers the power they deserve with a PlanetScale database today.
Junos 2023 reminds us how Canadian content regulations and funding supports music across the country

Associate Professor Popular Music and Media Studies, University of Alberta

Assistant Professor, Media and Popular Culture, Department of Communications, University of California, San Diego

Scholarly Communications & Copyright Librarian, University of Winnipeg
Disclosure statement
Brian Fauteux has received past funding from SSHRC.
Andrew deWaard has received past funding from SSHRC.
Brianne Selman has received past funding from SSHRC.
University of Alberta and University of Winnipeg provide funding as founding partners of The Conversation CA.
University of Alberta and University of Winnipeg provide funding as members of The Conversation CA-FR.
University of California, San Diego provides funding as a member of The Conversation US.
View all partners
As we celebrate another year of Canadian music at the Juno Awards , let’s consider the broader music ecosystem that facilitates a vibrant component of our multifaceted culture and identity.
An essential component of this ecosystem supporting musical artists has been the policy of Canadian Content (CanCon) regulations for music radio.
CanCon policy hasn’t only ensured Canadian music is played on the radio, but notably, that radio profits are redistributed to artists through grant programs — something critical for artists’ viability and success .
Revitalization in digital era
Currently, there is debate on how to implement similar regulations for streaming media. Bill-C11, An Act to amend the Broadcasting Act and to make related and consequential amendments to other Acts has been passed by the Senate (with contentious amendments), and is now being debated in the House .
The few large multinational corporations that make use of Canada’s creative sector should also contribute to the public funding of the arts, contributing to the revitalization of music in Canada in the digital era.

Music industry highly consolidated
On one hand, the music industry in Canada is highly consolidated, with three record labels (Universal, Warner, Sony), three streaming companies (Spotify, Apple Music, Amazon Music), and one live concert and ticketing company (LiveNation/Ticketmaster).
They are all non-Canadian. They have market power that shapes the industry to favour superstars, lessens the ability of working musicians to make a living wage and limits the diversity of Canadian music.
On the other hand, public programs support diverse Canadian music heritage and the development of Canadian artists. This year’s Juno nominees include at least 85 artists who have received a total of 433 grants from FACTOR (The Foundation Assisting Canadian Talent on Recordings).
Read more: Junos 50th anniversary: How we remember these award-winning hit singles
FACTOR, along with public and community radio, the Polaris Prize, provincial music industry associations and other public-serving organizations and regulations help ensure the diversity and abundance of music outside of the purely profit-driven system.
Bill C-11 has potential to address the limitations of the corporate music model and provide musicians with more opportunities to earn a livelihood by increasing opportunities for grants. But these concerns have been overshadowed by the sprawling nature of the bill and its legislative amendment process.
Bill C-11 proposes an update to the Broadcasting Act to include online platforms in CRTC regulation and CanCon rules.
In terms of streaming music (like on Spotify or Apple Music), this would mean including music by Canadian artists on the curated playlists provided by the platform, and companies paying in to a media fund that would provide grants for Canadian artists.
Algorithms are not neutral : they train us as much as we train them. Using them to promote local music or Canadian music may inspire a wider variety of music heard on streaming services.
Regulations done properly
Some critics say C-11 would cause financial hardship and unintended consequences for content creators and open the door for CRTC interference in freedom of expression and lead to government control over social feed algorithms.
Many remain unconvinced that the centralization of regulation is worth the overreach of the bill.
Researchers in public policy and communications have amplified some creators’ concerns that given the role of broadcasting as a settler nation-building project entrenched in systemic racism, new policy would need to do more to safeguard interests of Black, Indigenous and racialized content creators .
Major Senate change
A major Senate amendment proposed limiting the bill to maintain the autonomy of individual creators posting online, and curbing the CRTC’s discretionary power .
But Pablo Rodriguez, Minister of Canadian Heritage, has rejected Senate amendments and the process is yet again under fire.
The non-profit Open Media dedicated to “ keeping the internet open, affordable and surveillance-free ,” notes a key Senate amendment “considerably reduces the risk of ordinary Canadian user-uploaded content being regulated as broadcasting content ” but flags problems with how age restrictions on content would be managed.
It’s good to have critics ensure regulations benefit all artists and users and that the bill does not tell people what to create . Yet much of the writing on C-11 has dismissed CanCon regulations for the streaming era altogether.
Read more: Should we be forced to see more Canadian content on TikTok and YouTube?
Why CanCon matters
In radio, CanCon refers to regulations that began in 1971. By playing more music by Canadians on the radio (initially 30 per cent Canadian music over the broadcast week, now at least 35 per cent ), the aim was to grow domestic music industries.
In the same era, major labels invested in Canadian record pressing plants to help overcome the costs of importing records.
By the end of the 1970s, evidence of music industry growth in Canada was apparent, with more recording taking place in studios and an increase in performance royalties being paid to songwriters .
Music grants for artists
Two avenues of support for artists in Canada are campus/community radio and grants, often from FACTOR.
Our research found artists overwhelmingly emphasize the importance of grants to their careers. While some note barriers to access with writing and receiving some grants, grant funding remains crucial.
Both the Community Radio Fund of Canada and FACTOR receive money from Canadian Content Development (CCD) contributions . These come from commercial radio stations with annual revenue above $1,250,000. English-language stations that meet this criteria pay $1,000 plus half a per cent on all revenues above $1,250,000.
To support music in Canada, corporate music streaming services should pay into CCD funds.
Lower charting success
Our research has documented a decline in the number and variety of charting artists and songs today in Canada which coincides with lower charting success of Canadian artists. This can be correlated to a lack of CanCon regulations in streaming, versus in the 90s when CanCon regulations affected how Canadians listen to music.
In satellite radio, CanCon regulations mean a certain per centage of channels must be Canadian . While these regulations aren’t perfect (Canadian channels are grouped together far down the channel lineup), artists have benefitted from royalties.
This was made evident in the uproar surrounding the cancellation of CBC Radio 3 on SiriusXM, a channel that was a stable source of income for artists and labels.
Beyond reforms to C-11, we argue guidelines governing corporate mergers should centre the concerns of workers and consumers, benefiting many sectors in Canada, including music.
Both government actions would help address the most immediate danger facing Canadian music today: media consolidation.
- Apple Music
- Music streaming
- Canadian music
- juno awards
Want to write?
Write an article and join a growing community of more than 160,800 academics and researchers from 4,574 institutions.
Register now

How To Write A Resignation Letter
- March 8, 2023
- Lisa Wachuku
- Career , Coaching , Resignation
If you have decided to leave your current job, the next step is to write a resignation letter. Writing a resignation letter may seem like a daunting task, but it is an important part of the process of leaving your job on a positive note. A resignation letter is a formal document that informs your employer of your decision to leave the company. In this blog post, we will provide you with a step-by-step guide on how to write a resignation letter.
Step 1: Plan Ahead
Before you start writing your resignation letter, it is important to plan ahead. Take some time to think about your decision to leave and the reasons why you are resigning. This will help you to compose a clear and concise letter. You should also consider the timing of your resignation and ensure that you are giving your employer enough notice.
Step 2: Address the Letter
Your resignation letter should be addressed to your immediate supervisor or manager. It is important to use the proper salutation and address the person by their name. If you are unsure of the person’s name, you can address the letter to “Dear [Job Title]” or “To Whom It May Concern.”
Step 3: Begin with a Formal Statement
Your resignation letter should begin with a formal statement that clearly states your intention to resign. For example, “I am writing to inform you that I have decided to resign from my position as [Job Title] at [Company Name].”
Step 4: Provide Your Reason for Resigning
In the next paragraph, you should provide your reason for resigning. This is an optional step, but it is a good opportunity to provide feedback to your employer. You can explain that you are leaving to pursue a new opportunity, to focus on personal goals, or because of personal circumstances. You should be honest but professional in your explanation.
Step 5: Express Gratitude
Express your gratitude for the opportunities you have had at the company. This is a chance to acknowledge the support and guidance you have received from your colleagues and superiors. You can also mention the skills and experience you have gained during your time at the company.
Step 6: Offer to Help with the Transition
In the final paragraph of your resignation letter, you should offer to help with the transition. This can include training a replacement or assisting with the handover of your duties. This shows that you are committed to ensuring a smooth transition and leaving on a positive note.
Step 7: Close the Letter
Close the letter with a formal closing, such as “Sincerely” or “Best Regards,” followed by your name and signature. If you are sending the letter via email, you can include your contact information in your signature.
Sample Resignation Letter
Dear [Manager’s Name],
I am writing to inform you that I have decided to resign from my position as [Job Title] at [Company Name]. My last day of work will be [Date].
I have accepted an offer from another company that will allow me to pursue my long-term career goals. I have enjoyed my time at [Company Name] and appreciate the opportunities I have had to develop my skills and experience.
I want to express my gratitude for the support and guidance provided by my colleagues and superiors during my time at the company. I have learned a great deal from working here and will always value the experience.
I am committed to ensuring a smooth transition and am willing to assist with the handover of my duties. Please let me know how I can best help during this time.
Thank you for your understanding and support during this transition. Please let me know if there is anything else I can do to assist.
Writing a resignation letter can be challenging, but it is an important part of the process of leaving your current job on a positive note. It is important to remember that your resignation letter will become a part of your employment record. Therefore, it is essential to approach the task with a positive attitude and ensure that the letter reflects your appreciation for the opportunities you have had at the company.
In addition, it is important to consider the timing of your resignation. In general, it is recommended that you give your employer at least two weeks’ notice. This allows your employer to make arrangements for your replacement and ensure a smooth transition.
Finally, it is important to be prepared for the possibility that your employer may ask you to stay or counteroffer with a better package. If this happens, it is important to evaluate your options carefully and consider the long-term implications of your decision.
In conclusion, writing a resignation letter is an important step in the process of leaving your current job. By following the steps outlined in this blog post, you can ensure that your resignation letter is professional, respectful, and reflective of your appreciation for the opportunities you have had at the company. Good luck with your new endeavors!
Contact us if you are looking for a customized approach to your career needs.
Related Posts

A federal resume is a type of resume used specifically for applying to federal government…

Spring break is a time for students to take a break from their studies and…

Population as of 2020: 2,138,926 We compiled a list of the top employers in the Columbus,…
- previous post: Top Employers in Columbus, OH
- next post: How Does Spring Break Affect Your Job Search?

IMAGES
VIDEO
COMMENTS
C programming has three types of loops: for loop while loop do...while loop We will learn about for loop in this tutorial. In the next tutorial, we will learn about while and do...while loop. for Loop The syntax of the for loop is: for (initializationStatement; testExpression; updateStatement) { // statements inside the body of loop }
The syntax of the if statement in C programming is: if (test expression) { // code } How if statement works? The if statement evaluates the test expression inside the parenthesis (). If the test expression is evaluated to true, statements inside the body of if are executed.
In this article, you will learn about how to write a C program with our step by step guidelines. Learn about programming practice, process and standards. ... Proper way for construction of statements. While writing code, your statement should be simple and direct with proper indentation. Try to use one statement per line.
1. While Loop. In while loop, a condition is evaluated before processing a body of the loop. If a condition is true then and only then the body of a loop is executed. 2. Do-While Loop. In a do…while loop, the condition is always executed after the body of a loop. It is also called an exit-controlled loop. 3.
The conditional operator is kind of similar to the if-else statement as it does follow the same algorithm as of if-else statement but the conditional operator takes less space and helps to write the if-else statements in the shortest way possible. Syntax: The conditional operator is of the form variable = Expression1 ? Expression2 : Expression3
The nice thing about the ternary operator is that it's an expression, whereas the above are statements, and you can nest expressions but not statements. So you can do things like ret = (expr ? a : b) > 0; As an extra tidbit, Python >=2.6 has a slightly different syntax for an equivalent operation: a if expr else b.
The if Statement Use the if statement to specify a block of C++ code to be executed if a condition is true. Syntax if (condition) { // block of code to be executed if the condition is true } Note that if is in lowercase letters. Uppercase letters (If or IF) will generate an error.
Example 1: Take a number and apply some of the conditions and print the result of expression containing logical OR operator. #include <stdio.h> int main() { int num =10; printf("%d\n",( num ==10 || num >=5)); printf("%d\n",( num >=5 || num <=50)); printf("%d\n",( num!=10 || num >=5)); printf("%d\n",( num >=20 || num!=10)); return 0; } Output
Write the cin statement. First declare a variable. Then write a cin statement to define a value for the variable as shown. When the program runs, the input that user enters will be assigned to the variable. Note that the cin statement does not output any text onto the monitor. 3 Combine cin and cout statements.
Most statements in a typical C program are simple statements of this form. Other examples of simple statements are the jump statements return, break, continue, and goto.A return statement specifies the return value for a function (if there is one), and when executed it causes the function to exit immediately. The break and continue statements jump immediately to the end of a loop (or switch ...
C has four types of jump statements. The first, the goto statement, is used sparingly and has the form. goto identifier ; This statement transfers control flow to the statement labeled with the given identifier. The statement must be within the same function as the goto . The second, the break statement, with the form.
The basic type in C includes types like int, float, char, etc. Inorder to input or output the specific type, the X in the above syntax is changed with the specific format specifier of that type. The Syntax for input and output for these are: Integer: Input: scanf ("%d", &intVariable); Output: printf ("%d", intVariable);
Computer Science questions and answers. Write a single statement of \ ( C \) code to declare an array called foo of type int that has size 10 (i.e., it has 10 entries in the array), and initialize those 10 entries to be the first 10 perfect squares (i.e., 1, 4, 9, etc.). Write the C code to declare an array called foo of type pointer-to-char ...
The syntax of an 'if' statement in C programming language is − if (boolean_expression) { /* statement (s) will execute if the boolean expression is true */ } If the Boolean expression evaluates to true, then the block of code inside the 'if' statement will be executed.
The assignment operator assigns a value to a variable. 1 x = 5; This statement assigns the integer value 5 to the variable x. The assignment operation always takes place from right to left, and never the other way around: 1 x = y; This statement assigns to variable x the value contained in variable y.
The syntax for a switch statement in C programming language is as follows − switch(expression) { case constant-expression : statement(s); break; /* optional */ case constant-expression : statement(s); break; /* optional */ /* you can have any number of case statements */ default : /* Optional */ statement(s); }
In C++, please write a program according to the instructions and all the criteria. Thank you. Instruction Write and test a function that returns a copy of its string parameter with no repeated characters. The functions ignore case when they compare letters. The functions return strings whose letters are upper case.
For statement « Statement « C Tutorial. C Tutorial; Statement; For statement; 6.6.For statement: 6.6.1. for LOOP: 6.6.2. Omit all three parts in for loop: 6.6.3. The for loop with a comma operator: 6.6.4. Initialize loop control variable outside the for statement: 6.6.5. Use for loop to print a rectangle: 6.6.6. Sum integers in for statement:
You're have the statement using namespace std; at line 2. This incorporates an "unqualified lookup" to the "C++ Standard Library" "namespace". In basic terms, this means you don't have to use std:: in front of all the function calls you're using (e.g. cin => std::cin; endl => std::endl) because these calls are grouped by the "namespace" std.
Click the "Create" link at the bottom of the dashboard. Give your database a name. Select a region. Click the "Create database" button. Finally, you can click on the "Connect" button and select "General" in the dropdown to see your database credentials. You'll need these credentials to create an engine in SQLAlchemy.
Write capability statement for cleaning company Search more . Other Content Writing jobs. Posted Only freelancers located in the U.S. may apply. U.S. located freelancers only Someone keeps asking me for a capability statement, and I need help with writing one for my cleaning business. Less than 30 hrs/week ...
English-language stations that meet this criteria pay $1,000 plus half a per cent on all revenues above $1,250,000. To support music in Canada, corporate music streaming services should pay into ...
Step 2: Address the Letter. Your resignation letter should be addressed to your immediate supervisor or manager. It is important to use the proper salutation and address the person by their name. If you are unsure of the person's name, you can address the letter to "Dear [Job Title]" or "To Whom It May Concern.".