Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Examen

C programming operations

Puntuación
-
Vendido
-
Páginas
6
Grado
A+
Subido en
22-03-2023
Escrito en
2022/2023

Coding simple operations

Institución
Grado

Vista previa del contenido

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

Escuela, estudio y materia

Institución
Estudio
Desconocido
Grado

Información del documento

Subido en
22 de marzo de 2023
Número de páginas
6
Escrito en
2022/2023
Tipo
Examen
Contiene
Desconocido

Temas

$6.86
Accede al documento completo:

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Conoce al vendedor
Seller avatar
micheleaccordino

Conoce al vendedor

Seller avatar
micheleaccordino Southampton Solent University
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
1
Miembro desde
3 año
Número de seguidores
0
Documentos
8
Última venta
1 mes hace

0.0

0 reseñas

5
0
4
0
3
0
2
0
1
0

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes