Important Announcement
PubHTML5 Scheduled Server Maintenance on (GMT) Sunday, June 26th, 2:00 am - 8:00 am.
PubHTML5 site will be inoperative during the times indicated!

Home Explore An_Introduction_to_Computer_Science_ClassIX

An_Introduction_to_Computer_Science_ClassIX

Published by SIDDHANT JHA, 2021-06-20 14:31:22

Description: An_Introduction_to_Computer_Science_ClassIX

Search

Read the Text Version

If we need to build an application that runs on a computer and is used by other users, how can we proceed? Programming or coding deals with this particular aspect. 7.2 PROGRAMMING LANGUAGES In order to communicate in a structured manner, we the human beings use languages. Similarly, to communicate with computers, we should have some languages. These languages are called programming languages. A program is a set of instructions to perform some tasks by the computer. The languages that are used to write a program are called programming languages. Programming languages are similar to human languages in the sense that they have well-defined rules and regulations, called the grammar or the syntax of the language. All the instructions written in the program must follow the syntax of the language. Programming languages can broadly be categorized in three types- 1. Machine level language 2. Assembly level language 3. High-level language CPU communicates in machine level languages and these languages use only binary numbers (0 and 1). All the instructions are written using 0s and 1s. A program written in machine level language will be only combinations of 0s and 1s as shown in Figure 7.1. 01010101011110000110011110000010111 10000110010011111110111100001000011 01010111111000000111110000000011111 11110000000000000000000000000000000 00000000000000111111111100000000011 Figure 7.1: An example (hypothetical) of a machine language program. Now, you must have realized that to communicate with the machine, we are to write everything using 0s and 1s and this is a nightmare for every human being. Even computer scientists need to put huge efforts to write a program. The next level of languages are assembly languages. In these types of languages, instead of writing the program in binary format, we write them using some English words and symbols. An example of an assembly language program is shown in Figure 7.2. You can see that the program looks much better than the previous one. It is easy to read, understand and write. To write a program in assembly language for a CPU, we should know the ISA of the CPU including the register names. For example, the program in Figure 7.2 used registers $v0, $a0, $t0, and $t1. This brings some complicacy for the programmers. 141

li $v0, 5 syscall move $t0, $v0 li $v0,5 syscall move $t1,$v0 add $a0, $t1, $t0 li $v0, 1 syscall Figure 7.2: A code segment of assembly language program Now look at the program as shown in Figure 7.3. This looks even better than the assembly language program. We can define and use variables from our side (we will learn this in the next chapter). This kind of programming gives flexibility to the programmer. We call it high level language (HLL) programming. A program written in HLL is the closest to the human languages. To write a program in HLL, we do not need to know the details of the processor where the program runs. Thus we always prefer to write programs in HLL. int a, b, c; a = b + c; System.out.print(a); Figure 7.3: A code segment of high level language program From the above discussion, we understood that computers understand and operate on machine language and the programmer prefers to code in HLL. When a program is written in any HLL, to execute it on a computer, it needs to be converted into an equivalent machine language program. This is called compilation of a program. The basic job of a compiler is to convert a program written in high level language to the machine level language of the computer where the program runs. While doing so, it does a series of jobs in between. Some important jobs of a compiler are: syntax analysis (checks whether the program is written following the rules of the language or not), intermediate code generation (converts the HLL program into an intermediate form), optimization (improves the efficiency of the program), etc. We will learn the compilation process in the context of a C program in the next chapter. 142

7.3 PROBLEM SOLVING IN COMPUTER We write a program or build an application when we want our computer to do a specific task based on our requirement. We may use any high level language to write the program or build the application. To do so, we primarily need to know two things: i) Logic or the solution for the program, ii) Syntax of the HLL. The solution strategy depends on the problem we want to solve in our program. This is almost independent of the HLL we use to write our program. Once the solution for a given problem is ready, we need to write that using the permissible statements of the corresponding HLL. In the following section, we will spend some time to learn about the logic or solution strategy for a program. 7.4 ALGORITHM, FLOWCHART AND PSEUDOCODE Let us assume that we want to write a program to find the largest of N given numbers. The numbers are stored in computer memory and we need to make a comparison to find out the largest one. Think for a while how human beings would solve this problem ! When we are given only one number, the number is automatically the largest number. In general, let us consider the first number as the largest number. We will bring the second number and compare with the currently declared largest number. If the second number is greater than the current largest number, then we need to update and the second number becomes our new largest number. In case the second number is smaller than the current largest number, we do not need to do anything. If we keep on doing this till the last number, we will get the largest number among all the numbers. This is the solution strategy for the given problem. If we write them in steps specifying the operation for each step, we will end up with an algorithm for the problem. An algorithm is a well-defined set of steps to solve a given problem. The above discussed steps to find the largest number from a set of numbers can be written as an algorithm as shown in Figure 7.4. 1. Initialize the first number as the LARGEST 2. Get the next number and compare with the current LARGEST 3. If the new number is greater than the current LARGEST 4. Then update the LARGEST with the new number 5. Repeat steps 2, 3 and 4 if all the numbers are not visited 6. Declare the LARGEST as the largest number among all Figure 7.4: An algorithm to find the largest number from N numbers The steps in solving a problem can also be represented using a diagram. The graphical representation of an algorithm is called flowchart. We use different symbols to draw the flowchart. Each symbol has its dedicated meaning. We list some basic symbols used in a flowchart as follows. 143

Oval: used to indicate start or stop of the flow. Parallelogram: used to indicate input or output operation. Rectangle: used to indicate processing or calculation. Diamond: used to indicate a decision making operation. Figure 7.5 shows the flowchart for the algorithm we discussed above. Flowchart gives better docu- mentation of the program than the actual code. Figure 7.5 : Flowchart to find the largest number from N numbers. As stated earlier, to write a program we must follow all the rules of the language and every statement in the program has to be a valid statement of the language. If we want to write the program in an informal way, we may do so with the help of pseudocode. Pseudocode uses natural language and mathematical symbols to express the program. Some- times, it is easier for us to comprehend the pseudocode than the actual code or the program. As a result, pseudocodes are also heavily used. Figure 7.6 shows a pseudo code for the same problem we are discussing. Figure 7.6: A pseudo code to find the largest number from N numbers. Keywords learned in this chapter Coding Programming Programming Language Machine Level Language Assembly Language High Level Language Compiler Pseudocode Algorithm Flowchart 144

Exercises : 1. Fill in the blanks. a. ISA stands for …………………….... b. Programming is also known as ………..........……. c. The rules and regulations of a computer programming language is known as ……… d. In machine language, computer programs are written using only ……... numbers. e. In drawing flowchart, ……...…. is used for input/output operation. 2. Short answer questions (Answers should preferably be of 2-3 lines) : a. How do we write programs in assembly level language? The expression a = b + c can be a statement of which type of programming languages? b. Name the two basic ingredients if we want to write a computer program for solving a problem. c. Why is it easier for a human being to write programs in high level language than in machine level language? 3. Long answer questions (Answers should preferably be of 5-6 lines) : a. Define the term programming. Write the importance of computer programming. b. Explain the importance of compiler in program execution. c. Differentiate between algorithm, flowchart and pseudocode. 4. Problem solving and algorithm design questions. a. Draw a flowchart to find the larger number from two given numbers. b. Write a solution strategy for finding the largest number among three given numbers. Draw a flowchart for the same. c. Design an algorithm to find the smallest of N given numbers. Write a pseudo code for the same. Draw a flowchart to represent the solution strategy. d. Write a solution strategy for finding the greatest common divisor of two numbers. Draw a flowchart for the same. e. Write pseudocode for finding the summation of N given numbers. Draw a flowchart for the same. f. Write a solution strategy for arranging three numbers in ascending order of their values. Draw a flowchart for the same. g. Write pseudocode to announce all the even numbers from a given set of numbers. Draw a flowchart for the same. 145

INTRODUCTION TO 8CHAPTER C PROGRAMMING “Everybody should learn to program a computer, because it teaches you how to think.” - Steve Jobs. In this chapter, we will start writing programs in C. While doing so, we will first train our brain to think from a computer’s and a programmer’s perspective. We will also learn about the steps that occur in the background when we run our program on computer. 8.1 INTRODUCTION TO C PROGRAMMING LANGUAGE C is a high level programming language that was originally developed at Bell Labs by a computer scientist namely, Dennis Ritchie between 1972 and 1973. During the 1980s, C gradually gained popularity and it has become one of the most widely used programming languages of recent times. C compilers are available from various vendors for the majority of existing computer architec- tures and operating systems. As C is close to the assembly level language, sometimes it is also called a middle level language. Suppose you want to write something in a new human language (say, French). To do so, you should first learn the grammar or the rules of the language. You should also accept the meaning of the words as they are and then we can use them in the sentences we write. Similar is the case for a programming language too. Let us have a look in Example 8.1. This is a C program to print “I read in class IX under SEBA” on the display device (i.e. monitor) of the computer. #include<stdio.h> int main() { printf(“I read in class IX under SEBA”); return 0; } Example 8.1: A C program to print “I read in class IX under SEBA”. 146

8.2 THE PRELIMINARIES Before we start writing our own programs, let us first understand a few important things. 1. Syntax of the language : As stated earlier, whenever we want to write a program using any language, we must write it following the syntax of the language. The program in Figure 8.1 is just to print a sentence. But to do so, we had to write many other things. We also had to write the printable sentence within double quotes and with a word printf. We also needed to include another file in the first line of the program. All these are parts of the syntax for the language C. Do not worry! We will learn a good amount of syntax in this chapter. 2. Basic requirements : The next important question is, “Where do we write a program and how do we run it?”. To write any program, we need to have a text editor installed on our com- puter. Some of the good editors are Notepad++, Sublime Text, Atom and others. We may also use a notepad that is a pre-installed text editor on a windows system. After we write the program, we need to run the program. Running a program is also known as executing a program. To do so, the computer must have a C compiler installed on it. The importance of a compiler is explained to you earlier. Some of the popular C compilers are gcc, MinGw, ICC etc. There exists some software that combines the editor and compiler and provides other interesting features. These softwares are called integrated development environments (IDE). Some popular IDEs are Codeblock, Oracle developer studio, NetBeans, DevC++, Eclipse etc. Moreover, you may also use online compilers to write and execute your program. In that case, you do not need to install any software. One such online compiler is available on the website https://www.onlinegdb.com/online_c_compiler. 3. Think from a computer’s perspective : When we code (that is, when we write pro- grams), we play the role of a programmer rather than a user. While writing a computer program, we assume that we have a computation or processing element (i.e. the CPU) and a huge memory where data will be stored. This is also called the programmer’s view of memory. Figure 8.1 shows a diagrammatic representation of the same. Figure 8.1: Programmer’s view about CPU and memory. 147

We also assume that the processing element will process one instruction after another sequentially. Therefore, while writing a program for a given problem, we need to design it in such a way that each step performs some work and each work will be accomplished by one or a set of instructions of the programming language. Many complex (but interesting) things happen when the CPU communicates with memory and when it executes the instructions. But this is beyond the scope of the book. If you study computer science later in your career, you can learn these exciting features! 8.3 WRITING OUR FIRST C PROGRAM In this book, we will see writing C programs using an IDE namely Codeblock. If the IDE is not installed on your computer, you need to first download and install it (steps 1 and 2). We will follow step 3 onwards to write our C programs. 1. Go to the website of codeblock: http://www.codeblocks.org/downloads 2. Download the version that suits your computer and install it. If you do not have any C compiler installed on your computer, then you may download codeblock with mingw setup file (refer Figure 8.2). 3. Open the Codeblock software on your computer. 4. Create an empty file by clicking menu items: File  New  Empty file (Figure 8.3) 5. Then you may start writing the code. 6. Save the file using any filename with an extension of .c (Figure 8.4). 7. After you complete writing the program, you save the file by pressing Ctrl+S or clicking File  Save file. 8. Run the program by pressing F9 or clicking menu items Build  Build and run. 9. In case there is no error in the code and the program successfully builds, you will see an output window with the intended output (Figure 8.5). 10. If there is any error in the program you wrote, you will see on the build message panel (Figure 8.6). You may also install any other IDE or any other compiler. Alternatively, you may also use an online compiler as mentioned before. This will not affect the learning of C programming. 148

Figure 8.2: Downloading Codeblock from website Figure 8.3: Creating new file in Codeblock to write program. 149

Figure 8.4: Saving C program in Codeblock. Figure 8.5: Running our first C program. 150

Figure 8.6: A C program with an error. 8.4 UNDERSTANDING THE C PROGRAM Let us now try to understand the C program we wrote line by line. In the first line, we have included an existing file namely, stdio.h in the program we are writing. This is a header file (file extension is .h) and it provides support for standard input and output operations. The file contains definitions of many functions (such as printf(), scanf(), etc.) that we use in our program. In addition to stdio.h, C programming language provides many other header files such as stdlib.h, math.h, string.h and others. We may also create header files from our side. Those will be called user defined header files. #include<stdio.h> Whenever we write something with a double parentheses (), it indicates a function in a program. A function combines a set of statements within two curly braces {} for performing any specific work. The execution of any program starts from a special function main(). All C programs must have this function. int main() The next statement is the printing statement. Syntax of the language says if we want to print anything, we should write inside the built-in function printf(). This is used to send formatted output to the screen. The string to be printed is enclosed within double quotes. 151

We put a semicolon (;) at the end of this line. This indicates it is a statement and every statement in C programming language is to be ended with a semicolon. printf(“I read in class IX under SEBA”); The last statement in the program is a return. This is the last statement of the function main() too. Every function in a program has to return some value. As we have prefixed “int” with the function main(), the function should return any integer value (we will learn different types available in C in the next chapter). return 0; TvQrayulfuirrceoekmtoutarhcynetoiiruvnrtigthsyeaa:lnnfy. 0 8.5 COMPILATION OF A C PROGRAM: BEHIND THE SCENE Let us spend some time to understand what happens behind the scene when we build (or compile) the program we wrote. As we have done our program using an IDE, we do not care much about these steps. But many interesting things happen inside and knowing these steps will improve our concepts. The steps can be represented using the diagram as shown in Figure 8.6. We will briefly go through the steps. Figure 8.7 : Steps in C program compilation. 152

In the preprocessing step, the compiler removes the commented lines (commented lines are not part of the program; we write them for our understanding purpose. We will see an example later.) from the program. The included header files are expanded and a few other works are done. If the source file name is Prog1.c, then this step produces output as Prog1.i. In the next step, the expanded file is compiled and converted into assembly language. The assembly code is generated depending on the ISA of the computer. Then the generated assembly language code Prog1.s is converted into the machine language code Prog1.o. This is also called an object file. The last step of the compilation is linking. At this step, different object files are linked if one object file requires to use another object file for its execution. Finally, we get an executable file as output from our source file that we wrote. The operating system runs this executable file on our computer and we get to see the desired output of the program. 8.6: USING ESCAPE SEQUENCE IN PRINTF() Our first C program (Example 8.1) displayed a sentence on the monitor using the function printf(). In this section, we will learn using escape sequences inside printf() to display sentences differently (e.g. printing sentences in different lines, putting gaps in the display, etc.). An escape sequence in a programming language is a sequence of characters that does not represent itself when used inside a character or string literal, but is translated into another character or a sequence of char- acters that may be difficult or impossible to represent directly. In C, all escape sequences consist of two or more characters, the first of which is the backslash, \\ (called the “Escape character”). The remaining characters determine the interpretation of the escape sequence. Table 8.1 lists some of the commonly used escape sequences with their interpretations. ESCAPE CHARACTERS INTERPRETATIONS \\n New line \\t Horizontal tab \\v Vertical tab \\’’ Double quotes \\r Carriage return \\b Backspace Alert (Beep) sound \\a Table 8.1: Some escape sequences for C programming language We may use these escape sequence characters in the printf() function of the program we discussed before. For example, if we want to print in two lines, we may use \\n. Example 8.2 demonstrates one such program. 153

#include<stdio.h> int main() { printf(“Namaskar! \\n I am from Bilasipara. \\n I read in INAHS School.”); return 0; } Example 8.2: A C program to print in multiple lines. seTaqrbuyoeuvQnescuitenaigccbkhlaoeaallurcaaottnpcitdvthueieattryrsns.e:afsrlycozamepetthhee Keywords learned in this chapter Syntax Text Editor Integrated Development Environments (IDE) Middle Level Language Header File Escape Sequence 154

Exercises : 1. Fill in the blanks. a. C is the only high-level programming language ……… (TRUE/FALSE) b. IDE stands for ……………. c. We always need a very powerful computer to run C programs ……… (TRUE/FALSE) d. Every statement in a C program has to end with ……………… e. Execution of a program starts from ………….. 2. Short answer questions (Answers should preferably be of 2-3 lines): a. While writing a computer program, what does a programmer need to assume about the cpu and storage? b. Do we always need Codeblock to write C programs? Explain. c. Why do we need header files? Name a few standard header files in C. 3. Long answer questions (Answers should preferably be of 5-6 lines): a. Explain the process of compilation of a C program. When we save a C program with the name Namaskar.c, what files will be created at each step of compilation? b. Can we compile an erroneous code in C? If we do not write the function main() in our C program, will it compile successfully? c. What is a programmer’s view of memory? Is it different from actual memory? Explain briefly. 4. Programming assignments : a. Write and execute a C program to print your name. b. Write and execute a C program to print your name and your mother’s name in two different lines but using a single printf. c. Write and execute a C program to print the sentence “I am from Assam. I am a responsible citizen of my country.” five times. d. Remove the semicolons (;) from the C program of the previous question. Compile the program and check the errors. Note the line numbers and then rectify them. e. Write and execute a C program to print your name in the order Last name First name. But you will pass them in First name Last name order inside printf [Hint: use proper escape sequence]. 155

EXPLORING 9CHAPTER C PROGRAMMING LANGUAGE “The only way to learn a new programming language is by writing programs in it.” - Dennis Ritchie (The developer of C language) In this chapter, we will have a deeper look at the C programming language. In the process, we will learn several program elements of the language. We will learn to write simple programs in C using different operators. We will learn about conditional operators and others. 9.1 IDENTIFIERS AND KEYWORDS The creator of the C programming language, scientist Dennis Ritchie said if we need to learn a new programming language, we must write programs in that language. Hence we spend some time knowing several other important features of the language C and then we should write programs us- ing those features. Let us start with identifiers and keywords. A character set in C is formed using i) the upper case letters from A to Z, ii) the lower case letters a to z, iii) digits from 0 to 9 and iv) some special characters such as *, %, _, +, -, =, #, <, > and others. C makes use of the character sets to form identifiers. Identifiers are used as variable names, function names and others. A valid identifier is a combination of letters and digits that starts with a letter. We list some of the valid and invalid identifiers of C. Some valid identifiers in C: x, Y, x24, area, sum_1, rate_of_interest, SUM nFo int fodbQreoute iuhniatcecg khtTvha aoaecblftirlditee vhaii aedtsbymoeo:nnvfst rei fof.iomerrs S2onTmda,berleaint9ev.1-a:olSfi-doimnietdeevraneltisditf,aiencrdirsicnilvnealaCidr:eidae, n“txif”i,er_sxinyC. 156

C reserves a few identifier names for some special purposes and they cannot be used other than their dedicated purpose. These identifiers are called keywords. We list a few of the commonly used keywords with their meanings in Table 9.2. Do not worry if you do not understand the meanings of these words right now. We will keep on learning them as we learn more about C programming. Identifiers Meanings / Major usages int, char, double, float, void Represent type of data if, else, switch, default Used in conditional statements for, while, do, break, continue Used in loop Table 9.2: Some commonly used keywords in C. 9.2 VARIABLE, DATA TYPES AND FORMAT SPECIFIERS A variable is an identifier that is used to store some value within a program. The value stored in a variable can change during the execution of the program. A variable must be declared first before it is used in the program. Every variable is associated with a type from the declaration itself. This is called the data type of a variable. Following is a statement in C to declare a variable ‘x’ of type integer with an initial value of 7. int x = 7; When we declare a variable in a program, a certain amount of memory space is allocated for the variable to store its value. Depending on the data type, the amount of memory space varies and thus the range of values the variable can store also varies. When we want to print the value of a variable, we need to specify this using the appropriate format specifier of its type. Same is the case for accepting the value of a variable from the keyboard. The following statement prints the value of variable x on the output screen. printf(“Value of variable x is %d”,x); Table 9.3 lists some built-in datatypes in C with their typical storage requirements and format specifiers. In addition to these built-in data types, C supports derived data types like array, structure, pointer, etc. We will study them in class X. DATA TYPE STORAGE RANGE FORMAT char (in bytes) 0 to 255 or -128 to 127 SPECIFIER int 1 -2,147,483,648 to 2,147,483,647 %c 4 %d unsigned int 4 0 to 4,294,967,295 %u long long int 8 -(2^63) to (2^63)-1 %lld float 4 1.2E-38 to 3.4E+38 %f double 8 2.3E-308 to 1.7E+308 %lf Table 9.3 : Built-in data types of C programming language. 157

We have already seen printing messages and variables on the screen. Let us now see how we can accept input to the program from users. We may use another library function scanf() for this. Scanf() is one of the commonly used built-in functions to take input from users. The scanf() function reads formatted input from the standard input devices such as keyboards. The following lines of code will accept an integer value for the variable y. int y; printf(“Please enter value for y: “); scanf(“%d”, &y); The variable name is prefixed by a symbol ampersand (&). This indicates the address of the variable in computer memory. Scanf() function requires the address of the variable to read input in it. You may enter any valid integer value from the keyboard. Please remember the printf() statement is written just to inform the user for entering the integer value. This is not a mandatory statement here. You may refer Example 9.1 for the complete program. #include<stdio.h> int main() { int var; printf(“\\n Please enter some integer value “); scanf(“%d”,&var); printf(“\\nYou have entered %d as value for var”,var); return 0; } Example 9.1: A C program to take an integer from keyboard and to display it. 9.3 OPERATORS IN C We have learned declaring variables, taking input in a variable from the keyboard and to print its value. We now learn applying operations on the variables. C supports a large number of operations. The following statement in C indicates an operation. x = y + 2; In the above statement, x and y are variables, 2 is a constant. Both y and 2 are called operands and + is called the operator. The combination of variables, constants and operands here formed an expression in C. The operator that requires two operands is called a binary operator. The one that requires 158

only one operand is called a unary operator. The above statement uses another operator called assignment (=). Assignment operator is used to assign a value to a variable. The previous value of the variable is lost and the new value (calculated from right side) is stored in the variable. #include<stdio.h> int main() { int num1, num2, sum; printf(“\\n Please enter the first integer: “); scanf(“%d”,&num1); printf(“\\n Please enter the second integer: “); scanf(“%d”,&num2); sum = num1 + num2; printf(“\\n Summation of %d and %d is %d”,num1, num2, sum); printf(“\\n Thank you!”); return 0; } Example 9.2: A C program to calculate summation of two numbers. Example 9.2 depicts a C program to find the summation of two numbers. Both the numbers are taken from the keyboard using scanf(). You have seen that we have printed three variables using only one printf() function. In this case, we need to write the variable name in the same order they appear in format specifiers. Now let us spend some time learning about different types of operators provided by C language. Following table lists some commonly used operators with their types. We will use some of them now and will use the rest in class X. OPERATOR TYPE OPERATORS Arithmetic +, -, *, /, % Relational <, >, <=, >=, = =, != Logical &&, ||, ! Biwise &, |, <<, >>, ~, ^ Assignment =, +=, -=, /=, %= Unary + +, - - Table 9.4: Some of the commonly used operators of C programming language. Arithmetic operators are mainly used for mathematical calculations: addition (+), subtraction (-), multiplication (*), division (/) and reminder (%). Relational operators are used to compare values of two expressions and produce binary output (true or false) depending on the condition and the values of the operands. For example, if a=5 and b=7, then a > b will produce false. Now recall our discussion in Chapter 7 that if we know the logic of a problem, we can simply put that using the syntax of the programming language to write the program. 159

Let us say, we need to calculate the area of a circle. If we know the formula, we can easily write a C program for the same. We will take the radius of the circle as input and write the formula of the area (3.14 x r2) in C notation using different operators (3.14*r*r). Example 9.3 shows the complete C program and Figure 9.1 shows the screenshot of the program written using Codeblock. #include<stdio.h> int main() { float radius, area=0.0; printf(“\\n Please enter the value of radius: “); scanf(“%f ”,&radius); area = 3.14*radius*radius; printf(“\\n The area of the circle is %f ”,area); printf(“\\n Thank you!”); return 0; } Example 9.3: A C program to calculate area of a circle. Figure 9.1: C program screenshot of Example 9.3 160

C also supports three logical operators AND (&&), OR (||) and NOT (!). These operators also produce binary outputs depending on the expressions and the operator. For example, if a=0 and b=1, then a && b will produce false. Similarly, a||b will produce true and !(a&&b) will produce true. In the next section, we will see a program (Example 9.5) that uses AND (&&) operator. In addition to the operators listed above in the table, C supports some special operators like sizeof(), pointer operators (*), member selection operators (., ->), etc. We will study these operators along with the rest of the operators from the above table in class X 9.4 CONDITIONAL STATEMENTS Till now we have written programs where every statement in the main() function executes. They are executed in the order they appear in the code and they are executed only once. But many times, the problem we are given to solve is not that simple. The solution of the problem may require to execute only a set of statements depending on some logical test. This is called branching. Moreover, a statement might require to be executed more than once. This is called looping. We now see addressing such scenarios in C programming. #include<stdio.h> int main() { int num1, num2; printf(“\\n Please enter the first integer: “); scanf(“%d”,&num1); printf(“\\n Please enter the second integer: “); scanf(“%d”,&num2); if (num1 > num2) printf(“\\n First number is greater than the second number”); if (num1 < num2) printf(“\\n First number is smaller than the second number”); if (num1 == num2) printf(“\\n Both the numbers are equal”); printf(“\\n Thank you!”); return 0; } Example 9.4: A C program to compare two numbers using if statement 161

Branching: if, else-if, switch Let us first have a look in the C program as shown in Example 9.4. The program compares two numbers entered by a user from the keyboard to check whether one number is greater than the other, smaller than the other or both the numbers are equal. When we run the program, we see that depending on the value we enter from the keyboard, we see output from only one printf() statement (from the last three printf() statements). This means that out of three print statements, only one executes. We achieved this using a if statement. Whenever the condition inside if() is true, the enclosed statement of the if executes. Whenever we want to enclose more than one statement with an if, we put the statements inside two curly braces. See the following code segment below. if (num1 > num2) { greater = num1; printf(“\\n First number is greater than the second number”); } There is another clause called else in C. Whenever only one condition coYmQocupuhleimecctkkeayatpchwrteoirvgoiitruteaytmtp:hueatn. d will be true out of a set of conditions, we may put them using if-else or if-else if-else construct. The last three if statements of Example 9.4 can be replaced with the following set of statements. if (num1 > num2) printf(“\\n First number is greater than the second number”); else if (num1 < num2) printf(“\\n First number is smaller than the second number”); else printf(“\\n Both the numbers are equal”); We now combine the if clause with the logical AND operator in another program as shown in Example 9.5. The program checks whether the first number is the largest one among three given num- bers. pYroougnQmruamuamyibctnkenoroaufwacimmntiedbvxoiettnterhygsne:.tdlhatrrhegieesst In this example, we first saw that we can accept inputs to more than one variable using a single scanf() function. Then we saw using logical AND operator in between two expressions. The if statement in the program checks whether num1 is larger than both num2 and num3. If yes, the print statement is executed. 162

