100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Condition statment in C language £5.49   Add to cart

Exam (elaborations)

Condition statment in C language

 2 views  0 purchase

Condintions, If Elseif and Switch.

Preview 2 out of 8  pages

  • March 22, 2023
  • 8
  • 2022/2023
  • Exam (elaborations)
  • Unknown
All documents for this subject (8)
avatar-seller
micheleaccordino
SOLENT UNIVERSITY




Fig5-Task1-GradeA

In figure 6 the user input ‘a’ = 15 and ‘b’ = 9 and press 4 for subtraction as it is showing below.




Fig6-Task1-GradeA

In figure 7 is showing if the user enters any other number that is not an option the program will show the
message “Please enter 1 to 4 only.”




Fig7-Task1-GradeA

Assessment 2
Introduction of Conditional Statement

Conditional statement is using in programming to run a determinate condition. When the condition is true the
program will print the allocated end statement. For example if the 2nd of January is Monday the end statement
will say ‘It’s Bank Holiday, extra day off’ but if false the condition the program run a different code that say
‘Sorry, you need to go back to work’. In this case we can take in consideration two type of Conditional
Statement; If statement and Switch statement.
If statement, as we said before is using to check if a specific condition is true or false and execute when is
True but in a multiple conditional Switch statement is used more often as the performance are more efficient.
Switch statement is working in a different way, as it takes the given value and check inside the case if there is
a match. It is divided by case and for each of them there is a break; that will stop to check the condition when
it is true and print the allocated end statement. Both Conditional statements are used in this Assessment but
let’s give an example for each of them.

10

, SOLENT UNIVERSITY

Example of If statement:
Start

Condition

If true end statement

false

Else If true end statement

false

Else end statement

How we can see If statement simply working in this way, when the condition is true go straight to the end
statement of If, if it is false go to the next and print Else condition. Else is used when there are not condition
true, then the system will execute Else. For each of them there is a different statement that will be print. See
grade D to B for explanation how the program will print out when reach the condition.

Example of Switch statement:
Start

Condition

Case 1= true /break;
false

Case 2= true /break; End statement
false

default End Statement

How we can see for Switch Statement the condition will be checked if it is equal to the case if one of them is
true will print the end statement. Each case in switch has a break; to tell the program to stop to check other
condition. It’s recommended to use after the case a default for not have any issue in case that all of them are
false. Default is like Else in If statement, when all the case are false the program will execute the default
option. See grade A where switch statement has been used, it will give a visual understanding how the
program works in this conditional statement. (Gookin, 2004)
Grade D
This task requires to create a program that it will ask the user to select four options and after that it will
calculate the fees that the user will pay. The options are char, so for make sure that the program run properly
let’s give a space after the first quotation mark in scanf.
On the options the user can use ether uppercase or lowercase characters.
The program in option two to four it will multiplicate the cost for the allocated percentual fee. Also, to round
and take the two number after the point it has been used %.2 before the ‘f’ as float number.
%. and ‘X’ number after, it counts how many numbers needs to print after the dot. For example for show
25.64 is %.2f.




11

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller micheleaccordino. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for £5.49. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

57114 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy revision notes and other study material for 14 years now

Start selling
£5.49
  • (0)
  Add to cart