100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
C programming operations £4.49   Add to cart

Exam (elaborations)

C programming operations

 0 view  0 purchase

Coding simple operations

Preview 2 out of 6  pages

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


Operator Example Details
&& (x&&y) Mean AND, the conditions need
to match for be true.
|| (x||y) Mean OR, one of the conditions
need to match to be true.
! !(x&&y) Mean NOT, if the condition is
false , it will be change in true.

Explanation:
If the value of x=-1 and y=3, and the User needs x=-1 and y=2 in the first operator (x&&y) it will false, on
the second (x||y) it will be true and the last !(x&&y) also it will be true.

Relational Operator

Relational operator is using to compare a relation between to value. Let’s use the same value x=-1 and y=3.

Operator Details Example
== Equal to (x==y) is false
> Greater than (x>y) is false
< Less than (x<y) is true
>= Greater than or equal (x>=y) is false
<= Less than or equal to (x<=y) is true
!= Not equal to (x!=y) is true

Escape sequence

Escape sequence is using to make outcome user-friendly and easy to understand without to see number or
letter together when the program print out the code and help the programmer to write comments without
showing to the user.

Escape sequence Details
\n escape sequence is a newline; the cursor will be on the next line.
\t horizontal tab.
// add a comment that doesn’t show to the user but only to the programmer


Note: All the Assessment with a char menu, for user-friendly outcome, the program will take either
uppercase or lowercase.




Assessment 1
Introduction of Variables and Operators

What is a variable in C program? Variables are like an empty square (memory) with one only space that
needs to be fill with a certain value, it can be inserted from the user or just it can be given before, from the

5

, SOLENT UNIVERSITY

programmer. In this first assessment it will be using a different datatype like integer, float, char and double.
Integer in programming language is identify as int and it is a whole positive and negative numbers. int
number = -2,10,65,-7 etc. The name of the int can be anything that it doesn’t recall a programming language
option. Float is used for decimal numbers with a limit of floating number after the point, float equal to
maximum 3.40282347e+38F. When the maximum decimal number is reached it can be use double. double
equal to maximum 1.79769313486231571e+308. For characters is char, char letter = ‘a’,’b’,’c’ etc. How we
can see the letter are between two single quotes to make sure that the program prints them as letter and not as
ASCII code. Now for print them we will use printf(“”);. Remember that printf always needs to be followed
with two brackets first and inside them two quotation marks, one before the text that needs to be print and
one on the end and a semi-colon after the last bracket. Semi-colon determinate that a statement ended and a
new one will start. (Gookin, 2004)

Example:
If we want to print “Hello World, my name is Michele”. We don’t need to create any variable at this stage.
Printf(“Hello World, my name is Michele”);

How we can see the program doesn’t require any variable, but it will only print what is inside the printf. If
we want to print a value give to the variables we will use:
int = %d
char = %c
float = %f
double = %lf

Example:

int x = 38
printf(“Hello, my name is Michele and I am %d years old”,x); The comma x after the last quotation mark
tells the program that %d is equal to int x.

In this case the program will output the value of 38 instead of %d. Let’s if we give two variables and we
want multiplicate them. We can also get an interaction from the user but how we can do that? After storage
an empty variable we can ask the user to enter a value by using scanf(“”); and print out the statement.

Example:

int x
printf(“Hello, please enter your age: “);
scanf(“%d”,&x);
printf(“You are %d years old”,x);

With scanf the user will give a value of x variable and the second printf will show the value that the user
choice. For allocate x value we will need to use all the time comma + ampersand before the name of the
variable, like we did for scanf in the previous example. In the tasks below it is showed how to do simple
operations between variable using operator, like multiplication, division, subtraction, and addition, first with
a pre-decided value and after with the input of the user.

Grade D
In this task is required to give a values of X numbers at two variables, ‘a’ and ‘b’, and execute simple
mathematics operation. The integer ‘a’=15 and ‘b’=5.
Doesn’t required any action from the user, the program will run as it is. For make the outcome user-friendly
escape sequence has been used.

.

6

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 £4.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
£4.49
  • (0)
  Add to cart