#include<stdio.h> int main() { int num1, num2, num3; printf(“\\n Please enter three integers: “); scanf(“%d%d%d”,&num1,&num2,&num3); if ( (num1 > num2) && (num1 > num3) ) printf(“\\n Number1 is the largest and its value is %d”,num1); printf(“\\n Thank you!”); return 0; } Example 9.5: A C program to check whether a number is the largest among three numbers. Switch case statements If we need to do a selection of statement execution in a program based on some integral value, we can use switch () construct of C. The value of the expression inside the switch() construct directs to different cases and accordingly a block of statements are executed for one case. #include<stdio.h> int main() { int place; printf(“\\n Please enter your choice: \\t 1:Bilasipara \\t 2:Guwahati \\t 3:Sivasagar \\t:”); scanf(“%d”,&place); switch(place) { case 1: printf(“You pressed 1”); printf(“\\n Bilasipara is a sub-division town of Dhubri district.”); break; case 2: printf(“You pressed 2”); printf(“\\n Guwahati is the largest city of Assam and it is the Gateway to North East India.”); break; case 3: printf(“You pressed 3”); printf(“\\n Sivasagar is a beautiful city of Assam and it has many historical significance.”); break; default: printf(“You pressed %d”,place); break; } return 0; } Example 9.6: A C program to switch construct. 163

Keywords learned in this chapter C-keywords Variables Data Types Operators Conditional Statements, Branch Loop if-else switch sizeof() ADDITIONAL CONTENTS FOR CHAPTER 9 A. Tips for good programming practice The ability to write good programs is always appreciated. Good programs include many things: easy to read, faster execution, lesser memory requirement and others. Let us have some simple tips to make a program easier to read. 1.Variable naming : Variables used in the program should be named appropriately. The name should represent its purpose. For example, if we need to store the roll number of a student, some appropriate proper variable names can be rollNumber, rollNo, roll, etc. 2. Proper indentation : The program should look good. The lines in the program should be properly justified. Figure 9.1 shows this clearly. 3. Writing comments : It is a good practice to write comments along with the program. Comments will not be executed by the compiler. But these will help when we read the program at a later point in time. Comments are also helpful when someone else needs to go through the program for making some changes in it. This situation is so common in an industry where programs are written by many people in a team. Example B.5 shows a well commented program in C. When we want to comment a single line in C programming, we put double slash (//). When we want to comment more than one line, we enclose them inside /* and */. Whenever you write a program now onwards, you should always try to follow the above mentioned tips. You may also follow other tips you acquire from other genuine sources. This will help you to become a good coder oneday! All these rules are not followed in all the example programs because you are the beginner of the programming language and seeing many comments (or lengthy variable names) inside the programs may hamper your learning. 164

INDENTATION MAINTAINED INDENTATIONS NOT MAINTAINED int main() int main() { { int num1=5, num2=7; int num1=5, num2=7; if (num1 > num2) if (num1 > num2) printf(“First one greater”); printf(“First one greater”); else if (num1 < num2) else if (num1 < num2) printf(“First one smaller”); else printf(“First one smaller”); printf(“Equal”); else return 0; } printf(“Equal”); return 0; } Figure 9.1: Two programs showing indentation. Program Examples B. Programming Examples It is said that programming is a skill and we know that practice is the only way to acquire a skill. Let us present some additional programming examples here. You are highly encouraged to practice these examples. You should also try to write all the programs from the exercise. In addition, whenever you learn some equations in other subjects (Science, Mathematics, etc.), you should try to write C programs for the same. /* A program in C to find the average of five integers */ #include<stdio.h> int main() { int num_1 =10, num_2=20, num_3=30, num_4=40, num_5=50; float avg = (num_1+num_2+num_3+num_4+num_5 )/5; printf(“\\n Average of all the numbers is: %f ”, avg); return 0; } Example B.1: A C program for finding the average of five given numbers. 165

/* A program in C to calculate simple interest. */ #include<stdio.h> int main() { int principal_amount, no_of_year; float rate_of_interest, interest_amount=0; printf(“\\n Please enter principal amount: “); scanf(“%d”,&principal_amount); printf(“\\n Please enter rate of interest: “); scanf(“%f ”,&rate_of_interest); printf(“\\n Please enter number of years: “); scanf(“%d”,&no_of_year); interest_amount = principal_amount*no_of_year*rate_of_interest/100; printf(“\\n The calculated simple interest is: %f ”, interest_amount); return 0; } Example B.2: A C program for finding simple interest. /* A program in C to swap two variables */ #include<stdio.h> int main() { char char1=’x’, char2=’y’, temp; printf(“\\n Characters before swap are: %c and %c”, char1, char2); temp = char1; //temp stores the first character char1 = char2; // first character is replaced by second character char2 = temp; //second character is restored back from temp printf(“\\n Characters after swap are: %c and %c”, char1, char2); return 0; } Example B.3: A program in C to swap two variables. 166

/* C program to find the digits of a number */ #include<stdio.h> int main() { int number=0, d1, d2, d3, d4, d5, temp; printf(“Enter a 5-digit number and press ENTER: “); scanf(“%d”,&number); temp = number; d5=temp%10; temp = temp/10; d4=temp%10; temp = temp/10; d3=temp%10; temp = temp/10; d2=temp%10; temp = temp/10; d1=temp; printf(“\\n Digits are: %d %d %d %d %d”, d1, d2, d3, d4, d5); return 0; } Example B.4: A program in C to find the digits of a number. #include<stdio.h> int main() { int mark_eng; //mark for English int mark_asm; //mark for Assamese int mark_sci; //mark for Science int mark_soc; //mark for Social Science int mark_math; //mark for Mathematics int mark_comp; //mark for Computer int mark_total; // Total marks scored by a student float marks_average; //Average marks of 6 subjects /* Getting marks for different subjects from keyboard as entered by an user of the program */ printf(“\\n ::: Welcome to SEBA Student Marking System ::: \\n”); 167

printf(“\\n Please enter mark for English and press ENTER: “); scanf(“%d”,&mark_eng); printf(“\\n Please enter mark for Assamese and press ENTER: “); scanf(“%d”,&mark_asm); printf(“\\n Please enter mark for Science and press ENTER: “); scanf(“%d”,&mark_sci); printf(“\\n Please enter mark for Social Science and press ENTER: “); scanf(“%d”,&mark_soc); printf(“\\n Please enter mark for Mathematics and press ENTER: “); scanf(“%d”,&mark_math); printf(“\\n Please enter mark for Computer Science and press ENTER: “); scanf(“%d”,&mark_comp); /* Marks are taken from keyboard; now doing calculation... */ mark_total = mark_eng + mark_asm + mark_sci + mark_soc + mark_math +mark_comp; printf(“\\n Total marks scored by the student is: %d”, mark_total); marks_average = mark_total / 6; printf(“\\n Average marks scored by the student is: %f ”, marks_average); /* Calculation is done; now checking grade... */ if ( marks_average >= 60.0) printf(“\\n The student obtains FIRST division.”); else if ( (marks_average < 60.0) && (marks_average >= 45.0) ) printf(“\\n The student obtains SECOND division.”); else if ( (marks_average < 45.0) && (marks_average >= 30.0) ) printf(“\\n The student obtains THIRD division.”); else printf(“\\n The student is declared FAIL.”); printf(“\\n \\n ... Thank you! ...”); return 0; } Example B.5: A C program for finding the grade of a student based on the marks entered from the keyboard. 168

