Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

C programming operations

Rating
-
Sold
-
Pages
6
Grade
A+
Uploaded on
22-03-2023
Written in
2022/2023

Coding simple operations

Content preview

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

Document information

Uploaded on
March 22, 2023
Number of pages
6
Written in
2022/2023
Type
Exam (elaborations)
Contains
Unknown

Subjects

£4.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
micheleaccordino

Get to know the seller

Seller avatar
micheleaccordino Southampton Solent University
View profile
Follow You need to be logged in order to follow users or courses
Sold
1
Member since
3 year
Number of followers
0
Documents
8
Last sold
1 month ago

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these revision notes.

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and smashed it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions