A flow chart is a graphical or symbolic representation of a process.

Similar documents
Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition

JAVA OPERATORS GENERAL

GO - OPERATORS. This tutorial will explain the arithmetic, relational, logical, bitwise, assignment and other operators one by one.

Introduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9

Operators in C. Staff Incharge: S.Sasirekha

Basic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

Expressions and Precedence. Last updated 12/10/18

Operators. Java operators are classified into three categories:

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following g roups:

SECTION II: LANGUAGE BASICS

Computers Programming Course 6. Iulian Năstac

Operators in java Operator operands.

Unit-2 (Operators) ANAND KR.SRIVASTAVA

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

Informatics Ingeniería en Electrónica y Automática Industrial

Unit-II Programming and Problem Solving (BE1/4 CSE-2)

Will introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators

.Net Technologies. Components of.net Framework

Chapter 3: Operators, Expressions and Type Conversion

A complex expression to evaluate we need to reduce it to a series of simple expressions. E.g * 7 =>2+ 35 => 37. E.g.

I Internal Examination Sept Class: - BCA I Subject: - Principles of Programming Lang. (BCA 104) MM: 40 Set: A Time: 1 ½ Hrs.

UNIT- 3 Introduction to C++

CP FAQS Q-1) Define flowchart and explain Various symbols of flowchart Q-2) Explain basic structure of c language Documentation section :

Information Science 1

Programming in C++ 5. Integral data types

Le L c e t c ur u e e 2 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Variables Operators

Unit 3. Operators. School of Science and Technology INTRODUCTION

CT 229. Java Syntax 26/09/2006 CT229

The Arithmetic Operators. Unary Operators. Relational Operators. Examples of use of ++ and

The Arithmetic Operators

Operators & Expressions

Operators and Type Conversion. By Avani M. Sakhapara Assistant Professor, IT Dept, KJSCE

Sir Muhammad Naveed. Arslan Ahmed Shaad ( ) Muhammad Bilal ( )

Fundamentals of Programming

Arithmetic Operators. Portability: Printing Numbers

Prof. Navrati Saxena TA: Rochak Sachan

ME 461 C review Session Fall 2009 S. Keres

Guide for The C Programming Language Chapter 1. Q1. Explain the structure of a C program Answer: Structure of the C program is shown below:

CprE 288 Introduction to Embedded Systems Exam 1 Review. 1

DEPARTMENT OF MATHS, MJ COLLEGE

LECTURE 3 C++ Basics Part 2

Chapter 4. Operations on Data

Fundamental of Programming (C)

Expression and Operator

The Java language has a wide variety of modifiers, including the following:

Expressions. Arithmetic expressions. Logical expressions. Assignment expression. n Variables and constants linked with operators

Infix to Postfix Conversion

Operators and Expressions in C & C++ Mahesh Jangid Assistant Professor Manipal University, Jaipur

Engineering Computing I

CS113: Lecture 3. Topics: Variables. Data types. Arithmetic and Bitwise Operators. Order of Evaluation

Part I Part 1 Expressions

Writing Program in C Expressions and Control Structures (Selection Statements and Loops)

BCA-105 C Language What is C? History of C

Operators. Lecture 3 COP 3014 Spring January 16, 2018

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:

Outline. Performing Computations. Outline (cont) Expressions in C. Some Expression Formats. Types for Operands

Department of Computer Science

Operators and Expressions:

Java enum, casts, and others (Select portions of Chapters 4 & 5)

Chapter 2: Using Data

UNIT 3 OPERATORS. [Marks- 12]

Data Types and Variables in C language

Quick Reference Guide

CSC 1214: Object-Oriented Programming

Computer Programing. for Physicists [SCPY204] Class 02: 25 Jan 2018

CS313D: ADVANCED PROGRAMMING LANGUAGE

Variables and Operators 2/20/01 Lecture #

RUBY OPERATORS. Ruby Arithmetic Operators: Ruby Comparison Operators:

OBJECT ORIENTED PROGRAMMING

CSE 230 Intermediate Programming in C and C++

Programming. Elementary Concepts

Model Viva Questions for Programming in C lab

CHAPTER 3 Expressions, Functions, Output

CHW 469 : Embedded Systems

CHAPTER 3 BASIC INSTRUCTION OF C++

ISA 563 : Fundamentals of Systems Programming

Review of the C Programming Language for Principles of Operating Systems

SOFTWARE DEVELOPMENT 1. Operators 2018W A. Ferscha (Institute of Pervasive Computing, JKU Linz)

Fundamentals of Programming CS-110. Lecture 3

Overview of C. Basic Data Types Constants Variables Identifiers Keywords Basic I/O

Lecture 02 Summary. C/Java Syntax 1/14/2009. Keywords Variable Declarations Data Types Operators Statements. Functions

Chapter 2: Introduction to C++

Fundamental Data Types. CSE 130: Introduction to Programming in C Stony Brook University

Chapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen

C/Java Syntax. January 13, Slides by Mark Hancock (adapted from notes by Craig Schock)

C/Java Syntax. Lecture 02 Summary. Keywords Variable Declarations Data Types Operators Statements. Functions. if, switch, while, do-while, for

Operators and Expressions

Lesson #3. Variables, Operators, and Expressions. 3. Variables, Operators and Expressions - Copyright Denis Hamelin - Ryerson University

Chapter 12 Variables and Operators

Week 2 Introduction to Computer and Algorithm (Part 2)

M4.1-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE

Programming Fundamentals (CS 302 ) Dr. Ihsan Ullah. Lecturer Department of Computer Science & IT University of Balochistan

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program

Computers Programming Course 5. Iulian Năstac

Mechatronics and Microcontrollers. Szilárd Aradi PhD Refresh of C

HISTORY OF C LANGUAGE. Facts about C. Why Use C?

Lecture 02 C FUNDAMENTALS

Transcription:

Q1. Define Algorithm with example? Answer:- A sequential solution of any program that written in human language, called algorithm. Algorithm is first step of the solution process, after the analysis of problem, programmers write the algorithm of that problem. The number of instructions must be finite. To write the algorithm you first must know how to solve the problem! An algorithm produces the same output information given the same input information, and several short algorithms can be combined to perform complex tasks such as writing a computer program. Qualities of a Good Algorithm Inputs and outputs should be defined precisely. Each step in algorithm should be clear and unambiguous. Algorithm should be most effective among many different ways to solve a problem. An algorithm shouldn't have computer code. Instead, the algorithm should be written in such a way that, it can be used in similar programming languages. Example Q2. What is the use of flow chart? Answer: - A flow chart is a graphical or symbolic representation of a process. Each step in the process is represented by a different symbol and contains a short description of the process step. A flowchart is a type of diagram that represents an algorithm, workflow or process, showing the steps as boxes of various kinds, and their order by connecting them with arrows. Flowcharts are important for planning & working of a program. Flowcharts decreases our efforts i.e. they are easy to understand and check logics and algorithms. Flowcharts have become necessity as it is important to do paper work i.e. making logic and algorithm before creating a program on a Machine. It emphasizes individual steps & their interconnections. Once the flowchart is drawn, it becomes easy to write the program in any high level language. Must for the better documentation of a complex program. Symbols & Description Symbol Purpose Description Flow line Used to indicate the flow of logic by connecting symbols. Terminal(Stop/Start) Used to represent start and end of flowchart. Input/output Used for input and output operation. Processing Used for arithmetic operations and data-manipulations.

Decision On-page Connector Used to represent the operation in which there are two alternatives, true and false. Used to join different flow line Off-page Connector Predefined Process/Function Used to connect flowchart portion on different page. Used to represent a group of statements performing one processing task. Advantages of Flowchart:- 1. Communication: - Flowcharts are better way of communicating the logic of a system to all concerned. 2. Effective analysis: - With the help of flowchart, problem can be analyzed in more effective way. 3. Proper documentation: - Program flowcharts serve as a good program documentation, which is needed for various purposes. 4. Efficient Coding: - The flowcharts act as a guide or blueprint during the systems analysis and program development phase. 5. Proper Debugging: - The flowchart helps in debugging process. 6. Efficient Program Maintenance: - The maintenance of operating program becomes easy with the help of flowchart. It helps the programmer to put efforts more efficiently on that part. Q3.What is the different steps followed in the program development? Answer: - A computer is used to solve a problem. Steps are:- 1. Analyze the problem 2. Identify the variables involved 3. Design the solution 4. Write the program 5. Enter it into a computer 6. Compile the program and correct errors 7. Correct the logical errors if any 8. Test the program with data

9. Document the program Q4. Write about space requirements for variables of different data type? Answer:- Whenever we declare variable in Computer s memory, Computer must know the type of the data to be stored inside the memory. A data type specifies the type of data that a variable can store such as integer, floating, character etc. There are 4 types of data types in C language. Types Basic Data Type Derived Data Type Enumeration Data Type Void Data Type Data Types int, char, float, double array, pointer, structure, union Enum Void Basic Data Types The basic data types are integer-based and floating-point based. C language supports both signed and unsigned literals. The memory size of basic data types may change according to 32 or 64 bit operating system. Let's see the basic data types. It size is given according to 32 bit OS. Data Types Memory Size Range Char 1 byte 128 to 127 signed char 1 byte 128 to 127 unsigned char 1 byte 0 to 127 Short 2 byte 32,768 to 32,767 signed short 2 byte 32,768 to 32,767 unsigned short 2 byte 0 to 32,767 Int 2 byte 32,768 to 32,767 signed int 2 byte 32,768 to 32,767 unsigned int 2 byte 0 to 32,767

short int 2 byte 32,768 to 32,767 signed short int 2 byte 32,768 to 32,767 unsigned short int 2 byte 0 to 32,767 long int signed long int unsigned long int Float Double long double 4 byte 4 byte 4 byte 4 byte 8 byte 10 yte Q5. What is an operator? Describe the different types of operator that are included with in the c language with the example for each? Answer: - Operators:- "Operator is a special symbol whose meaning is fixed and used to perform operation on values or operands." Operators are used in programs to manipulate data & variable. Types Of Operators :- 1. Based On Operands 2. Based on Operation Types Of Operators On The Basis Of Operands : 1. Unary Operators 2. Binary Operators 3. Ternary Operators 1. Unary Operators: - This type of operator requires only one operand or variable to perform an operation. This operator is called unary Operator. (++, --,!) 2. Binary Operators: - This type of operator requires or takes only two operands, means at least two operands are compulsory required. (<, >,< =, +)

3. Ternary Operators: - This type of operator requires or takes three operands to perform operation is called Ternary Operator. (? :) Types Of Operators On The Basis Of Operation:- 1. Arithmetic Operators 2. Relational Operators 3. Logical Operators 4. Assignment Operators 5. Increment & Decrement Operators 6. Bitwise Operators 7. Misc Operators 1) Arithmetic Operators: The arithmetic operators are used with numeric values to perform common arithmetical operations, such as addition, subtraction, multiplication etc. There are following arithmetic operators supported by C language: Assume variable A holds 10 and variable B holds 20 then: Operator Description Example + Adds two operands A + B will give 30 - Subtracts second operand from the first A - B will give -10 * Multiply both operands A * B will give 200 / Divide numerator by denumerator B / A will give 2 % Modulus Operator and remainder of after an integer division ++ Increment operator, increases integer value by one -- Decrement operator, decreases integer value by one B % A will give 0 A++ will give 11 A-- will give 9 2) Relational Operator:- These operators are used to compare two operands and Return true if relation is True, Return false if relation is False. These are Binary Operators

Operator Description Example == Checks if the values of two operands are equal or not. If yes, then the condition becomes true. (A == B) is not true.!= Checks if the values of two operands are equal or not. If the values are not equal, then the condition becomes true. (A!= B) is true. > Checks if the value of left operand is greater than the value of right operand. If yes, then the condition becomes true. (A > B) is not true. < Checks if the value of left operand is less than the value of right operand. If yes, then the condition becomes true. (A < B) is true. >= Checks if the value of left operand is greater than or equal to the value of right operand. If yes, then the condition becomes true. (A >= B) is not true. <= Checks if the value of left operand is less than or equal to the value of right operand. If yes, then the condition becomes true. (A <= B) is true. 3) Logical Operator:- These are Binary Operators. These operators are used within if when there is more than one condition. There are three operators: 1) Logical And && 2) Logical OR 3) Logical Not! Operator Description Example