TEACHERS’ NOTE 1. While writing programs, show different permissible and non-permissible things in C. [For example, demonstrate a C program to show that C ignores additional white spaces.] 2. Demonstrate all the programming examples given in the book. Run the programs with different inputs. 3. Whenever the students encounter any formula or equation in other subjects, encourage them to code those in C. Demonstrate some of them. 4. We have used Codeblock to demonstrate the programs. If needed, please use other editors/IDEs and demonstrate the same to the students (as mentioned in Section 8.2). 5. While teaching, please emphasize on the fact that “Coding is not typing”; coding primarily involves thinking; coding enables our computer to do something we want. 6. The programs provided in the book are mainly to explain different features of the C language and the concept involved. Students should practice similar programs as well using the features they learn. 7. Some additional C programs are available on the website www.manojitghose.com/seba. You may use them in your class if needed. Exercises : 1. Fill in the blanks. a. Identifiers in C programming language start with ……… b. break is a keyword in C ……………. (TRUE/FALSE) c. A variable in C can store more than one value at a time ……… (TRUE/FALSE) d. An integer variable typically reserves ……………… bytes in memory. e. Built-in function used to accept user input from the keyboard is ……….. f. Format specifier for accepting value from keyboard for an integer variable is ………….. g. Every operator in C requires exactly two operands ……… (TRUE/FALSE) h. .....…........…. sign is used to indicate reminder operation in C. i. To compare two float variables in C, we can use ……… statement. j. When we need to select a set of statements for execution in a C program based on some integral value, a good choice can be to use ………… construct. 2. Short answer questions: a. If we need to execute many statements when an if condition in C returns true, how can we write them? Write a code segment. b. List five commonly used operators of C programming language with their meaning. c. The scanf statement should always be preceded by a printf statement in C. Is it true? Explain briefly. 169

3. Programming assignments: a. Write a C program and try to declare variables of type int with the following variable names separately. first_variable, secondVariable, ThirdVariable, char, number, -, --, _x, 9months, blp24, 8724, dimatala, gogamukh??, I want to be a doctor. Report if any variable declarations are not permitted by the compiler. Analyze the reasons (Hint: refer Section 9.1). b. Write the following code segment inside the main() function of a C program and run it. Analyse the output. Relate the output with the concepts learned in Section 9.2 about the allocated space of a variable in computer memory. int var = 7; printf(“The value of var is %d. “, var); printf(“The address of var in memory is %p.”, &var); c. Write the following code segment inside the main() function of a C program and run it. Analyse the output. Relate the output with the concepts learned in Section 9.2 about the allocated space of a variable in computer memory. int p = 9; printf(“Size of the variable p is %ld \\n”, sizeof(p) ); printf(“Size of an integer is %ld \\n”, sizeof(int) ); printf(“Storage for the type of the variable p is %ld \\n”, sizeof( typeof(p) ) ); d. Write a C program to do the following. i. Declare three integer variables as int p = 9, q = 7, result = 0; ii. Display the value of the result variable after performing the following operations and storing the output of each operation in it. p + q; p - q; p / q; p * q; p % q; p + q; (p & q); (p && q); iii. Perform ++result; result++; result - -; Display value of result at each step. e. Write a C program to find the area of a rectangle. The length and width of the rectangle are inputs. f. Change the programming example B.1 to accept the integers from the keyboard using scanf() function. g. Improve the programming example B.5 to check whether the student scores PASS or FAIL in individual subjects [Hint: use if clause]. h. Improve the programming example B.5 to check whether every mark entered from the keyboard is positive or not. If any mark is wrongly entered as negative, prompt the user to re-enter. [Hint: use if clause and then put scanf()]. i. Write a program in C for awarding student grade (as example B.5) using switch-case construct. 170

RECENT 10CHAPTER DEVELOPMENTS IN IT “IT + IT = IT; Indian Talent + Information Technology = India Tomorrow” - Narendra Modi, The Honorable Prime Minister of India. We live in the era of Information Technology (IT). IT has touched every segment of human life and it has brought a radical change. It has found its applications in every sector including agriculture, manufacturing, mining, business, healthcare, service industries and others. In this chapter, we will briefly study about the recent developments in various domains of IT. 10.1 COMPUTER HARDWARE Let us first see some of the recent technologies in hardware (specially processor) that are available in the market. We will also have a look at some of the very recent developments that are still in the research stage (product is not available in the market). 10.1.1 Multicore architecture and GPU In Chapter 1, we have seen that computers have a processing element in them and that is called the CPU. When the CPU consists of multiple processing elements within it, we call it a multicore system. A processing element is popularly known as a core. For example, Intel i7 processor series has 4 to 6 cores with 2 threads of execution per core. The cores operate in a coordinated manner and share the system resources (such as memory) among them. Figure 10.1 shows a diagrammatic representation of a multicore system with four cores. We know that the speed of a computer is mainly determined by the clock frequency of the processor (expressed in GHz). But with a significant increase in the clock frequency, the processor temperature increases significantly. On the other hand, as the number of cores in a system increases, the overall processing capability of the system increases. This makes the system faster. However, putting many cores together brings other complexities such as managing shared re- sources, scheduling applications, area of the chip, etc. 171

Figure 10.1: Diagramatic representation of a multicore architecture Multicore processors are widely used across many application domains, including general-pur- pose, network, embedded, digital signal processing (DSP), and graphics (GPU). Out of these, as a general user, we often come across the term GPU specially for its usage in gaming. We know it as a graphics card. Graphics card contains GPU on it. GPU is a specialized, elec- tronic circuit designed to rapidly manipulate and alter memory for faster output to a display device. GPUs are highly parallel architectures and consist of hundreds of smaller cores. Several programming languages such as OpenCL, CUDA, and Halide are being used for writing programs that can be efficiently run on GPUs. Figure 10.2: Diagramatic representation of 3D NoC. 172

