C, C++, Java, Python, PHP, JavaScript and Linux for Beginners [1 ed.]

An ideal addition to your personal elibrary. With the aid of this indispensable reference book, you may quickly gain a g

948 203 97MB

English Pages 1865 Year 2019

Report DMCA / Copyright

DOWNLOAD FILE

Polecaj historie

C, C++, Java, Python, PHP, JavaScript and Linux for Beginners [1 ed.]

Table of contents :
Question:
Question: (1)
Administrative data:
At-risk data: Information that could be lost.
Data Catalogue → A curated set of metadata regarding datasets and their data components.
Research Data Lifecycle
Stream processing
Simulation research data:

Citation preview

C, C++, Java, Python, PHP, JavaScript and Linux For Beginners

(A Step-by-Step Guide to Coding)

"The only true wisdom is in knowing you know nothing." − Socrates

Manjunath.R #16/1, 8th Main Road, Shivanagar, Rajajinagar, Bangalore560010, Karnataka, India *Email: [email protected]

Disclaimer

Despite my best efforts to assure the accuracy of the material in this book, I do not accept and hereby disclaim any liability to any party for any loss, damage, or disruption caused by mistakes or omissions, whether caused by negligence, accident, or any other cause. For any suggestions or concerns, please write to me: [email protected]

© Copyright 2019 Manjunath.R

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. (CC BY-NC-SA 4.0) Under the terms of the cc-4.0-by license, you may: 

Share – copy and distribute the content in any form or media



Remix, alter, and build upon the content for any non-commercial objective

As long as you comply by the conditions of the license, the licensor cannot revoke these rights. You have to 

Provide proper recognition;



Cite the license by including a link to it (https://creativecommons.org/licenses/by-nc-sa/4.0/); and



Specify whether (and if so, which) changes were made from the original.

Dedication

I dedicate this book to every individual, programmer, teacher, educational institutions and enterprise corporations in every country of the world for their immense contributions towards the process of creating, designing, deploying and supporting software…

Acknowledgements

Without the amazing work of some renowned programmers, their creativity, and their inventiveness in the field of software programming, this book would not have been accomplished. I would like to use this opportunity to thank my dearest friend and well-wisher "Lawrence" for his unwavering support during the COVID crisis and for giving me access to all the resources I needed to finish this book. I want to express my gratitude to my family for their support and encouragement as I wrote this book, especially to my mother, who has been a tremendous source of inspiration in my life. I owe a lot of gratitude to my mother for teaching me how to be perseverant and strong in life. Finally, I want to emphasize how crucial patience is when writing a book or taking on any other project in life.

Foreword

I'm neither the proprietor of a well-known publishing house or a top IT firm with hundreds of inhouse programmers who could easily produce anything I needed. I am a self-employed software engineer who is passionate about what I do, and believe me when I say that a lot of work and effort went into compiling this comprehensive edition. I'll be overjoyed if it helps even a few others reach their ideal positions in their professions.

Thank You − Manjunath.R

An Enjoyable Introduction to Coding

Introduction

Today's devices are mostly powered by software: almost everyone uses Facebook, WhatsApp and Twitter to communicate, many phones have internet-connected desktops, and the majority of office work requires using a computer to do tasks. As a response, there is a huge increase in demand for programmers. Numerous books, interactive websites, and programmer training courses make the bold claim that they can turn ambitious novices into software engineers earning six figures. This book is for all programmers, whether you are a novice or an experienced pro. Its numerous examples and well paced discussions will be especially beneficial for beginners. Those who are already experienced with programming will probably gain more from this book, of course. You will be at a modest level of programming proficiency when you have finished this book, from where you can take yourself to next levels so that you can automate simple tasks such as: 

Making a file backup



Get rid of the irritating emails



Completing online forms

This book will make an amazing complement to any tutorial and serve as a source of information to your specific inquiries if you are just learning what kind of animals C, C+ +, Java, PHP, Python, and JavaScript are. Even if your career has nothing to do with computers, the skills you learn from programming can be valuable at school and at work. Programming is a pleasant, occasionally difficult and perhaps frustrating activity. Creativity, logic, and problem-solving are all enhanced through programming. 

Educational institutions are teaching it



Corporate societies are employing it



Pupils need it



(Pedagogues desire it... ;)



(Coders perceive it... :)

Have Fun!

As you progress through this book, keep in mind that programming can be enjoyable. Do not consider of this as work. Consider programming as a means to develop entertaining games or software applications that you can show off to others or your friends. Programming is a tremendous brain workout and is essential today because so much of our everyday world is automated. But above all, you have access to the quick-paced, creative world that depends on machine connections.

"The only way to learn a new programming language is by writing programs in it." – Dennis Ritchie

Note: 

Linux version used: CentOS Linux release 7.3.1611 (Core)



Python version used: 3.7.3

The Basic Programming Principles That Every Programmer Should Know:

1. Always be aware of the purpose of your software program before beginning to write it. 2. Programming is not the solution; it is merely a means to achieve a solution. 3. Consider the problem rather than just the solution. 4. Always try to make things simpler; anyone can come up with a complicated answer to a problem. To make a solution simple while remaining consistent, it requires extra work and consideration. 5. Reduce Deeply Nested Ifs or Loops: When your software program is deeply nested, your program becomes complicated and disorganized. 6. Delete Unnecessary Code. Make sure your software program is safe, secure, reliable, testable and clear to read. 7. Give code reviews some attention so you can spot bugs early, before they cause serious problems in your software application. 8. Reduce complexity. Software programs must have clear explanations. 9. Generalize your software program. Make sure your software program is documented. Understanding the function of a certain component of the software application is greatly aided by the documentation and comments.

10. Fancy algorithms and data structures are more difficult to implement. Use simple, efficient, appropriate algorithms and data structures. 11. Refractor your software program frequently to improve its internal software attributes in terms of upkeep, testing and comprehension. 12. Each time you make a change to your software program: check it, build it and test it. 13. Before being released, all software codes must pass each and every unit test. 14. Always use caution when using someone else's code. Maintain a standardized, orderly and generally consistent coding style. 15. Avoid implementing a code style that is too hard to understand. 16. Because it makes the code more difficult to maintain, duplication is seen adversely in software programming. 17. Look for bugs and flaws and fix them. Divide your software program into Brief, Concise Units. 18. Avoid overdesigning. Focus your software design on the requirements of the clients. 19. Program defensively. Functions should be simple and do a distinct, defined task. 20. Create reusable functions and Keep the functions as simple, immutable and manageable as possible. 21. When naming your variables and functions, choose names that are meaningful and descriptive.

22. Put your software program's structure on view by using indentation. 23. Delete any unused variables and functions; do not comment them. 24. If you feel that a part of the software program is excessively unorganized, regroup and modify it, or even split it up into different portions. 25. Avoid using GOTO statements because they cause the software program to be unstructured, which makes it harder to understand and makes debugging more complex. 26. Avoid using the same identifier more than once. 27. The length of functions shouldn't be excessively long. 28. Think Twice, Code Once: Encourage yourself to consider the problem more before coming up with a solution. 29. The very first step in making a software program readable by humans is to add comments. Comments should be detailed explanations of a software program. 30. White space should be utilized regularly to increase code readability even though it has little significance to compilers. 31. Coding standards must be followed while formatting code. 32. Avoid security pitfalls and Keep your software code portable. 33. All software design is redesign. Take advice from others' experience. 34. The writing of software program should make it simple for a future software developer to correct errors or modify its functionality. 35. Never compromise clarity for a false sense of efficiency.

"More computing sins are committed in the name of efficiency (without necessarily achieving it) than for any other single reason − including blind stupidity." − W.A. Wulf

36. Enhance the appearance of software program by avoiding excessively long names or ambiguous acronyms 37. Look for a method that employs a loop rather than duplicating lines. Compared to 100 individual blocks of code, one loop that can handle 100 repetitions is simpler to debug.

You're not coding to amaze strangers. You're in this profession to find ways to resolve problems.

"The computer programmer is a creator of universes for which he alone is the lawgiver. No playwright, no stage director, no emperor, however powerful, has ever exercised such absolute authority to arrange a stage or field of battle and to command such unswervingly dutiful actors or troops."

− Joseph Weizenbaum

Top 10 Programming Languages and Their Applications

Python 

Artificial Intelligence, Deep learning and Machine Learning

JavaScript 

Rich Interactive Web Development

Java 

Enterprise Application Development

R

Data Analysis

C/C++

Operating Systems and System Tools

Golang

Server-Side Programming

C# 

Application and Web Development Using .NET

PHP

Web Development

SQL

Database Management

Swift

For Mobile Application Development on iOS

How much time does it take to become a good programmer?

A skilled coder can identify the best solution to any problem and solve even the most challenging issues. Being a good programmer requires constant knowledge upkeep and the acquisition of new skills. A PhD isn't always necessary to become a skilled programmer, but discipline and determination are. Being a successful programmer demands you to be one step ahead, while becoming a respectable coder takes years of hard effort.

Image Credit: Wikipedia.org

Contents

When you innovate, you've got to be prepared for everyone telling you you're nuts. – Larry Ellison

C Programming

22

C++ Programming

222

Linux

381

Git Commands

545

Algorithm

549

The Most Significant Failures When Al Turned Rogue, Causing Disastrous Results

574

Is DevOps a good career?

585

Android

589

Docker Commands

614

Java Programming

618

Structured Query Language

737

Basic MongoDB Commands

761

Python Programming

763

JavaScript Programming

860

PHP Programming

921

C Exercises

962

HTML

1082

CSS

1202

30 Bash Scripts for Beginners

1274

30 Python Scripts for Beginners

1289

9 Interesting Python Facts

1328

C++ Exercises

1331

Java Exercises

1385

Python Exercises

1461

Whether you want to uncover the secrets of the universe, or you just want to pursue a career in the 21st century, basic computer programming is an essential skill to learn.

− Stephen Hawking (One of the most brilliant theoretical physicists in human history)

Programming language

High level language

Low level language

Machine level language

General purpose

Specific purpose

High level language

High level language

Assembly language

Interpreter

High level language

Compiler

C Language Basic Syntax Rules

Including header files

#include int main()

main() function must be there

{ Single line comment

// Hello World Program printf("Hello,world!");

Semicolon after each statement

return 0; /* indicate that program ended successfully */ }

Program enclosed by curly braces

1

Machine level language

C Keywords

auto break case char continue do default const

double else enum extern for if goto float

int long register return signed static sizeof short

struct switch typedef union void while volatile unsigned

Special Characters in C Programming

, ( % ' ^ -

< ) [ & ! \

> ; ] { * ~

Primary

. $ # } / +

_ : ? " |

Secondary

C Constants

Array, Pointer, Structure, Union etc.

Non-numeric Numeric Character

String

Floating-point Integer 

Integer : 246, 0, -3679, +35, 9777, -36026 etc.



Floating-point : 246.23, 0000.23, -36.79, +35.56, 9.777, -360.216 etc.



Character : 'b', '?', '@', '#' etc.



String : "C", "Java", "Python", "JavaScript" etc.



Boolean : True, False



Nothing : Null

2

Data types: Types

Size in bytes

Keyword

Integer

2

int

Floating-point

4

float

Double

8

double

Character

1

char Input output functions:

Escape Sequences:

Input

Output

Formatted

scanf()

printf()

Unformatted

getchar()

putchar()

gets()

puts()

Sequence

Meaning

\a

System alarm (bell)

\b

Backspace

\f

Form feed

\n

Newline

\r

Carriage Return

\t

Horizontal Tab

\v

Vertical Tab

\\

Backslash

printf("Albert!!\n\a"); // This line outputs a quotation

\'

Single quote

return 0; // This returns control to the operating system

\"

Double quote

\?

Question mark

\0

End of string

#include // This is a preprocessor directive int main() // This identifies the function main() { // This marks the beginning of main()

} // This marks the end of main()

# Output: Albert!!

// C Program to Find Square of a Number

Output: #include // preprocessor directive /* function main begins program execution */ int main() {

Enter any number: 2 # entered number The square of the number = 4

int x; /* number to be input by user */ int square; /* variable in which square will be stored */ printf("Enter number: "); /* prompt */ Input outputany functions: scanf("%d", &x); /* read an number */ square = x * x; /* assign product to square */ printf("The square of the number = %d", square); /* print square */ return 0; /* indicate that program ended successfully */ } /* end function main */

3

Format specifiers in C

Format Specifier

Meaning

%c

Read a Single Character

%d

Read a Decimal integer

%e

Read a Floating-point number

%f

Read a Floating-point number

%g

Read a Floating-point number

%h

Read a short integer

%i

Read a Decimal or hexadecimal or octal number

%o

Read an octal number

%p

Read a pointer

%s

Read a string

%u

Read an Unsigned integer

%x

Read a hexadecimal number

%n

Prints nothing

%%

Prints % character

C Operators

Unary

Arithmetic

Ternary

Binary

Logical

Relational

4

Bitwise









Arithmetic operators Operations

Operator

Addition

+

Subtraction

-

Multiplication

*

Division

/

Modulus

%

Relational operators Operator

Meaning


=

Greater than or equal to

==

Equal to

!=

Not equal to

Logical operators Operator

Meaning

&&

Logical AND

||

Logical OR

!

Logical NOT

Operator

Meaning

&

Bitwise AND

|

Bitwise OR

^

Exclusive –OR (XOR)

~

1's complement

>

Right shifting of bits

Bitwise operators

5

Shorthand operators Operator

Example

Equivalent construct

+

a=a+b

a+=b

-

a=a-b

a-=b

*

a=a*b

a*=b

/

a=a/b

a/=b

%

a=a%b

a%=b

&

a=a&b

a&=b

|

a=a|b

a|=b

^

a=a^b

a^=b

>=b

Mathematical Functions Function

Description

sqrt(x)

Return the square root of x

exp(x)

Return exponential (ex)

log(x)

Return natural logarithm of x (base e)

log10(x)

Return logarithm of x (base 10)

fabs(x)

Return absolute value of x

abs(x)

Return absolute value of x

floor(x)

Return a value rounded to the next lower integer

pow(x,y)

Return x raised to power y (xy)

fmod(x,y)

Return floating-point remainder of x/y (with same sign of x)

sin(x)

Return the sine of x

cos(x)

Return the cosine of x

tan(x)

Return the tangent of x

acos(x)

Return arc cosine of x [cos−1(x)]

asin(x)

Return arc sine of x [sin−1(x)]

atan(x)

Return arc tangent of x [tan−1(x)]

6

#include #include int main() { // ceil() function rounds a number upwards to its nearest integer printf("%f\n", ceil(2.6)); // Output: 3.000000 // floor() method rounds a number downwards to its nearest integer printf("%f\n", floor(2.6)); // Output: 2.000000 return 0; }

/* * Multi-line * Comment. */

Multi-line comments /******************************************* * Multi-line * * Comment. * *******************************************/

#include int main(void) { printf("\"Albert Einstein was a German-born theoretical \"\nphysicist\n"); return 0; }

Output: "Albert Einstein was a German-born theoretical " physicist

7

C Header files Header file

Description

stdio.h

Input and Output functions

conio.h

Console Input and Output functions

stdlib.h

Some standard library functions

math.h

Mathematical functions

string.h

String manipulation functions

ctype.h

Character handling functions

time.h

Time computing functions

malloc.h

Memory allocation and deallocation functions

graphics.h

Graphical functions

dos.h

Function linking DOS routines

wctype.h

Functions to classify and transform individual wide characters

limits.h

Functions define various symbolic names

float.h

Functions define set of various platform-dependent constants related to floating point values

Preprocessor Directives Preprocessor directive

Use

#define

To define a macro

#include

Inserts a particular header from another file

#if

To test whether a compile–time condition is true

#undef

To undefine a macro

#else

To specify the alternative action if a test fails

#endif

To end the preprocessor condition

#include stdio.h is a standard header file required to

#define NUMBER_OF_APPLES 24

use input/output functions such as printf()

int indicates that main() returns an integer value