&& Called Logical AND operator. If both the operands are non-zero, then the condition becomes true. (A && B) is false. Called Logical OR Operator. If any of the two operands is non-zero, then the condition becomes true. (A B) is true.! Called Logical NOT Operator. It is used to reverse the logical state of its operand. If a condition is true, then Logical NOT operator will make it false.!(a && B) is true. 4) Assignment Operators:- There are following assignment operators supported by C language: Operator Description Example = Simple assignment operator, Assigns values from right side operands to left side operand += Add AND assignment operator, It adds right operand to the left operand and assign the result to left operand -= Subtract AND assignment operator, It subtracts right operand from the left operand and assign the result to left operand *= Multiply AND assignment operator, It multiplies right operand with the left operand and assign the result to left operand /= Divide AND assignment operator, It divides left operand with the right operand and assign the result to left operand %= Modulus AND assignment operator, It takes modulus using two operands and assign the result to left operand C = A + B will assign value of A + B into C C += A is equivalent to C = C + A C -= A is equivalent to C = C A C *= A is equivalent to C = C * A C /= A is equivalent to C = C / A C %= A is equivalent to C = C % A <<= Left shift AND assignment operator C <<= 2 is same as C = C << 2 >>= Right shift AND assignment operator C >>= 2 is same as C = C >> 2 &= Bitwise AND assignment operator C &= 2 is same as C = C & 2

^= bitwise exclusive OR and assignment operator = bitwise inclusive OR and assignment operator C ^= 2 is same as C = C ^ 2 C = 2 is same as C = C 2 5) Bitwise Operators:- C language has a special facility that allows direct manipulation of individual bits of a data. This facility is provided by bitwise operator. Bitwise operators allow us to provide the facility to manipulate individual bits of a data where general operators directly manipulate the data. Operator Description Example & Binary AND Operator copies a bit to the result if it exists in both operands. (A & B) = 12, i.e., 0000 1100 Binary OR Operator copies a bit if it exists in either operand. (A B) = 61, i.e., 0011 1101 ^ Binary XOR Operator copies the bit if it is set in one operand but not both. (A ^ B) = 49, i.e., 0011 0001 ~ Binary Ones Complement Operator is unary and has the effect of 'flipping' bits. (~A ) = -61, i.e. 1100 0011 in 2's complement form. << Binary Left Shift Operator. The left operands value is moved left by the number of bits specified by the right operand. A << 2 = 240 i.e., 1111 0000 >> Binary Right Shift Operator. The left operands value is moved right by the number of bits specified by the right operand. A >> 2 = 15 i.e., 0000 1111

6) Misc Operators sizeof & ternary Besides the operators discussed above, there are a few other important operators including sizeof and? : Supported by the C Language. Operator Description Example sizeof() Returns the size of a variable. sizeof(a), where a is integer, will return 4. & Returns the address of a variable. &a; returns the actual address of the variable. * Pointer to a variable. *a;? : Conditional Expression. If Condition is true? then value X : otherwise value Y 7) Increment & Decrement Operator:- These are Unary operators. These are one of the powerful operators. Their symbol is: ++, -- Increment Operator (++):- This operator is used to increase value of a variable by one and always one. Decrement Operator (--):- This operator is used to decrease or reduce the value of a variable by one. For example int i = 10; i ++; then i--; then There are two forms for these two operators. 1. Prefix form 2.Postfix form i = 11 i = 9

1.Prefix form:- In this form the operator is fix before the operand. Example:- ++j --j => int t1, i = 10; t1 = ++i; evalution steps i=i+1-> 11 t1=i->11 Now t1=11 i=11 2. Postfix form:- In this form the operator will fix after the operand. Just like this i++, j++ In postfix form, the value of a variable use in an expression and after it will manipulate. int t1, i = 10; t1 = i ++; Evaluation steps t1 = i 10 i = i +111 Now t1 = 10 i =11 And int t1, i = 10; t1 = i--; t1 = i

i = i -1; Now t1 =10 i = 9