10.1.2 System-on-chip When a chip contains multiple cores on it, they form a network and communication takes place among them. All the cores are equipped with an additional hardware called router for communication purposes. This is called network-on-chip (NoC). The cores are used to be organized on a X-Y plane. But in the recent developments, the cores are being placed in different layers: one layer on top of another. The layers are connected using a special technology called through silicon via (TSV). This system is called 3D NoC and research is going on to build processors and memory using this technology. 10.1.3 Near or In-memory computation Another interesting development in the field of computer hardware is near or in-memory com- putation. We have learned in Chapter 1 that a computer has several components; CPU and memory are two such components. Whenever a CPU operates on some data (say adding two numbers), it brings the data from memory. When the size of the data is huge or when the data resides at a dis- tance, it takes a significant amount of time to bring data. The near or in-memory computation paradigm says that the computing element (also called the processing element) should be placed where data resides (that is memory or storage). This paradigm becomes prominent with the introduction of 3D architecture we discussed in the last section. This is another promising field where research is going on in full swing both by industries and academic institutions. 10.2 ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING Another popular topic of today’s era is artificial intelligence (AI) and machine learning. Let us discuss these terms briefly. In simple ways, AI can be defined as the intelligence capability of a machine. This includes whether a machine can learn from its own or it has a problem solving ability or not. Leading textbooks define AI as the field of study of a device that perceives its environment and takes actions that maximize its chance of successfully achieving its goals. The field of study was founded in 1955 but it did not receive much attention. After AlphaGo (it is a computer program that plays the board game Go) successfully defeated a professional Go player in 2015, artificial intelligence has gained the attention of the research com- munity. AI consists of many sub-fields of study and machine learning is one of them. In simple terms, machine learning (ML) means a technique where a machine can learn from its experience. Here machine implicitly means a computer. Machine learning algorithms are based on some models and the model is to be trained first using a large dataset before its actual use. Suppose we want to build a handwriting recognition system. Now, one person may write a letter very differently from another. But the machine should be able to correctly identify that. To do so, we should first feed the system with many sample writings with the correct answers. 173

The model will go through it and learn. Learning essentially means to extract some features (or characteristics) from the dataset so that it can correctly take the decision depending on the values of these features. The training is a computationally expensive task and requires a huge amount of time. One special class of ML is deep learning (DL) that is based on an artificial neural network (ANN) and uses multiple layers to extract higher-level features from the input. An ANN is based on a collection of connected units or nodes called artificial neurons, which loosely model the neurons in an animal brain. Each connection, like the synapses in a biological brain, can transmit a signal to other neurons. An artificial neuron that receives a signal then processes it and can signal neurons connected to it. The signal in case of an ANN is a real number, and the output of each neuron is computed by some non-linear function of its inputs. Figure 10.3 shows an ANN with one hidden layer. . Figure 10.3: An example of an artificial neural network with one hidden layer A paradigm of ML where we do not have any labelled training data (labelled data means data having output) and the machine completely learns from the environment is known as reinforcement learning (RL). Upon taking a decision, the machine receives some reward and it takes actions in an environment in order to maximize the cumulative reward. Because of the availability of high performance computers, these learning based techniques are being used almost in every field including operations research, game theory, information theory, control theory, simulation-based optimization, product recommendation, self-driving cars, language translators and others. 10.3 RECENT APPLICATION DOMAINS Let us now briefly discuss some of the popular applications of current time and the computa- tion behind them. 174

10.3.1 Robotics Robotics involves developing machines that can substitute for humans and replicate human actions. This is an interdisciplinary research area that includes information engineering, mechanical engineering, electronic engineering, bioengineering and others in addition to computer science and engineering. The machine runs several complex algorithms to sense the environment, to move the arm of the robot and others. One emerging field of robotics is Robotic Surgery where doctors and engineers work hand in hand with a common goal. A computer scientist mainly contributes to this field of study by developing efficient algorithms and writing programs for different operations. Nowadays, very simple interfaces are available for the beginners (like school students) to program some simple robots using drag-and-drop software like Scratch. You may try using them if Robotics or Atal Tinkering or similar labs are set-up in your school. 10.3.2 Natural language processing (NLP) This is another interesting example of AI that deals with the interactions between computers and human language. This is a collaborative field of study between computer science and linguistics. The goal is to write computer programs to process and analyze large amounts of natural language data so that the computer understands the language with the contextual nuances of the human lan- guage. The program should understand the contents of documents, extract information from them, categorize them and so on. NLP has found its applications in translators, word processors, IVR (in- teractive voice response) systems, personal assistant applications such as Siri, OK Google, Alexa and Cortana. The inherent ambiguous nature and the variety of expression of the natural languages make this problem challenging for the computer scientist. 10.3.3 Internet of things (IoT) IoT in simple terms means everything we use in our daily lives (our tee shirt to window curtains, toothbrush to pen, etc.) will be smart and connected to the Internet. These items will be embedded with some sensors, computing and communication elements so as to connect and exchange information with other items or systems. IoT has found its usages in every sector including healthcare, home appliances, manufacturing, agriculture and others. This is another active field of research to build efficient hardwares, softwares and communication infrastructure. The number of IoT devices connected to the Internet is expected to be 26 billion soon. 175

10.4 COMPUTING AS A UTILITY SERVICE Till now we have talked about recent developments in computer hardware, software and algorithmic techniques. These are to improve the capability of our computing systems. With an increase in the capability, the cost of the system also increases. Being a user, we see that our old system becomes obsolete and we often need to upgrade them. Sometimes, it is not worthy to incur such an expenditure. This observation has popularized computing as a utility service after water, gas, telephone and electricity. The situation is analogous to the car renting service (Ola, Uber etc.). We do not buy a car; we rent it whenever we need it. Let us discuss some recent developments in computing service technology. 10.4.1 Cloud computing Cloud computing is a resource sharing computing platform that offers a large amount of space and computing capability to its users via the Internet. The users are charged as a “pay-as-you-go” model based on their resource usages. Computers with high compute and storage capacities are placed in data centers. Users will rent the machines depending on their requirements and they are charged by the service providers based on their use. Figure 10.4: Cloud computing architecture Figure 10.4 shows an abstract view of the architecture of a typical cloud computing platform. It consists of an application layer, a virtualization layer, and a hardware layer. The user submits their jobs at the application layer and the actual execution happens at the hardware layer. Each machine contains a set of virtual machines (VM) of different size and capabilities. These 176

VMs are rented by users and VMs in the system can be added or removed seamlessly depending on the user demand. Some popular cloud service providers of recent times are Amazon Web Services (AWS), Microsoft Azure, Google Cloud, etc. 10.4.2 Mobile cloud computing You might have seen that nowadays, we run a wide range of applications on our mobile phones. Along with the traditional mobile phones, IoT devices, autonomous vehicles are entrusted with performing several compute-intensive applications such as, augmented reality, image processing, etc. Many times, these devices run applications that are of critical nature. But these devices are resource-constrained and mostly run on battery. Hence, the integra- tion of these devices with the cloud computing platform becomes a popular choice. This is known as Mobile Cloud Computing (MCC) which allows a mobile device to send some or all of its compute-intensive tasks to the cloud so that battery power can be saved along with achieving other benefits. The process of sending tasks to MCC is termed as offloading. 10.4.3 Mobile edge computing MCC however comes with an overhead resulting from the data transmission delay. This might so happen that the benefits drawn by offloading the computation is lesser than the data transfer delay overhead. Sometimes, the applications may not permit such a long latency. In addition, MCC requires a high Internet bandwidth. To overcome this problem, mobile edge computing (MEC) has been introduced which brings computation closer to the user. An example of MEC system is shown in Figure 10.5 where a few mobile devices (MDs) are connected to some roadside units (RSU). These RSUs along with some computation systems form the MEC server. Again the MEC server is connected to the cloud system. Figure 10.5: An example of MEC architecture 177