int main(void) { printf("There are %d apples in a basket.\n", NUMBER_OF_APPLES); return 0; }

// Output: There are 24 apples in a basket.

8

#include #include

// define a macro ab with the value 25

int main() {

#define ab 25

int x = 16; int y = (x++, ++x);

int main() {

printf("%d", y); return 0; }

/*******************************************************

// Output: 18

When the #ifdef condition is encountered: If ab macro is defined: #ifdef condition is executed If ab macro is not defined: #else condition is executed

******************************************************/

#ifdef ab printf("Your lucky number is: %d\n", ab); #else

Output:

printf("Error: printing lucky number!");

Your lucky number is: 25

#endif

return 0; #include

}

int main() { #ifdef ab Development of C Program:

printf("Your lucky number is: %d\n", ab); #else

Source Code

printf("Error: printing lucky number!"); #endif

Preprocessor return 0; }

Output:

Compiler Library

Error: printing lucky number!

Linker

Executable program

9

ASCII Table

ASCII

Char

---------

ASCII

Char

---------

ASCII

Char

---------

ASCII

Char

----------

0

NUL (null)

32

SPACE

64

@

96

`

1

SOH (start of heading)

33

!

65

A

97

a

2

STX (start of text)

34

"

66

B

98

b

3

ETX (end of text)

35

#

67

C

99

c

4

EOT (end of transmission)

36

$

68

D

100

d

5

ENQ (enquiry)

37

%

69

E

101

e

6

ACK (acknowledge)

38

&

70

F

102

f

7

BEL (bell)

39

'

71

G

103

g

8

BS

(backspace)

40

(

72

H

104

h

9

TAB (horizontal tab)

41

)

73

I

105

i

10

LF

(NL line feed, new line)

42

*

74

J

106

j

11

VT

(vertical tab)

43

+

75

K

107

k

12

FF

(NP form feed, new page)

44

,

76

L

108

l

13

CR

(carriage return)

45

-

77

M

109

m

14

SO

(shift out)

46

.

78

N

110

n

15

SI

(shift in)

47

/

79

O

111

o

16

DLE (data link escape)

48

0

80

P

112

p

17

DC1 (device control 1)

49

1

81

Q

113

q

18

DC2 (device control 2)

50

2

82

R

114

r

19

DC3 (device control 3)

51

3

83

S

115

s

20

DC4 (device control 4)

52

4

84

T

116

t

21

NAK (negative acknowledge)

53

5

85

U

117

u

22

SYN (synchronous idle)

54

6

86

V

118

v

23

ETB (end of trans. block)

55

7

87

W

119

w

24

CAN (cancel)

56

8

88

X

120

x

25

EM

57

9

89

Y

121

y

26

SUB (substitute)

58

:

90

Z

122

z

27

ESC (escape)

59

;

91

[

123

{

28

FS

(file separator)

60




94

^

126

~

31

US

(unit separator)

63

?

95

_

127

DEL

(end of medium)

10

Data Conversion Functions Function

Use

atof()

Converts string to float

atoi()

Converts string to int

atol()

Converts string to long

ecvt()

Converts double to string

fcvt()

Converts double to string

gcvt()

Converts double to string

itoa()

Converts int to string

ltoa()

Converts long to string

strtod()

Converts string to double

strtol()

Converts string to long integer

strtoul()

Converts string to an unsigned long integer

ultoa()

Converts unsigned long to string

Character Classification Functions Function

Use

isalnum()

Tests for alphanumeric character

isalpha()

Tests for alphabetic character

isdigit()

Tests for decimal digit

islower()

Tests for lowercase character

isspace()

Tests for white space character

isupper()

Tests for uppercase character

isxdigit()

Tests for hexadecimal digit

tolower()

Tests character and converts to lowercase if uppercase

toupper()

Tests character and converts touppercase if lowercase

#include #include

Output:

int main() { char x = '8'; if (isxdigit(x) != 0) { printf("%c is a hexadecimal character.", x); } /* end if */ else { printf("%c is not a hexadecimal character.", x); } /* end else */ return 0; }

11

8 is a hexadecimal character.

String Manipulation Functions

Use

Function strchr()

Appends one string to another

strchr()

Finds first occurrence of a given character in a string

strcmp()

Compares two strings

strcmpi()

Compares two strings without regard to case

strcpy()

Copies one string to another

strdup()

Duplicates a string

stricmp()

Compares two strings without regard to case (identical to strcmpi)

strlen()

Finds length of a string

strlwr()

Converts a string to lowercase

strncat()

Appends a portion of one string to another

strncmp()

Compares a portion of one string with portion of another string

strncpy()

Copies a given number of characters of one string to another

strnicmp()

Compares a portion of one string with a portion of another without regard to case

strrchr()

Finds last occurrence of a given character in a string

strrev()

Reverses a string

strset()

Sets all characters in a string to a given character

strstr()

Finds first occurrence of a given string in another string

strupr()

Converts a string to uppercase

#include int main() { double z; int x = 5; int y = 8; z = (double)(x + y)/2 - (x + y)/(double)(x*x + y*y); printf("%f", z); return 0; }

If marks is greater than or equal to 35 then

#include

printf("Passed\n") otherwise printf( "Failed\n" )

int main() {

is executed

int marks = 15; marks >= 35 ? printf( "Passed\n" ) : printf( "Failed\n" );

// Output: 6.353933

return 0; } // Output: Failed

12

Searching and Sorting Functions

Function

Use

bsearch()

Performs binary search

lfind()

Performs linear search for a given value

qsort()

Performs quick sort

File Handling Functions Function

Use

fopen()

opens new or existing file

fprintf()

write data into the file

fscanf()

reads data from the file

fputc()

writes a character into the file

fgetc()

reads a character from file

fclose()

closes the file

fseek()

sets the file pointer to a given position

fputw()

writes an integer to file

fgetw()

reads an integer from file

ftell()

returns current position

rewind()

sets the file pointer to the beginning of the file

#include int main() { int x = 3; while(x

Greater than

7 > 3 is TRUE


=

greater than or equal

9 >= 9 is TRUE

6 ? 25 : 50; printf( "%d", return 0; }

printf( "%d", x); } return 0; }

Output: 25

17

x);

Continue syntax

while (condition) {

do {

// statements

// statements

if (condition to break) {

if (condition to break) {

continue;

continue;

}

}

// statements

// statements

}

} while (condition);

for (variable initialization; condition; variable update) { // statements if (condition to break) { continue; } // statements }

Switch syntax

#include

Output:

/* function main begins program execution */ int main() {

2

switch (expression) { case 1:

1

int i = 1; /* initialization */

3

// statements

while(i25); // Output: 1 (True)

printf("Enter any number:"); scanf("%d", &a);

return 0;

printf("Enter any number:");

}

scanf("%d", &b); c = a%b;

printf("The remainder of a and b = %d", c); return 0; }

#include int main() { int i = 52;

The output on the screen: printf("%d", i= 60 { print $0 }' marks.txt Albert 95 Alan 65 Print all names with marks ≥ 60

John 92 James 66 Mary 77 Yovan 98

Tensor Processing Unit (TPU): An application-specific integrated circuit for neural network machine learning that Google developed using its own Tensorflow software

Translational invariance: A machine learning model's potential to disregard the translation of an image or its content. In other words, the model can still identify an animal in an image even if it is rotated or relocated to the top corner

1732

Trend analysis: A method used in technical analysis that makes predictions about future changes in stock prices using trend data that has just been observed

Universal function approximation theorem: There is already a neural network available for any function that we want to compute since neural networks have some kind of universality in them

Watson studio: A data science platform developed by IBM that offers the environment and resources necessary for us to work with others to solve business challenges using data

Weight sharing:

XGboost:

A method of neural network model

A free software package that offers a

compression that lowers the number of

regularizing gradient boosting framework for

weights in a network that must be trained

the programming languages C++, Java, Python, R, Julia, Perl, and Scala

[manju@localhost ~]$ ls -l total 4 -rw-rw-r--. 1 manju manju

0 Jul 31 07:49 1.c

-rw-rw-r--. 1 manju manju

0 Jul 31 07:49 1.cpp

-rw-rw-r--. 1 manju manju

47 Jul 31 10:03 1.html

-rw-rw-r--. 1 manju manju

0 Jul 31 03:56 1.pdf

1733

[manju@localhost ~]$ ls -l | awk '{print $6 " " $9}' Jul 1.c Jul 1.cpp Jul 1.html Jul 1.pdf

[manju@localhost ~]$ cat names.txt Albert, Physicist, USA, M, 03/14/1879 Charles, Biologist, Great Britain, M, 02/28/1889 John, Chemist, Germany, M, 05/21/1890 Alan, Mathematician, Russia, M, 05/28/1905

[manju@localhost ~]$ awk -F, '{print $1 " is a" $2}' names.txt Albert is a Physicist Charles is a Biologist John is a Chemist Alan is a Mathematician

[manju@localhost ~]$ awk 'BEGIN {FS=","} USA Great Britain Germany Russia

1734

{print $3}' names.txt

echo "1,2,3,4,5" | awk '{ split($0,x,",");for (i in x) {sum+=x[i]} } END {print sum}'

Go through the array elements and calculate their sum # Output: 15 (1 + 2 + 3 + 4 + 5)

"Simplicity is the soul of efficiency." – Austin Freeman

1735

SAP stands for System Applications and Products in Data Processing. One of the world's top software developers for business process management, SAP helps companies of all sizes manage their finances, logistics, human resources, and other business areas.

1. Introduction: SAP is a market leader in offering ERP (Enterprise Resource and Planning) solutions and services to enterprises across industries for improved work and data management. In 1972, SAP was established in Walldorf, Germany. It stands for Systems, Applications and Products in Data Processing. It has developed and grown over time to become one of the two leading competitors in the ERP software market as well as the leading global provider of client / server business solutions, for which it is now renowned. In 180 countries, SAP serves more than 335,000 clients, 80% of whom are small- and medium-sized businesses, according to its 2016 corporate fact sheet. By assisting in better management of customer needs and nurturing long-lasting and fruitful customer relationships, SAP is a German multinational software company whose products enable businesses to track customer and business interactions. SAP also builds a strong technical support for organizations. One of the basic goals of all corporate companies is to satisfy their customers, and SAP is particularly well-known for its data management tools that help them do this.

2. What is SAP? The technological revolution of today is being led by SAP. SAP, the industry leader in enterprise application software, supports businesses in overcoming the negative effects of complexity, creating new chances for innovation and growth, and maintaining a competitive edge. This has helped SAP rise to the top of the list of the biggest providers of ERP and other enterprise applications.

1736

3. History of SAP

In order to continuously transform the information technology industry, five former IBM employees founded SAP in 1972 with the goal of developing standard application software for the business potential of technology and real-time business processes. Since its founding, SAP has released a number of versions, including SAP R/1, SAP R/2, and SAP R/3. The R in these releases stands for "RealTime" data processing. The number 3 in the R/3 stands for three-tier client-server architecture.

4. Features of SAP 

Monitors Human Costs



Documents Progress of Process



Process of Invoices



Records External Employee's Services



Confirms Service Management Orders



Maintains Planning and Progress



Collects Data Plans and Sheets

5. Technical details

ERP The essential business operations of a firm are included in SAP ERP. Almost every functional area of a company activity, including the purchase of products and services, sale and distribution, finance, accounting, human resources, manufacturing, production planning, logistics, and warehouse management, is supported and integrated by the ERP package. The most recent Enhancement Package (EHP8) for SAP ERP 6.0 was released in 2016.

1737

SAP R/3 It is client / server version of the software and it is 3-tier architecture which includes 3 layers installed in 3 separate servers. The 3 layers are: 

Presentation Layer: that contains the software components that make up the SAPGUI.



Application Layer: that consists of one or more application servers and a message server.



Data Base layer: that consists of a central database system containing all of the data in the R/3.

SAP R/2 It is a main frame version of software and it is 2-tier architecture in which 3 layers are installed in 2 separate servers.

SAP R/1 It is the first version and it is one-tier architecture in which 3 layers are installed in one server.

6. Functional modules of SAP include: 

FICO - Finance & Control



PP - Production Planning



MM - Material management



SD - Sales and distribution



HR - Human resource



CRM - Customer Relationship Management

1738

7. How is SAP in terms of career growth?

SAP provides a faster career growth whether it is functional or technical area, provided the candidate has good fundamental knowledge in IT domain and a very sound knowledge of SAP. Certification in SAP can increase your job prospects. Fortune 500 Firms has implemented SAP R/3 and being successful because of its process integrations among the different organizational functionalities in real time data accessing under a single common database. There are various sub-modules of SAP (such as Material Management (MM), Project System (PS), Sales and Distribution (SD), Advanced Planner and Optimizer (APO), Quality Management (QM) etc.) and every module in SAP has its own demand and uniqueness and has opened up new job opportunities to execute on an aggressive acquisition strategy to fill the technology gaps. Owing to the various advantages, more and more organizations are moving towards adopting SAP to impact business in an important and far-reaching way.

Non-parametric learning algorithm:

Algorithms that get their learning from data rather than a mathematical model

Linear Regression:

A regression is a technique for figuring out how one variable "y" and another variable "x" is related. A linear regression is a method used to represent a linear relationship between the independent variable "x" and the dependent variable "y" in statistics. In Machine Learning, a Linear Regression is a supervised machine learning algorithm. When there is a linear relationship between two variables, the dependent variable's value changes in response to changes in the independent variable's value (increase or decrease). With the use of the following equation, the relationship can be mathematically represented as: y = mx + c

1739

where: 

The dependent variable "y" is what we are attempting to predict.



"x" serves as the independent variable for our predictions.



The slope of the regression line "m" shows how much of an impact "x" has on "y".



"c" often known as the y-intercept, is a constant. "y" would be equal to m if "x" = 0.

Furthermore, the linear relationship can be positive or negative:

Positive Linear Relationship: If both the independent and dependent variables increase, the linear relationship is said to be positive. The following graph can help you understand it: y

y

x

x

Positive Linear Relationship

Negative Linear Relationship

Negative Linear Relationship: If both the independent and dependent variables decrease, the linear relationship is said to be negative. The above graph can help you understand it:

1740

Random Forest Algorithm: 1. Choose the samples at random from the provided dataset. 2. The second step of this technique is to build a decision tree for each sample. The forecast outcome from each decision tree will then be obtained. 3. Voting will be done for each predicted outcome in this step. 4. Finally, choose the prediction result that received the majority of votes as the final prediction result.

Conducting feature selection before to data modeling will: 

Decrease overfitting



Speed up training



Improve model correctness

Epistemology: An exploration of the kind of knowledge needed to address global issues

Dempster Shafer's theory: A logical theory of evidence based on credible arguments and belief functions. It is used to calculate the likelihood of an event by combining various pieces of evidence

Rule-Based Expert Systems: The most basic type of Artificial Intelligence, which follows predetermined knowledge-based rules to address issues

1741

PL/SQL Code Block Structure:

[DECLARE]

declaration statements;

[BEGIN]

Defined by the keywords execution statements;

DECLARE, BEGIN, EXCEPTION, and END

[EXCEPTION]

exception statements;

END;

Data

Numerical transformation

Transforming Data

Data analysis

into Visuals Graphical interpretation

Human interaction

1742

Data flow diagram

System flow chart

Graphical representation of the information system

Graphical representation of the information system by describing the process step-by-step

The reader of a data flow diagram cannot interpret the result from it easily

The reader of a system flow chart can easily understand the process

Natural language

The speech recognition not only can understand the voice but also return answers to questions or other queries that are being asked.

Structure Chart

Flowchart

Represents the basic architecture of the software with

Represents the graphical structure of an algorithm

the help of modules

Quite complex to understand and design

Easier to construct and understand

Special purpose registers (Contain specific information the CPU needs)

1743



Instruction Register: contains the actual instruction which is currently being executed by the CPU



The program counter: contains the address of the next instruction to be executed by the program Memory

Buffer Memory

Cache (high speed memory)

A temporary holding area for

Stores the frequently used

data

data by the CPU

Being part of dynamic RAM

Being part of static RAM

aid in improving the speed of

aid in improving the speed of

operations of the CPU

operations of the CPU

Loses its stored information in a very short time

Information remains stored as

(for milliseconds) even when power supply is on

long as power supply is on

DOS (Disk Operating System) is an operating system that runs from a hard disk drive

1744

Napier bones

Numbers 0 to 9 were marked on a set of ivory sticks in such a way that the product of any number can be found by placing the sticks side by side.

A programming language is like a natural, human language in that it favors certain metaphors, images, and ways of thinking.

— Mindstorms: Children, Computers, and Powerful Ideas, Seymour Papert (1980)

0! = 1 n! = n × (n − 1)! if n > 0

Statement

Token

(sentence)

(word)

sequence of tokens (words)

sequence of characters (letters)

1745

Kernel language

Aid the programmer in reasoning and understanding

Foundational calculus

Mathematical study of programming

Abstract machine approach

Efficient execution on a real machine

Cache mapping

A technique by which the contents of main memory are brought into the cache memory

Record Operations

Making changes to data at the record level

Variables



local variable



instance variable



static variable

Local Variable: A variable declared inside the body of the method

Instance Variable: A variable declared inside the class but outside the body of the method

A variable that is declared as static is called a static variable.

Static binding in Java occurs during compile time while dynamic binding occurs during runtime.

1746

// syntax error

#include int main() { int x = 23; int y = 25; printf("%d", (x, y)) // semicolon missed return 0;

}

// run-time error

#include int main() { int n = 19, div = 0; // wrong logic // number is divided by 0, // so this program abnormally terminates

div = n/0; printf("result = %d", div); return 0; }

1747

// linker error

Occurs when the executable of the program cannot be generated #include int Main() // Here Main() should be main() { int a = 10; printf("%d", a); return 0; }

// semantic error

Occurs when the statements written in the #include int Main()

program are not meaningful to the compiler

{ int a, b, c; a + b = c; // semantic error return 0; }

// logical error

#include int main() { int i = 0; // logical error: a semicolon after loop

1748

for(i = 0; i < 3; i++); { printf("loop "); continue; } getchar(); return 0; }

Hashing Data Structure List = [11, 12, 13, 14, 15]

Hash function H(x) = [x % 10] Modulo operator

will be stored at positions {1,2,3,4,5} in the array or Hash table

1 11 11%10

2 12 12%10

3

4

13

14

5 15

13%10 14%10 15%10

Hash function



h(11) = 11%10 = 1



h(14) = 14%10 = 4



h(12) = 12%10 = 2



h(15) = 15%10 = 5



h(13) = 13%10 = 3

1749

Class

Object

Blue print from which objects are created

Instance of a class

Declared once

Created many times as per requirement

Allocates memory when it is created

Does not allocates memory when it is created

public class MyClass { public static void main(String[] args) { display(); //there is no object created here because display is a static method } public static void display(){ System.out.println("Call from static method"); } }



A static method can access only static members



A non-static method can access both static and non-static members

public class MyClass { public static void main(String[] args) { HelloWorld tc = new HelloWorld(); tc.display(); //object is created here because display is a non-static method } public void display(){ System.out.println("Call from non-static method"); } }

1750

Write code

Plan your program

Test code

Find errors

Think of a solution

Debugging cycle:

Identify the cause of errors

Find and remove the number of errors or bugs or defects in a program

Input data testing: A test phase that concentrates on the accuracy of the data utilized by Machine Learning models during training and prediction

Correctness debugging

Where is the bug?

Performance debugging

Why is it so slow or fast?

Exploratory debugging

What does it do? How does it do it?

Debugging Process:

Computer forensics:

1. Identify the error The process of evaluating the

2. Identify the exact location of the error 3. Understand and analyze the type of bug or error

damage produced by a security

4. Checks all the new errors in the program

attack and figuring out how it was successful

5. Fix and validate the bug 6. Retest the program

1751

Android - Application Components

Which are the building blocks of android application?

The main components of the android application are: 

Activities



Services



Broadcast Receivers



Content Providers



Intent



View



Android Virtual Device (AVD)



Android Emulator

Activities

If you open your phone application, you see number of activities such as received calls, dialed calls, missed calls etc. If you click on received calls, then another activity (i.e., screen showing the list of received calls) is opened. And if you click on one of the received call, then another activity showing the information about the received call (such as the phone number of received call, the time at which it was received etc.) is opened. And if you want to make a call, another activity showing the number keypad is opened.

Services

If you want the music to play in the background or if you want some video to be downloaded while you are browsing over the internet ‒ services provide feasibility for the music to play in the background or video to be downloaded while you are browsing over internet.

1043 1752

Broadcast Receivers

Pop up notifications such as low battery, charging, Power got connected to the mobile device, Power got disconnected from the mobile device, A headset was plugged in, A headset was plugged out.

Your battery is very low [4%], please plug in immediately

Popup notification by broadcast receiver

Content Providers

If you type a request for the meaning of a word in the search engine of user dictionary application User dictionary application sends the request to content resolver and the content resolver sends the request to the content provider and the content provider fetches the information from the database and directs it to the content provider and then from content provider to content resolver and finally from content resolver to user application.

Intent

1044 1753

Activity 1

Activity 2

View photo

When you press view photo, intent (message) is sent to the android operating system to open another activity (i.e., activity 2) which display the photo

View (apps user interface)

Android Virtual Device (AVD) & Emulator

Different android mobile devices possess different configurations. After running and testing your android application on emulator (the component that allows the testing of android application without the necessity to install the application on a physical Android based mobile device) you need Android Virtual Device (AVD) to test whether the application is compatible with a particular android mobile device configuration before installation of the app into that mobile device.

1045 1754

Understand the problem

[Algorithmic Problem Solving]

Decide on computational means

Decide an algorithm

Prove correctness

Analyze the algorithm

Code the algorithm

Brute force algorithm finds a solution by trying all possible answers and picking the best one.

If there is a lock of four digit PIN. The digits to be chosen from 0-9 then the brute force will try all possible combinations one by one like 0001, 0002, 0003, 0004, and so on until we get the right PIN. In the worst case, it will take 10,000 tries to find the right combination.

1755

Divide-and-conquer technique

Problem of size n

subproblem 1 of size

n

subproblem 2 of size

2

solution to subproblem 1

n 2

solution to subproblem 2

solution to the original problem

Numerical stability refers to how errors introduced during the execution of an algorithm affect the result

1) Get the current instruction. 2) Determine the meaning of the instruction. 3) Perform the action called for by the instruction. 4) Prepare for getting the next instruction.

1756

Functions of interpreter

Persistent Data Structure

Ephemeral Data Structure

Data structure that always preserves the

Data structure that do not preserves the previous version

previous version of itself when it is modified

of itself when it is modified

Modifications are nondestructive A modification destroys the version which we modify

Packages

User defined Packages

In Built Packages

The Reentrant program is a way to handle multitasking.

Backtracking

If the current solution is not suitable, then eliminate that and backtrack (go back) and check for other solutions.

1757

Time complexity of an program

Space complexity of an program

The amount of time taken by an program to

The amount of memory space used by an

complete its execution as a function of the

program to complete its execution as a function

length of the input

of the length of the input { int d = a + b + c; return(d); }

Here, in the program above, a, b, c and d are 4 integers, so each will take 4 bytes. So, the memory required will be 4×4 = 16 bytes. In addition to this memory, while returning value, d will take 4 bytes. Therefore, the total memory requirement will be 16+4 = 20 bytes. This is the space complexity of the above-program

C#

C# Complier

C/C++

C/C++ Complier

Prolog

Intermediate

Just-in-Time

language

Compiler

Prolog Complier

in

F#

F# Complier

Scheme

Scheme Complier

Languages

Compilers

Common language runtime

Microsoft's Visual Studio.Net programming environment

1758

Hardware or Stimulator

Declarative programming → specifies what is to be done rather than how to do it

SQL, HTML, XML and CSS (model-based programming)

Does not provide instructions on how to solve the problem

Imperative programming: provides step by step instructions on how to solve the problem

                           

Ada ALGOL Assembly language BASIC Blue C C# C++ COBOL D FORTRAN Go Groovy Java Julia Lua MATLAB Modula MUMPS Nim Oberon OCaml Pascal Perl



Rust



Easy to read and learn



Solution path is very easy for beginners to understand



Optimization and extension is more difficult



PHP PROSE Python Ruby

1759

Higher risk of errors when editing

Imperative programming (PHP):

$participantlist = [1 => 'Peter', 2 => 'Henry', 3 => 'Sarah']; $firstnames= []; foreach ($participantlist as $id => $name) { $firstnames[] = $name; }

Declarative programming (PHP):

$firstnames = array_values($participantlist);

Imperative programming



Structured Programming: the code is divided into modules or function and include three basic elements:  Sequence: Execute a list of statements in order. x = 5 y = 11 z = x + y WriteLine(z)



Selection: Execute a block of code if a condition is true. The block of code is executed at most once. x = ReadLine() If x Mod 2 = 0 WriteLine("The number is even.") End If

1760



Repetition: Repeat a block of code while a condition is true. There is no limit to the number of times that the block can be executed. x = 2 While x < 100 WriteLine(x) x = x * x End



Procedural Programming: the use of code in a step-wise procedure to develop applications



Modular Programming: the process of subdividing a computer program into separate sub-programs

Declarative programming



Logic Programming: presentation of program in the form of symbolic logic



Functional Programming: programs are constructed by applying and composing functions

Imperative programming

algorithms + data (good for decomposition)

Functional programming

functions (good for reasoning)

Logic programming

facts + rules (good for searching)

Object-oriented programming

objects + messages (good for modeling)

Structured Programming

Unstructured Programming

Code is divided into modules or function

Code is considered as one single block

1761

Easy to read

Hard to read

Easy to do testing and debugging

Hard to do testing and debugging

Prolog program to print Hello World!

:- initialization(main). main :- write('Hello World!').

Hello World!| ?-

Some basic features of Prolog include:

Output on the screen

For every input array of length n ≥ 1, the MergeSort



pattern-matching mechanism



backtracking strategy that searches for possible

algorithm performs at most

solutions 

6nlog2 n + 6n

uniform data structures from which programs are built

operations, where log2 denotes the base-2 logarithm.

Recursion

Iteration

Uses

Uses

selection structure A program is called recursive when a statement

repetition structure A program is called iterative when a loop repeatedly

in a function calls itself repeatedly

executes until the controlling condition becomes false

Reduces the size of the code

Makes the code longer

Slow in execution

Fast in execution

Consumes more memory

Consumes less memory

1762

#include

#include

int fact(int n){

int main() {

if(n == 0)

int i, n = 5, fact = 1;

return 1;

for(i = 1; i