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

Exam (elaborations)

C language

 3 views  0 purchase

Programming with C language and solving problems

Preview 4 out of 84  pages

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




BSc (Hons) [Foundation]




Michele Accordino

Academic Year 2022-2023




Portfolio




Assignment 1
Submission Date:
3rd February 2023 Before 4pm (UK time)




Unit title: Problem Solving
Unit Code: QHO305
Unit Leather: Dhouha Kbaier




1

, SOLENT UNIVERSITY


Contents
Introduction..........................................................................................................................................3
Logical Operator...........................................................................................................................4
Relational Operator......................................................................................................................5
Escape sequence...........................................................................................................................5
Assessment 1........................................................................................................................................5
Introduction of Variables and Operators...........................................................................................5
Grade D........................................................................................................................................6
Grade C.........................................................................................................................................7
Grade B.........................................................................................................................................8
Grade A.........................................................................................................................................8
Assessment 2......................................................................................................................................10
Introduction of Conditional Statement...........................................................................................10
Grade D.......................................................................................................................................11
Grade C.......................................................................................................................................13
Grade B.......................................................................................................................................14
Grade A.......................................................................................................................................15
Assessment 3......................................................................................................................................17
Introduction of Loops.....................................................................................................................17
Grade D......................................................................................................................................18
Grade C.......................................................................................................................................20
Grade B.......................................................................................................................................22
Grade A.......................................................................................................................................25
Assessment 4......................................................................................................................................27
Grade D......................................................................................................................................27
Grade C.......................................................................................................................................30
Grade B.......................................................................................................................................34
Grade A.......................................................................................................................................36
Assessment 5......................................................................................................................................38
Introduction of Arrays....................................................................................................................38
Grade D......................................................................................................................................39
Grade C.......................................................................................................................................42
Grade B.......................................................................................................................................46
Grade A.......................................................................................................................................54
Differences between getchar(); and scanf();:..............................................................................54
Assessment 6......................................................................................................................................59

2

, SOLENT UNIVERSITY


Introduction to Sorting Algorithm..................................................................................................59
Grade D......................................................................................................................................60
Grade C.......................................................................................................................................61
Grade B.......................................................................................................................................62
Grade A.......................................................................................................................................63
Assessment 7......................................................................................................................................64
Introduction of Function.................................................................................................................64
Recursion....................................................................................................................................65
Grade D......................................................................................................................................66
Grade C.......................................................................................................................................69
Grade B.......................................................................................................................................72
Scope of Variable........................................................................................................................75
Class of Variable.........................................................................................................................75
Grade A.......................................................................................................................................76
Reflecting Report................................................................................................................................80
References..........................................................................................................................................82
Bibliography.......................................................................................................................................83
Appendices.........................................................................................................................................84




Introduction
What is Programming and C language?

3

, SOLENT UNIVERSITY

Programming is a serial of instruction that it is given to the computer. Those must be converted to one of the
languages used in the computer. This process is called compilation and it is using a software application
called compiler. C language is a binary language that the computer understands and one of the most used
programming languages. C was created by Dennis Ritchie at the Bell Laboratories in 1972. C is strongly
associated with UNIX, as it was developed to write the UNIX operating system. For this portfolio will be use
Replit.com but there are other program, like Visual Studio Code. The C program instruction start with the
main function, showed below.

#include <stdio.h>
int main(void)
{printf("Hello World\n");
return 0;}

The library stdio.h is the most used in C programming that contains input and output types, functions that the
program will use, this included almost the 75% of the C library, for example if the program needs
mathematic functions it needs to be included, in addition, #include<math.h>. The int main means that this is
our main function and (void) that doesn’t return to any other function. For include something that needs to be
show in our program we need to start with curly bracket and end with it. Printf followed with open and close
bracket and quotation marks open and close as well, it will print on our console what is inside, in this case
Hello World. \n is an escape sequence that we will talk about on the first assessment and on the end our
return 0; that tell the system that the program it might be terminated (in this assignment return 0; is not using
as not necessary to keep in the program). (Gookin, 2004)
In this Portfolio, it has been divided into functions, as showed below:

#include <stdio.h>
void gradeA();
void gradeB();
void gradeC();
void gradeD();
int main(void) {
int grade;
printf("Select the Grade.\n1-GradeD\n2-GradeC\n3-GradeB\n4-GradeA\
n");
scanf("%d", &grade);
if (grade == 1) {
gradeD();
} else if (grade == 2) {
gradeC();
} else if (grade == 3) {
gradeB();
} else if (grade == 4) {
gradeA();
} else {
printf("Wrong digit! Try again between 1 and 4.");}
}
N.B.: Functions will be explained in Assessment 7 of this Portfolio.




Logical Operator

Logical Operator is using for decision-making, there are three main logical operators showed below.

4

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