The basic principle of MEC is to bring computation power of MCC to the edge of a network close to the users or the MDs. The applications running on MDs can then send the compute-intensive tasks to the nearby MEC servers at a lower overhead. A wide range of mobile applications nowadays tend to avail the MEC services for providing better quality of experience (QoE) to the users. Emerging applications for distributed content delivery and caching, web performance enhancements, various smart city services in the domains of healthcare, transportation, energy, manufacturing and industrial automation heavily rely on MEC infrastructure for task execution. Keywords learned in this chapter Multicore GPU Network-on-Chip AI Machine Learning Reinforcement learning Robotics Natural language processing (NLP) Internet of things (IoT) Cloud computing Mobile cloud computing Mobile edge computing Offloading 178

Exercises : 1. Fill in the blanks. a. A multicore system has only one processing element within it. ……………. (TRUE/FALSE) b. Processor temperature ………. with a decrease in its operating clock speed. c. GPU stands for ……………………………… . d. In order to facilitate communication, the cores are embedded with ..….. in case of NoC. e. Alexa is an example of …………………………… . f. IVR stands for ……………………………………. . g. The expected number of IoT devices connected to the Internet soon is ……... crores. h. Amazon web service is ………………………… . i. Sending part of an application from the mobile device to powerful machines for its efficient execution is known as ……………. . 2. Short answer questions (Answers should preferably be of 2-3 lines): a. Define a multicore system. Is Intel i7 a multicore system? Explain briefly. b. What is GPU? Why do we need GPU in our computer system? c. Define 3D NoC architecture. What technology is typically used for connecting one layer with another in case of 3D NoC architecture? d. What is NLP? Mention one of the critical challenges of NLP. e. What is utility computing? Write one of the primary reasons for its popularity in recent times. f. What is mobile cloud computing? How does this technology become handy for the mobile phones to run several applications? g. Write one of the major challenges of MCC while running critical user applications. 3. Long answer questions (Answers should preferably be of 5-6 lines): a. Is multicore system a good choice? Explain with its merits, demerits and challenges. b. What is near memory computation? How is it different from traditional computation? Why are scientists doing research on memory computation? c. What is machine learning? Explain its importance in today’s era. d. What is an artificial neural network? Differentiate between deep learning and reinforcement learning. e. Write a short note on cloud computing. f. What do you understand by the term IoT? How can IoT impact human lives in the near future? g. Explain MEC framework with a diagram. How is it different from MCC? 179

CASE STUDIES 11CHAPTER APPLICATIONS OF IT IN DAILY USE 1. DISCUSSION OF DIFFERENT CAREER OPTIONS AND OPPORTUNITIES IN INFORMATION TECHNOLOGY. Swadesh is a student of ABC National School, Hyderabad. A career fare is held in his school. Mr. Reddy, a career counselor, came as the speaker in the occasion. Mr. Reddy discuss about the recent trend in different industries. He talked about the most fast developing field, i.e., about Information Technology. Mr. Reddy told “Since almost every aspect of our lives has become intertwined with technology, it comes as no surprise that some of the most sought-after career opportunities can be found in the Information Technology industry, or IT for short. Not only does this career choice offer a chance to make substantial income, but they also promise long-term employment as it seems like the technology will only continue growing.” He also told “It is also important to mention that this industry is one of the rare ones where experience and the readiness and willingness to learn is usually valued more than the education you received. This is due to the fact that this industry is experiencing such rapid growth that some things you might have learned today are already replaced by different way and new methods to- morrow.” Swadesh and his friends were very much inspired by Mr. Reddy and his speech. Regarding the career options in IT, Swadesh and his friends knows that Software Engineer and Hardware Engineer is the only options in IT. But Mr. Reddy speaks about another 10 career options: A. Support Specialist F. Computer Programmer B. Web Developer G. IT Technician C. System Analyst H. Network Engineer D. Database Administrator I. Web Administrator E. IT Coordinator J. Data Entry Operator If you are Swadesh, which IT career option will you choose and why. 180

2. MAKING YOUR BIODATA IN MS-WORD Sameer Ali, a Class 12th passed student, is a boy from a poor family. His father and mother are aged. So he has to run his family doing part time jobs till Class 12. After passing Class 12, he is in urgent need for a full time job. One day, while reading newspaper, he comes across a job advertisement (looking for a fresher for office works). His profile matches with the job advertisement. In that advertisement, it has been mentioned that the candidate’s bio – data to be made and send as an attachment. But Sameer is confused in which software he has to create the bio data. If you are Sameer, how will you create your bio data and in which software will you use? (Consider yourself as Sameer) 3. CREATING A BROCHURE FOR YOUR SCHOOL IN MS-WORD Centre of online studies is organizing virtual alumni Meet for the pass out batches of your school. It will be an interactive session between the ones who pass out in covid-19 situation where the studies held only through online mode. As a creative head of the organizing committee you are suppose to make a brochure in word document of upcoming event. 4. CREATING REPORT CARD IN MS-EXCEL World is changing and changing environment has not only give us bad experience, but also make us more techno savvy. 2020 – 21 has a session of full of new learning experiences where we have explore enormous options of making our teaching profile more effective. Principal of ABC National School, Hyderabad ask all teachers to make final session report card in MS-Excel. Consider yourself as a teacher of Grade IX, make a report card of your class using MS–Excel. 5. CREATING A PRESENTATION IN MS-POWERPOINT WITH BIOGRAPHY OF GREAT PERSONALITIES OF INDIA. Consider yourself a student of Grade IX. Your History teacher have just narrated you the story of Independence of India, efforts, hard work and sacrifices done by our great leaders. Your teacher has asked to give you a PowerPoint presentation on 15th August. Create a presentation in MS – PowerPoint with biography of any great personalities which inspire you the most. 181

182

References 1. Brian W. Kernighan and Dennis Ritchie, The C Programming Language, 2nd edition, Pearson, 2015. 2. https://en.wikipedia.org/ 3. https://www.codeblocks.org/ 4. Byron S Gottfried, Programming with C, 4th edition, McGraw Hill, 2018. 5. David A. Patterson, John L. Hennessy, Computer Organization and Design: The Hardware/Soft- ware Interface, 5th edition, Elsevier, 2016. 6. P. Mell and T. Grance, The NIST definition of cloud computing, National Institute of Standards and Technology, vol. 53, no. 6, 2009. 7. V. Chaturvedi, A. K. Singh, W. Zhang and T. Srikanthan, “Thermal-aware task scheduling for peak temperature minimization under periodic constraint for 3D-MPSoCs,” 25th IEEE International Sym- posium on Rapid System Prototyping, pp. 107-113, New Delhi, India, 2014. 8. Ghose, Manojit (2018), Energy Efficient Scheduling of Real Time Tasks on Large Systems and Cloud. (Doctoral thesis, Indian Institute of Technology Guwahati, Assam). Retrieved from http:// gyan.iitg.ernet.in/handle/123456789/1194. 9. V. Deka, C. Guleria and M. Ghose, “TEAM: Time and Energy Aware Application Partitioning and Resource Allocation Strategy on MEC Platform,” 2020 IEEE 17th India Council International Con- ference (INDICON), pp. 1-7, New Delhi, India, 2020.






Like this book? You can publish your book online for free in a few minutes!
Create your own flipbook