Ch 1 introduction to Embedded Systems (AY:2018-2019--> First Semester)Moe Moe Myint
This document provides an introduction to embedded systems for a course at Mandalay Technological University. It includes chapters on what embedded systems are, their typical applications and domains, characteristics, designing systems with microcontrollers, hardware and software co-design, real-time operating systems, and product development processes. The document outlines learning objectives for understanding fundamentals of embedded systems and being able to recognize, comprehend, implement, practice, develop familiarity with tools, and perform lab work related to embedded systems. It also provides an overview of key topics in each chapter and keywords to note related to embedded systems.
This document discusses the process of compiling programs from source code to executable code. It covers lexical analysis, parsing, semantic analysis, code optimization, and code generation. The overall compilation process involves breaking the source code into tokens, generating an abstract syntax tree, performing semantic checks, translating to intermediate representations, optimizing the code, and finally generating target machine code.
Modem is a network device that enables a computer to transfer data from telephone lines to computers and computers to telephone lines.
The word modem is derived from modulator and demodulator.
Modem performs modulation and demodulation.
This document discusses semaphores and their use in solving critical section problems. It defines semaphores, describes their wait and signal methods, and types including counting and binary semaphores. It then explains how semaphores can be used to solve classical synchronization problems like the bounded buffer, readers-writers, and dining philosophers problems. Examples of semaphore implementations are provided for each problem.
Operators in Java provide symbols that operate on arguments to produce results. The document discusses the different types of operators in Java including assignment, arithmetic, relational, logical, bitwise, and ternary operators. Examples are provided to demonstrate the usage of various operators like increment/decrement, arithmetic, relational, logical, bitwise, ternary, and instanceof operators in Java code.
Elements and Principles of Design (Updated)Ravi Bhadauria
Here's a complete presentation on elements and principles of design that every designer must know. So, have a look at this presentation till the end. To learn more go for our official website - https://www.admecindia.com.
The document provides an overview of the C programming language. It discusses that C was developed at Bell Labs in the 1970s and is a general purpose language closely associated with UNIX. It then covers C's character set, keywords, basic program structure including header files and library functions, data types, variables, constants, and provides a simple "Hello World" example program.
Operator overloading allows operators like + and - to have different implementations depending on the types of their operands. It allows user-defined types to be manipulated using the same syntax as built-in types. The document discusses various aspects of operator overloading like overloading unary, binary, and stream insertion/extraction operators. It also covers type conversions between basic and user-defined types using constructors and conversion functions. Restrictions on which operators can be overloaded and how different conversion scenarios are handled are explained.
The aim of this list of programming languages is to include all notable programming languages in existence, both those in current use and ... Note: This page does not list esoteric programming languages. .... Computer programming portal ...
View study notes of Function overloading .you can also visit Tutorialfocus.net to get complete description step wise of the concerned topic.Other topics and notes of C++ are also explained.
A function is a block of code that performs a specific task. Functions allow for modularity and code reuse in a program. There are several key aspects of functions:
1. Functions are defined with a return type, name, and parameters. The general format is return_type function_name(parameter list).
2. Parameters allow functions to accept input from the caller. There are two ways parameters can be passed: call by value or call by reference.
3. Variables declared inside a function are local, while those declared outside are global and visible to all code. Local variables exist only during the function's execution.
4. Functions can call themselves recursively to repeat a task, with a base
C Recursion, Pointers, Dynamic memory managementSreedhar Chowdam
The document summarizes key topics related to recursion, pointers, and dynamic memory management in C programming:
Recursion is introduced as a process where a function calls itself repeatedly to solve a problem. Examples of recursive functions like factorial, Fibonacci series, and Towers of Hanoi are provided.
Pointers are defined as variables that store the memory addresses of other variables. Pointer operations like incrementing, decrementing, and arithmetic are described. The use of pointers to pass arguments to functions and access array elements is also demonstrated.
Dynamic memory allocation functions malloc(), calloc(), and realloc() are explained along with examples. These functions allocate and manage memory during run-time in C programs.
The document discusses arrays in C programming. It defines an array as a collection of similar data elements stored in adjacent memory locations that share a single name. Arrays allow storing multiple values of the same type using this single name. The document covers array declaration syntax, initialization, passing arrays to functions, and multidimensional arrays. It provides examples of one-dimensional and two-dimensional arrays as well as operations like matrix addition and transpose.
This document provides an introduction to Python data structures including lists, tuples, sets, and dictionaries. It describes how to define, access, and modify each type of data structure. It also covers file handling, string functions, exceptions, and other Python concepts. The key points are:
- Lists are the most versatile data type and can contain elements of different types. They can be accessed by index, sliced, modified via assignments to slices.
- Tuples are immutable sequences that are useful for grouping related data. They allow packing and unpacking of elements.
- Sets store unique elements and support mathematical operations like union and intersection.
- Dictionaries store mappings of unique keys to values. They allow
Presentation on C++ Programming Languagesatvirsandhu9
This document provides an overview of the C++ programming language. It discusses why C++ is used, how it compares to Fortran, and the basic structure and components of a C++ program. The key topics covered include data types, variables, operators, selection statements, iteration statements, functions, arrays, pointers, input/output, preprocessor instructions, and comments. The document is intended to teach the basics of C++ programming in a structured way over multiple sections.
The document discusses call by value and call by reference in functions. Call by value passes the actual value of an argument to the formal parameter, so any changes made to the formal parameter do not affect the actual argument. Call by reference passes the address of the actual argument, so changes to the formal parameter do directly modify the actual argument. An example program demonstrates call by value, where changing the formal parameter does not change the original variable.
This document discusses parameters in C++. There are two types of parameters: formal parameters defined in a function and actual parameters passed during a function call. C++ supports two ways of passing parameters: call by value where the formal parameter is a copy of the actual value, and call by reference where the formal parameter is an alias to the actual parameter. Call by reference allows a function to modify the original value. While it is more efficient for large data types, it can be ambiguous whether a parameter is intended for input or output.
- An array is a collection of consecutive memory locations that all have the same name and type. An array allows storing multiple values of the same type using a single name.
- Arrays in C++ must be declared before use, specifying the type, name, and number of elements. Elements are accessed using an index.
- The main advantages of arrays are that they allow storing and processing large numbers of values efficiently using a single name. Arrays also make sorting and searching values easier.
Stream is a sequence of bytes that serves as an input or output source. The input stream provides data to a program while the output stream receives output. The get() and put() functions handle single character I/O. The >> operator is overloaded in istream while << is overloaded in ostream. The ios class contains functions like width(), precision(), and fill() for formatting output. Iomanip provides manipulators to format output in a chained manner.
This document discusses different uses of the "this" pointer in C++ classes. This pointer points to the object whose member function is being called. It can be used to return the object from a member function, access the memory address of the object, and access data members within member functions. Sample programs are provided to demonstrate returning an object using this, displaying the memory address of an object using this, and accessing a data member within a member function using this->.
The document discusses strings in C programming. It defines strings as sequences of characters stored as character arrays that are terminated with a null character. It covers string literals, declaring and initializing string variables, reading and writing strings, and common string manipulation functions like strlen(), strcpy(), strcmp(), and strcat(). These functions allow operations on strings like getting the length, copying strings, comparing strings, and concatenating strings.
The document discusses classes and objects in object-oriented programming. It defines a class as a blueprint for objects that bind data and functions together. A class defines data members and member functions. Objects are instances of a class that can access class data and functions. The document provides examples of defining a class called "test" with private and public members, and creating objects of the class to demonstrate accessing members.
The document discusses call by value vs call by reference in functions, and different storage classes in C including auto, extern, register, and static. It provides examples of each storage class and how they determine the scope and lifetime of variables. It also discusses recursion and provides examples of recursive functions to calculate factorial, sum of natural numbers, Fibonacci series, and solve the Towers of Hanoi problem.
This document provides an overview of key concepts in C programming including variables, arrays, pointers, and arrays using pointers. It defines variables as names that refer to memory locations holding values. Arrays are collections of homogeneous elements that can be one-dimensional or multi-dimensional. Pointers are variables that store the address of another variable and allow indirect access to values. The document also discusses pointer types, arrays using pointers, and differences between arrays and pointers.
Functions allow programmers to structure C++ programs into modular segments of code to perform individual tasks. There are two types of functions: library functions and user-defined functions. User-defined functions are defined using a return type, function name, and parameters. Functions can be called by value or by reference and can also be inline, recursive, or friend functions.
The document provides an overview of the C programming language, including its history, basic structure, data types, operators, input/output, decision making, looping, functions, arrays, pointers, strings, structures, file handling, and linked data structures. Some key topics covered include the C compilation process, basic C program structure, common data types like int and char, arithmetic, relational, and logical operators, if/else and switch statements, while, do-while and for loops, defining functions, and passing arguments to functions.
Operator overloading allows operators like + and - to have different implementations depending on the types of their operands. It allows user-defined types to be manipulated using the same syntax as built-in types. The document discusses various aspects of operator overloading like overloading unary, binary, and stream insertion/extraction operators. It also covers type conversions between basic and user-defined types using constructors and conversion functions. Restrictions on which operators can be overloaded and how different conversion scenarios are handled are explained.
The aim of this list of programming languages is to include all notable programming languages in existence, both those in current use and ... Note: This page does not list esoteric programming languages. .... Computer programming portal ...
View study notes of Function overloading .you can also visit Tutorialfocus.net to get complete description step wise of the concerned topic.Other topics and notes of C++ are also explained.
A function is a block of code that performs a specific task. Functions allow for modularity and code reuse in a program. There are several key aspects of functions:
1. Functions are defined with a return type, name, and parameters. The general format is return_type function_name(parameter list).
2. Parameters allow functions to accept input from the caller. There are two ways parameters can be passed: call by value or call by reference.
3. Variables declared inside a function are local, while those declared outside are global and visible to all code. Local variables exist only during the function's execution.
4. Functions can call themselves recursively to repeat a task, with a base
C Recursion, Pointers, Dynamic memory managementSreedhar Chowdam
The document summarizes key topics related to recursion, pointers, and dynamic memory management in C programming:
Recursion is introduced as a process where a function calls itself repeatedly to solve a problem. Examples of recursive functions like factorial, Fibonacci series, and Towers of Hanoi are provided.
Pointers are defined as variables that store the memory addresses of other variables. Pointer operations like incrementing, decrementing, and arithmetic are described. The use of pointers to pass arguments to functions and access array elements is also demonstrated.
Dynamic memory allocation functions malloc(), calloc(), and realloc() are explained along with examples. These functions allocate and manage memory during run-time in C programs.
The document discusses arrays in C programming. It defines an array as a collection of similar data elements stored in adjacent memory locations that share a single name. Arrays allow storing multiple values of the same type using this single name. The document covers array declaration syntax, initialization, passing arrays to functions, and multidimensional arrays. It provides examples of one-dimensional and two-dimensional arrays as well as operations like matrix addition and transpose.
This document provides an introduction to Python data structures including lists, tuples, sets, and dictionaries. It describes how to define, access, and modify each type of data structure. It also covers file handling, string functions, exceptions, and other Python concepts. The key points are:
- Lists are the most versatile data type and can contain elements of different types. They can be accessed by index, sliced, modified via assignments to slices.
- Tuples are immutable sequences that are useful for grouping related data. They allow packing and unpacking of elements.
- Sets store unique elements and support mathematical operations like union and intersection.
- Dictionaries store mappings of unique keys to values. They allow
Presentation on C++ Programming Languagesatvirsandhu9
This document provides an overview of the C++ programming language. It discusses why C++ is used, how it compares to Fortran, and the basic structure and components of a C++ program. The key topics covered include data types, variables, operators, selection statements, iteration statements, functions, arrays, pointers, input/output, preprocessor instructions, and comments. The document is intended to teach the basics of C++ programming in a structured way over multiple sections.
The document discusses call by value and call by reference in functions. Call by value passes the actual value of an argument to the formal parameter, so any changes made to the formal parameter do not affect the actual argument. Call by reference passes the address of the actual argument, so changes to the formal parameter do directly modify the actual argument. An example program demonstrates call by value, where changing the formal parameter does not change the original variable.
This document discusses parameters in C++. There are two types of parameters: formal parameters defined in a function and actual parameters passed during a function call. C++ supports two ways of passing parameters: call by value where the formal parameter is a copy of the actual value, and call by reference where the formal parameter is an alias to the actual parameter. Call by reference allows a function to modify the original value. While it is more efficient for large data types, it can be ambiguous whether a parameter is intended for input or output.
- An array is a collection of consecutive memory locations that all have the same name and type. An array allows storing multiple values of the same type using a single name.
- Arrays in C++ must be declared before use, specifying the type, name, and number of elements. Elements are accessed using an index.
- The main advantages of arrays are that they allow storing and processing large numbers of values efficiently using a single name. Arrays also make sorting and searching values easier.
Stream is a sequence of bytes that serves as an input or output source. The input stream provides data to a program while the output stream receives output. The get() and put() functions handle single character I/O. The >> operator is overloaded in istream while << is overloaded in ostream. The ios class contains functions like width(), precision(), and fill() for formatting output. Iomanip provides manipulators to format output in a chained manner.
This document discusses different uses of the "this" pointer in C++ classes. This pointer points to the object whose member function is being called. It can be used to return the object from a member function, access the memory address of the object, and access data members within member functions. Sample programs are provided to demonstrate returning an object using this, displaying the memory address of an object using this, and accessing a data member within a member function using this->.
The document discusses strings in C programming. It defines strings as sequences of characters stored as character arrays that are terminated with a null character. It covers string literals, declaring and initializing string variables, reading and writing strings, and common string manipulation functions like strlen(), strcpy(), strcmp(), and strcat(). These functions allow operations on strings like getting the length, copying strings, comparing strings, and concatenating strings.
The document discusses classes and objects in object-oriented programming. It defines a class as a blueprint for objects that bind data and functions together. A class defines data members and member functions. Objects are instances of a class that can access class data and functions. The document provides examples of defining a class called "test" with private and public members, and creating objects of the class to demonstrate accessing members.
The document discusses call by value vs call by reference in functions, and different storage classes in C including auto, extern, register, and static. It provides examples of each storage class and how they determine the scope and lifetime of variables. It also discusses recursion and provides examples of recursive functions to calculate factorial, sum of natural numbers, Fibonacci series, and solve the Towers of Hanoi problem.
This document provides an overview of key concepts in C programming including variables, arrays, pointers, and arrays using pointers. It defines variables as names that refer to memory locations holding values. Arrays are collections of homogeneous elements that can be one-dimensional or multi-dimensional. Pointers are variables that store the address of another variable and allow indirect access to values. The document also discusses pointer types, arrays using pointers, and differences between arrays and pointers.
Functions allow programmers to structure C++ programs into modular segments of code to perform individual tasks. There are two types of functions: library functions and user-defined functions. User-defined functions are defined using a return type, function name, and parameters. Functions can be called by value or by reference and can also be inline, recursive, or friend functions.
The document provides an overview of the C programming language, including its history, basic structure, data types, operators, input/output, decision making, looping, functions, arrays, pointers, strings, structures, file handling, and linked data structures. Some key topics covered include the C compilation process, basic C program structure, common data types like int and char, arithmetic, relational, and logical operators, if/else and switch statements, while, do-while and for loops, defining functions, and passing arguments to functions.
The document outlines the objectives and contents of the course GE3151 Problem Solving and Python Programming. The objectives include understanding algorithmic problem solving, solving problems using Python conditionals and loops, defining functions, and using data structures like lists, tuples and dictionaries. The course is divided into 5 units which cover topics like computational thinking, Python data types and expressions, control flow and functions, lists and tuples, files and modules. Some illustrative problems mentioned are finding the minimum in a list, solving towers of Hanoi problem, calculating distance between two points, checking voter eligibility, and preparing a retail bill.
The document discusses editing, compiling, and executing a simple C++ program. It begins with an overview of basic C++ programming elements and concepts like tokens, data types, arithmetic operators, and precedence. It then provides examples of simple C++ programs that perform arithmetic calculations and output results. The document emphasizes that understanding programming fundamentals like variables, data types, expressions, and control flow is necessary before writing even basic C++ programs.
The document provides an overview of the C programming language, including its history, characteristics, environment, structure, data types, variables, decision making, looping, libraries, and uses. It describes how C was developed at Bell Labs in the early 1970s and later standardized. The summary highlights C's small fixed set of keywords, static typing, use of headers and functions, and popularity for systems programming and performance-critical applications due to its efficiency and ability to access hardware.
The document discusses algorithms and flowcharts. It defines an algorithm as a finite set of steps to solve a problem and notes that algorithms can be expressed in various ways, including pseudocode and flowcharts. Pseudocode uses a language similar to programming but without specific syntax, making it readable by programmers familiar with different languages. A flowchart provides a graphical representation of an algorithm's logical flow. The document provides examples of algorithms expressed in pseudocode and represented through flowcharts, such as finding the average of two numbers and calculating the largest of several inputs. It also discusses common flowchart structures like sequence, selection, and iteration.
This document provides an introduction to the C programming language. It discusses fundamental C elements like data types, variables, constants, operators, and input/output functions. It explains how a basic C program is structured and compiled. Examples are provided to demonstrate simple C statements, arithmetic expressions, and how to write and run a first program that prints text. The key topics covered include basic syntax, program structure, data types, identifiers, operators, and input/output functions like printf() and scanf().
This document outlines a course on programming in C and data structures. The objectives are to teach students basic problem solving principles through C programming and design programming skills. The course covers various C programming concepts like variables, operators, branching, looping, functions, arrays, strings, structures, pointers, file management and preprocessors. It also introduces fundamental data structures like stacks, queues, linked lists and trees. The assessment includes a question paper with 10 questions, 2 from each module, and students must answer 5 questions total, selecting 1 from each module.
C is an imperative, procedural language in the ALGOL tradition. It has a static type system. In C, all executable code is contained within subroutines (also called "functions", though not in the sense of functional programming). Function parameters are passed by value, although arrays are passed as pointers, i.e. the address of the first item in the array. Pass-by-reference is simulated in C by explicitly passing pointers to the thing being referenced.
C program source text is free-format, using the semicolon as a statement separator and curly braces for grouping blocks of statements.
The C language also exhibits the following characteristics:
The language has a small, fixed number of keywords, including a full set of control flow primitives: if/else, for, do/while, while, and switch. User-defined names are not distinguished from keywords by any kind of sigil.
It has a large number of arithmetic, bitwise, and logic operators: +,+=,++,&,||, etc.
More than one assignment may be performed in a single statement.
This document outlines the syllabus for the course GE3151 Problem Solving and Python Programming. It includes 5 units that cover topics like computational thinking, Python data types, control flow, functions, lists, tuples, dictionaries, files and modules. The objectives of the course are to understand algorithmic problem solving, learn to solve problems using Python conditionals and loops, define functions and use data structures like lists and tuples. It also aims to teach input/output with files in Python. The document provides the number of periods (45) and textbooks recommended for the course.
The chapter introduces the basic components of a C++ program, including functions, data types, operators, and statements. It discusses simple data types like integers, characters, and floating-point numbers. The chapter also covers arithmetic operators, expressions, and the order of precedence. It explains variable declaration, assignment statements, and how to input and output data. The goal is for readers to understand the basic structure and syntax of a C++ program.
Introduction
The term problem solving is used in many disciplines, sometimes with different perspectives and
often with different terminologies. The problem-solving process starts with the problem
specification and end with a correct program.
The steps to follow in the problem-solving process are:
Problem definition
Problem Analysis
Algorithm development
Coding
Testing & Debugging
Documentation & Maintenance
The stages of analysis, design, programming, implementation and maintenance form the life cycle
of the system.
Programming languages are designed to communicate with machines like computers. Programs are sets of instructions written in a programming language following its syntax to serve some purpose. C++ was developed in the 1980s as an object-oriented programming language. OOP views a problem in terms of objects rather than procedures. A programming language's character set includes letters, digits, symbols, and whitespace that it can recognize as valid characters. The smallest units of a program are tokens like keywords, identifiers, literals, operators, and punctuators.
This document provides sample code and exercises for learning C++. It covers writing "Hello World" programs, calculating basic statistics, finding prime numbers, working with loops, and debugging a factorial program. The exercises are divided into sections like writing different "Hello World" programs, understanding scope, using conditionals and loops, and fixing errors in a factorial function. Students are instructed to complete the exercises by writing code in separate files and submitting their work.
The document discusses Unit 4 of the Programming for Problem Solving course. It covers functions and pointers in C programming. Specifically, it discusses function declaration, definition, user-defined functions, storage classes, function prototypes, parameter passing methods (call by value and call by reference), recursion, pointers, pointer arithmetic, and dynamic memory allocation using pointers.
This slide notes are more than 10 years old of my teacher Mr Karim Zebari. He uses a brilliant simple language to explain programming principles step by step.
This document discusses algorithms and their analysis. It begins by defining an algorithm and its key characteristics like being finite, definite, and terminating after a finite number of steps. It then discusses designing algorithms to minimize cost and analyzing algorithms to predict their performance. Various algorithm design techniques are covered like divide and conquer, binary search, and its recursive implementation. Asymptotic notations like Big-O, Omega, and Theta are introduced to analyze time and space complexity. Specific algorithms like merge sort, quicksort, and their recursive implementations are explained in detail.
Design and Analysis of Algorithms (Knapsack Problem)Sreedhar Chowdam
This document describes the greedy knapsack problem where the goal is to maximize the value of items placed in a knapsack of limited capacity. It provides the values (p) and weights (w) of 6 items, as well as the knapsack capacity (M=13). The value to weight ratios (Pi/Wi) are also listed to help determine the optimal solution of maximizing value within the weight limit.
The document discusses several topics related to computer networks including:
1. The network layer, including design issues like store-and-forward and connection-oriented services. Routing algorithms like shortest path routing and flooding are also discussed.
2. Congestion control principles and policies for preventing congestion in virtual circuits and datagram subnets.
3. Transport layer protocols like TCP and UDP, and how they provide services and manage connections and transmissions.
4. Application layer protocols like DNS for managing domain names and resource records.
The document discusses topics related to data communication and computer networks including digital signals, transmission media, transmission impairments, and the data link layer.
Specifically, it covers:
- Digital signals can represent information using positive and negative voltages. More bits per level allow more information to be sent.
- Transmission impairments like attenuation, distortion, and noise can corrupt signals. Attenuation is addressed using amplifiers and repeaters.
- The data link layer provides error detection using techniques like block coding, error correction codes, CRC codes, and checksums to reliably transmit data despite errors.
This document provides an overview of data communication and computer networks. It discusses key topics such as data representation, data flow, network topologies, categories of networks, protocols and standards. The document specifically describes data communication components, protocols and elements, network criteria and types of topologies including mesh, star, bus and ring. It also defines local, metropolitan and wide area networks and compares their characteristics. Finally, it introduces the OSI reference model and layers.
This document provides an overview of a course on data communication and computer networks. It includes 5 units that cover topics such as introduction to data communication components, network models, physical layer, data link layer, network layer, congestion control, and the transport layer. It also lists 10 experiments related to the course content, such as implementing network commands, cyclic redundancy code, routing algorithms, and domain name servers. The instructor's name and some content that is copied from internet sources is acknowledged.
The document discusses various topics related to structures and unions, files, and error handling in C programming. It includes:
1) Defining structures and unions, passing structures to functions, self-referential structures.
2) Opening, reading, writing, and closing files. Functions for file input/output like fopen, fprintf, fscanf, getc, putc.
3) Error handling functions like feof() and ferror() to check for end of file or errors during file operations.
The document discusses two dimensional arrays in C programming. It explains how to declare, initialize and access 2D arrays. It provides examples of accepting 2D array elements as input and displaying them. It also discusses various matrix operations like addition, multiplication using 2D arrays. Functions to input, multiply and display matrices are demonstrated. Other topics covered include passing 2D arrays to functions, matrix transpose, finding sum of diagonal elements and multi-dimensional arrays. Finally, it briefly explains command line arguments in C.
The document summarizes topics covered in a programming for problem solving (PPS) class, including control structures like if/else statements, loops, and switch cases. Example programs are provided to find the largest of three numbers, determine if a character is a vowel or consonant, and identify the type of triangle based on angle or side lengths. The last example uses nested if/else and switch statements to classify triangles as equilateral, isosceles, right-angled, or scalene depending on the problem constraints.
This document provides an overview of Apache Hive, including its architecture and features. It states that Hive is an open source data warehouse system built on Hadoop that allows users to query large datasets using SQL-like queries. It is used for analyzing structured data and is best suited for batch jobs. The document then discusses Hive's architecture, including its drivers, metastore, and Thrift interface. It also provides examples of built-in functions in Hive for mathematical operations, string manipulation, and more. Finally, it covers Hive commands for DDL, DML, and querying data.
The document discusses various topics related to lists in Python including:
- Lists can store multiple items of similar or different types in a single variable.
- List items can be accessed and modified using indexes.
- List slicing allows accessing elements within a specified index range.
- Built-in functions like len(), max(), min() etc. can be used to perform operations on lists.
- List methods allow adding, removing, and modifying elements in lists.
- Lists can be passed as arguments to functions and returned from functions.
The document provides an overview of a Python programming course taught by Dr. C. Sreedhar. The course covers topics like the history of Python, installing Python, data types, operators, expressions, functions, and more. It includes code examples for basic programs to calculate area and perimeter, check if a number is even or odd, and determine if a number is divisible by 4 and 9. The document contains lecture slides with explanations and syntax for various Python concepts.
This document contains a summary of a class on string methods in Python. It discusses the str class and how to create strings, various string methods like find(), upper(), lower(), split(), indexing strings, formatting strings, comparing strings, and checking string properties. Traversing strings using for and while loops and that strings are immutable in Python are also mentioned.
The document summarizes key concepts in Python programming including decision statements, loops, and functions. It discusses boolean expressions and relational operators used in conditional statements. It also covers different loop constructs like while, for, and nested loops. Finally, it provides examples of defining and using functions, and concepts like local and global scope, default arguments, recursion, and returning values.
The document provides an overview of Unit 1 of a Python programming course taught by Dr. C. Sreedhar. Unit 1 covers introduction to Python including its history, installation, execution, commenting, data types, operators, and writing simple programs. It discusses Python's character set, tokens, core data types, I/O functions, assigning values to variables, and multiple assignments. Operators and expressions such as arithmetic, comparison, logical, and bitwise operators are also covered. Examples of simple Python programs are provided.
How to use nRF24L01 module with ArduinoCircuitDigest
Learn how to wirelessly transmit sensor data using nRF24L01 and Arduino Uno. A simple project demonstrating real-time communication with DHT11 and OLED display.
Data Structures_Linear data structures Linked Lists.pptxRushaliDeshmukh2
Concept of Linear Data Structures, Array as an ADT, Merging of two arrays, Storage
Representation, Linear list – singly linked list implementation, insertion, deletion and searching operations on linear list, circularly linked lists- Operations for Circularly linked lists, doubly linked
list implementation, insertion, deletion and searching operations, applications of linked lists.
The Fluke 925 is a vane anemometer, a handheld device designed to measure wind speed, air flow (volume), and temperature. It features a separate sensor and display unit, allowing greater flexibility and ease of use in tight or hard-to-reach spaces. The Fluke 925 is particularly suitable for HVAC (heating, ventilation, and air conditioning) maintenance in both residential and commercial buildings, offering a durable and cost-effective solution for routine airflow diagnostics.
its all about Artificial Intelligence(Ai) and Machine Learning and not on advanced level you can study before the exam or can check for some information on Ai for project
Raish Khanji GTU 8th sem Internship Report.pdfRaishKhanji
This report details the practical experiences gained during an internship at Indo German Tool
Room, Ahmedabad. The internship provided hands-on training in various manufacturing technologies, encompassing both conventional and advanced techniques. Significant emphasis was placed on machining processes, including operation and fundamental
understanding of lathe and milling machines. Furthermore, the internship incorporated
modern welding technology, notably through the application of an Augmented Reality (AR)
simulator, offering a safe and effective environment for skill development. Exposure to
industrial automation was achieved through practical exercises in Programmable Logic Controllers (PLCs) using Siemens TIA software and direct operation of industrial robots
utilizing teach pendants. The principles and practical aspects of Computer Numerical Control
(CNC) technology were also explored. Complementing these manufacturing processes, the
internship included extensive application of SolidWorks software for design and modeling tasks. This comprehensive practical training has provided a foundational understanding of
key aspects of modern manufacturing and design, enhancing the technical proficiency and readiness for future engineering endeavors.
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...Infopitaara
A feed water heater is a device used in power plants to preheat water before it enters the boiler. It plays a critical role in improving the overall efficiency of the power generation process, especially in thermal power plants.
🔧 Function of a Feed Water Heater:
It uses steam extracted from the turbine to preheat the feed water.
This reduces the fuel required to convert water into steam in the boiler.
It supports Regenerative Rankine Cycle, increasing plant efficiency.
🔍 Types of Feed Water Heaters:
Open Feed Water Heater (Direct Contact)
Steam and water come into direct contact.
Mixing occurs, and heat is transferred directly.
Common in low-pressure stages.
Closed Feed Water Heater (Surface Type)
Steam and water are separated by tubes.
Heat is transferred through tube walls.
Common in high-pressure systems.
⚙️ Advantages:
Improves thermal efficiency.
Reduces fuel consumption.
Lowers thermal stress on boiler components.
Minimizes corrosion by removing dissolved gases.
Value Stream Mapping Worskshops for Intelligent Continuous SecurityMarc Hornbeek
This presentation provides detailed guidance and tools for conducting Current State and Future State Value Stream Mapping workshops for Intelligent Continuous Security.
Analysis of reinforced concrete deep beam is based on simplified approximate method due to the complexity of the exact analysis. The complexity is due to a number of parameters affecting its response. To evaluate some of this parameters, finite element study of the structural behavior of the reinforced self-compacting concrete deep beam was carried out using Abaqus finite element modeling tool. The model was validated against experimental data from the literature. The parametric effects of varied concrete compressive strength, vertical web reinforcement ratio and horizontal web reinforcement ratio on the beam were tested on eight (8) different specimens under four points loads. The results of the validation work showed good agreement with the experimental studies. The parametric study revealed that the concrete compressive strength most significantly influenced the specimens’ response with the average of 41.1% and 49 % increment in the diagonal cracking and ultimate load respectively due to doubling of concrete compressive strength. Although the increase in horizontal web reinforcement ratio from 0.31 % to 0.63 % lead to average of 6.24 % increment on the diagonal cracking load, it does not influence the ultimate strength and the load-deflection response of the beams. Similar variation in vertical web reinforcement ratio leads to an average of 2.4 % and 15 % increment in cracking and ultimate load respectively with no appreciable effect on the load-deflection response.
Passenger car unit (PCU) of a vehicle type depends on vehicular characteristics, stream characteristics, roadway characteristics, environmental factors, climate conditions and control conditions. Keeping in view various factors affecting PCU, a model was developed taking a volume to capacity ratio and percentage share of particular vehicle type as independent parameters. A microscopic traffic simulation model VISSIM has been used in present study for generating traffic flow data which some time very difficult to obtain from field survey. A comparison study was carried out with the purpose of verifying when the adaptive neuro-fuzzy inference system (ANFIS), artificial neural network (ANN) and multiple linear regression (MLR) models are appropriate for prediction of PCUs of different vehicle types. From the results observed that ANFIS model estimates were closer to the corresponding simulated PCU values compared to MLR and ANN models. It is concluded that the ANFIS model showed greater potential in predicting PCUs from v/c ratio and proportional share for all type of vehicles whereas MLR and ANN models did not perform well.
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...Infopitaara
A Boiler Feed Pump (BFP) is a critical component in thermal power plants. It supplies high-pressure water (feedwater) to the boiler, ensuring continuous steam generation.
⚙️ How a Boiler Feed Pump Works
Water Collection:
Feedwater is collected from the deaerator or feedwater tank.
Pressurization:
The pump increases water pressure using multiple impellers/stages in centrifugal types.
Discharge to Boiler:
Pressurized water is then supplied to the boiler drum or economizer section, depending on design.
🌀 Types of Boiler Feed Pumps
Centrifugal Pumps (most common):
Multistage for higher pressure.
Used in large thermal power stations.
Positive Displacement Pumps (less common):
For smaller or specific applications.
Precise flow control but less efficient for large volumes.
🛠️ Key Operations and Controls
Recirculation Line: Protects the pump from overheating at low flow.
Throttle Valve: Regulates flow based on boiler demand.
Control System: Often automated via DCS/PLC for variable load conditions.
Sealing & Cooling Systems: Prevent leakage and maintain pump health.
⚠️ Common BFP Issues
Cavitation due to low NPSH (Net Positive Suction Head).
Seal or bearing failure.
Overheating from improper flow or recirculation.
2. Course Outcomes
CO1: Understand fundamentals of problem solving concepts with
various data types and operators
CO2: Apply conditional and iterative statements for solving a
given problem
CO3: Illustrate the applications of functions and storage classes.
CO4: Apply the concepts of pointers and dynamic memory
management in problem solving.
CO5: Understand the purpose of structures, unions and files.
3. Unit 1
General Problem Solving Concepts
Algorithm, Flowchart for problem solving with Sequential Logic Structure,
Decisions and Loops.
Imperative Languages
Introduction ; syntax and constructs of a specific language (ANSI C)–
Types Operator and Expressions with discussion of variable naming and
Hungarian Notation: Variable Names, Data Type and Sizes (Little
Endian Big Endian), Constants, Declarations, Arithmetic Operators,
Relational Operators, Logical Operators, Type Conversion, Increment
Decrement Operators, Bitwise Operators, Assignment Operators and
Expressions, Precedence and Order of Evaluation, Formatted input/output
4. Unit 2
Control Flow with discussion on structured and
unstructured programming
Statements and Blocks, If-Else-If, Switch,
Loops–while, do, for, break and continue, goto labels,
structured and un-structured programming
5. Unit 3
Functions and Program Structure with discussion on
standard library
Basics of functions, parameter passing and returning
type, C main return as integer,
External, Auto, Local, Static, Register Variables,
Scope Rules, Block structure, Initialization,
Recursion, Pre-processor, Standard Library Functions and
return types.
6. Unit 4
Pointers and Arrays:
Pointers and address, dynamic memory management,
Pointers and Function Arguments, Pointers and Arrays,
Address Arithmetic, character Pointers and Functions,
Pointer Arrays,
Pointer to Pointer, Multi-dimensional array and Row/column
major formats, Initialization of Pointer Arrays, Command
line arguments, Pointer to functions, complicated declarations
and how they are evaluated
7. Unit 5
Structures and Unions:
Basic Structure, Structures and Functions,
Array of structures, Pointer of structures, Self-referral
structures, Table look up, typedef, Unions, Bit-fields.
Files:
Introduction to Files, Opening and Closing files, Reading
and Writing files, File I/O functions, Error Handling in files
8. Textbooks & References
1.The C Programming Language, B. W. Kernighan
and D. M. Ritchie, Second Edition, PHI.
2.Programming in C, B. Gottfried, Second Edition,
Schaum Outline Series.
1. C: The Complete Reference, Herbert Schildt,
Fourth Edition, McGraw Hill.
2. Let Us C, Yashavant Kanetkar, BPB Publications
9. PROGRAMING FOR PROBLEM
SOLVING LAB [PPS(P)]
CO1:Implementprograms using conditional and loop statements in C.
CO2:Develop programs using 1-Dimensional and 2-Dimensional arrays.
CO3:Perform Call by value, Call by reference and Recursion through
functions.
CO4:Implement programs using pointers.
CO5:Develop programs using structures and file concepts
10. List of Experiments
1. Conditional Statements:
Quadratic equations, usage of switch statement.
2. Loop Statements :
Adam Number, Cosine series
3. Arrays:
Max Min problem, standard deviation and variance.
4. Character Arrays:
Palindrome, implementation of string handling functions.
11. List of Experiments
5. Functions and Recursion :
Matrix operations, Towers of Hanoi, GCD
6. Pointers:
Interchanging problem,
implementation of dynamic memory allocation.
7. Structures:
Usage of structures in various applications.
8. Files:
Reading contents from files and writing contents to files
12. C is a programming
language developed
at Bell Laboratories of
USA in 1972 by Dennis
Ritchie
13. C is a programming language developed at Bell
Laboratories of USA in 1972 by Dennis Ritchie
25. Unit 1
General Problem Solving Concepts
Algorithm, Flowchart for problem solving with Sequential Logic Structure, Decisions
and Loops.
Imperative Languages
Introduction ; syntax and constructs of a specific language (ANSI C)–Types
Operator and Expressions with discussion of variable naming and Hungarian
Notation: Variable Names, Data Type and Sizes (Little Endian Big Endian),
Constants, Declarations, Arithmetic Operators, Relational Operators, Logical
Operators, Type Conversion, Increment Decrement Operators, Bitwise Operators,
Assignment Operators and Expressions, Precedence and Order of Evaluation,
Formatted input/output
26. Algorithm
Algorithm is a finite set of instructions that if followed
accomplishes a particular task.
Algorithm
Input Output
Problem
Computer
32. Characteristics of Algorithm
Input
Output
Definiteness
Effectiveness
Finiteness
Input − An algorithm should have 0 or
more well-defined inputs.
Output − An algorithm should have 1 or
more well-defined outputs, and should
match the desired output.
Definiteness −Should be clear and
unambiguous. Each of its steps and their
inputs/outputs should be clear and must
lead to only one meaning.
Effectiveness − An algorithm should have
step-by-step directions, which should be
independent of any programming code
Finiteness − An algorithm must terminate
after a finite number of steps.
33. Characteristics of Algorithm
Input − Should have 0 or more well-defined inputs.
Output Should have 1 or more well-defined outputs, and
should match the desired output.
Definiteness −Should be clear and unambiguous.
Effectiveness − Should have step-by-step directions, which
should be independent of any programming code.
Finiteness − Must terminate after a finite number of steps.
34. Program to display “Welcome to C”
#include<stdio.h>
int main()
{
printf(“Welcome to C”);
return 0;
}
35. Problem 1: Addition of two numbers
Input :
two numbers (num1 = 4,
num2 = 6)
Output:
Sum = 10
Algorithm
Step 1: Start
Step 2: Read the first number(num1)
Step 3: Read second number(num2)
Step 4: Sum num1+num2
Step 5: Print Sum
Step 6: Stop
Sum = num1 + num2
36. Program to accept two numbers from the user and display the
sum using C language
/*
Program to accept two numbers and display the sum
Programmer : --Your name--
Roll no: --your roll number--
Date of compilation: 27Jan2021
Class : B.Tech I Sem „CST'
*/
37. #include<stdio.h>
// Main function begins
int main()
{
int num1,num2,sum;
printf("Enter first value:");
scanf("%d",&num1);
printf("Enter Second value:");
scanf("%d",&num2);
sum=num1+num2;
printf(“Addition of %d and %d is: %d",num1,num2,sum);
return 0;
}
38. Problem 2: Algorithm to find the area of rectangle
Input :
two numbers. (length = 8
breadth = 4)
Output:
Area of rect = 32
Algorithm
Step 1: Start
Step 2: Read first number(length)
Step 3: Read second number (breadth)
Step 4: Area length * breadth
Step 5: Print “Area of rect”, Area
Step 6: Stop
Area = length * breadth
39. Ex3: Problem: Find greater of two no‟s
Algorithm:
Step 1: Start
Step 2: Declare variables A, B
Step 3: Accept two values from user and store in A and B
respectively.
Step 4: Check whether A > B; True: 4.1; False: 4.2
4.1 Yes Print A is greater
4.2 No Print B is greater
Step5: Stop
40. Ex4: Find Largest of three numbers
Step 1: Start
Step 2: Declare variables a,b and c.
Step 3: Read variables a,b and c.
Step 4: If a>b ; True: 4.1; False: 4.2
4.1 If a>c True: 4.1.1; False: 4.1.2
4.1.1 Display a is the largest number.
else
4.1.2 Display c is the largest number.
4.2 Else
If b>c True: 4.2.1; False: 4.2.2
4.2.1 Display b is the largest number.
else
4.2.2 Display c is the greatest number.
Step 5: Stop
41. Ex5: Calculate Gross, Net Salary
Problem:
Accept the employee details such as empid and
basic salary. Consider DA with 120% of basic, HRA
with 10% of basic. Calculate the gross salary and
net salary considering tax deduction of Rs. 2% of
gross.
42. Example: Gross, Net
Empid: 1001
Basic: 10000
DA: 120% of Basic=1.20*10000= 12000
HRA: 10% of Basic=0.1*10000 = 1000
Gross=Basic+DA+HRA = 10000+12000+1000=23000
Tax: 2% of Gross = 0.02*23000=460
Net = Gross-Tax = 23000-460 = 22540
46. Flowchart
A Flowchart is a type of diagram (graphical or symbolic) that
represents an algorithm or process.
Each step in the process is represented by a different symbol
and contains a short description of the process step.
The flow chart symbols are linked together with arrows showing
the process flow direction. A flowchart typically shows the flow
of data in a process, detailing the operations/steps in a
pictorial format which is easier to understand than reading it in
a textual format.
48. 49
Identify
What do each of the following symbols represent?
Terminal
Input/Output
Operation
Process
Decision
Connector
Module
49. Example 1: Algorithm & Flowchart
Problem: Display the Sum, Average, Product of
three given numbers
Algorithm
Step1: Start
Step 2: Read X, Y, Z
Step 3: Compute Sum (S) X + Y + Z
Step 4: Compute Average (A) S / 3
Step 5: Compute Product (P) as X x Y x Z
Step 6: Print S, A, P
Step 7: Stop
50. Example 2: Algorithm & Flowchart
Problem: Display the largest of two given numbers
Algorithm
Step1: Start
Step 2: Read A, B
Step 3: If A is less than B
True: Assign A to BIG and B to SMALL
False: Assign B to BIG and A to SMALL
Step 6: Print S, A, P
Step 7: Stop
51. Control Structures
Sequence: A series of steps or statements that are executed in
the order they are written in an algorithm.
Selection: Defines two courses of action depending on the
outcome of a condition. A condition is an expression that is,
when computed, evaluated to either true or false. (ex: if, if
else, nested if)
Repetition/Loop: Specifies a block of one or more statements
that are repeatedly executed until a condition is satisfied. (Ex:
for, while, do while)
52. Ex: Sequence Control Structure
A series of steps or statements that are executed in the
order they are written in an algorithm.
The beginning and end of a block of statements can be
optionally marked with the keywords begin and end.
begin
statement 1
statement 2
statement n
.....
end
54. Sequence Example
int main()
{
int first, second, temp;
printf("Enter first number: ");
scanf("%d", &first);
printf("Enter second number: ");
scanf("%d", &second);
temp = first;
first = second;
second = temp;
printf("After swapping, firstno. = %dn", first);
printf("After swapping, secondno. = %d", second);
}
Swap two
numbers
using temp
var
55. Sequence Example
int main()
{
int a, b;
printf("Enter a and b: ");
scanf("%d %d", &a, &b);
a = a - b;
b = a + b;
a = b - a;
printf("After swapping, a = %dn", a);
printf("After swapping, b = %d", b);
return 0;
}
Swap two
numbers
without
using temp
var
58. Selection Ex: Program to print the given
number is negative or positive using if else
int main()
{
int num;
printf("Enter a number to check.n");
scanf("%d",&num);
if (num<0)
printf(“Given Number = %d is negativen",num);
else
printf(“Given Number = %d is positiven",num);
return 0;
}
59. Selection Ex:
Problem: Write an algorithm to determine a student‟s final grade
and display pass or fail. The final grade is calculated as the
average of four subject marks.
Algorithm
Step1: Start
Step 2: Input M1,M2,M3,M4
Step 3: GRADE (M1+M2+M3+M4)/4
Step 4: if (GRADE > 60) then Print “Pass” else “Fail”
Step 5: Stop
61. Selection Ex:
Program to check for odd or even
int main()
{
int num;
printf("Enter an integer: ");
scanf("%d", &num);
if (num % 2 == 0)
printf("%d is even.", num);
else
printf("%d is odd.", num);
return 0;
}
62. Selection Ex: Program to check odd or
even using ternary operator ? :
int main()
{
int num;
printf("Enter an integer: ");
scanf("%d", &num);
(num % 2 == 0) ? printf("%d is even.", num) : printf("%d is odd.", num);
return 0;
}
63. Selection Ex: Problem: Find greater of two no‟s
Algorithm:
Step 1: Start
Step 2: Declare variables A, B
Step 3: Accept two values from user and store in A and B
respectively.
Step 4: Check whether A > B; True: 4.1; False: 4.2
4.1 Yes Print A is greater
4.2 No Print B is greater
Step5: Stop
65. Selection Ex: Find Largest of three numbers
Step 1: Start
Step 2: Declare variables a,b and c.
Step 3: Read variables a,b and c.
Step 4: If a>b ; True: 4.1; False: 4.2
4.1 If a>c True: 4.1.1; False: 4.1.2
4.1.1 Display a is the largest number.
else
4.1.2 Display c is the largest number.
4.2 Else
If b>c True: 4.2.1; False: 4.2.2
4.2.1 Display b is the largest number.
else
4.2.2 Display c is the greatest number.
Step 5: Stop
66. int main()
{
double n1, n2, n3;
printf("Enter three different numbers: ");
scanf("%lf %lf %lf", &n1, &n2, &n3);
if (n1 >= n2 && n1 >= n3)
printf("%.2f is the largest number.", n1);
if (n2 >= n1 && n2 >= n3)
printf("%.2f is the largest number.", n2);
if (n3 >= n1 && n3 >= n2)
printf("%.2f is the largest number.", n3);
return 0;
}
Selection: if
67. int main()
{
double n1, n2, n3;
printf("Enter three numbers: ");
scanf("%lf %lf %lf", &n1, &n2, &n3);
if (n1 >= n2 && n1 >= n3)
printf("%.2lf is the largest number.", n1);
else if (n2 >= n1 && n2 >= n3)
printf("%.2lf is the largest number.", n2);
else
printf("%.2lf is the largest number.", n3);
return 0;
}
Selection: if else if
68. int main()
{
double n1, n2, n3;
printf("Enter three numbers: ");
scanf("%lf %lf %lf", &n1, &n2, &n3);
if (n1 >= n2)
{
if (n1 >= n3) printf("%.2lf is the largest number.", n1);
else printf("%.2lf is the largest number.", n3);
}
else
{
if (n2 >= n3) printf("%.2lf is the largest number.", n2);
else printf("%.2lf is the largest number.", n3);
}
return 0;
}
Selection: nested if
74. Practice Programs in Lab
1. Program to swap two numbers.
2. Program to accept student id (integer), marks of four subjects
and calculate the sum and average. If the average is greater than
60 Print “Pass” else “Fail”.
3. Program to display whether the given integer is odd or even.
4. Program to find simple interest.
5. Program to find the largest of three given numbers.
6. Program to accept two numbers and check whether both are
same.
76. C basic elements
Valid character set
Identifiers
Keywords
Basic data types
Constants
Variables
77. C Valid character set
uppercase English alphabets A to Z,
lowercase letters a to z,
digits 0 to 9,
certain special characters as building blocks to form
basic program elements viz. constants, variables,
operators, expressions and statements.
78. C Identifiers
Identifiers are names given to various items in the program, such as
variables, functions and arrays.
An identifier consists of letters and digits, in any order, except that the
first character must be a letter.
Both upper and lowercase letters are permitted.
C is a case sensitive, the upper case and lower case considered
different, for example code, Code, CODE etc. are different
identifiers.
The underscore character _ can also be included.
Keywords like if, else, int, float, etc., have special meaning and they
cannot be used as identifier names.
79. Valid and invalid C identifiers
ANSI standard recognizes 31 characters
valid identifiers: A, ab123, velocity, stud_name,
circumference, Average, TOTAL.
Invalid identifiers:
1st
"Jamshedpur"
stud-name
stud name
81. C Data types and sizes
Data type Description Size Range
char single character 1 byte 0 - 255
int integer number 4 bytes
-2147483648 to
2147483647
float
single precision floating point
number (number containing
fraction & or an exponent)
4 bytes 3.4E-38 to 3.4E+38
double
double precision floating point
number
8 bytes 1.7E-308 to 1.7E+308
82. C Data types and sizes
Data type Size Range
short int 2 bytes -32768 to 32767
long int 4 bytes
-2147483648 to
2147483647
unsigned short int 2 bytes 0 to 65535
unsigned int 4 bytes 0 to 4294967295
unsigned long int 4 bytes 0 to 4294967295
long double (extended precision) 8 bytes 1.7E-308 to1.7E+308
83. C Constants
C can be classified into four categories namely integer
constants, floating point constants, character constants
and string constants.
A character constant is written as for example - 'A'
A normal integer constant is written as 1234.
A long int uses L (uppercase or lowercase) at the end of
the constant, e.g. 2748723L
C also supports octal and hexadecimal data. Ex: 0xC
84. Escape sequence characters
Character Escape Sequence ASCII Value
Bell a 007
Backspace b 008
Null 0 000
Newline n 010
Carriage return r 013
Vertical tab v 011
Horizontal tab t 009
Form feed f 012
86. Accept name from the user
Method 1
char name[20];
printf("Enter your name:");
scanf("%s",name);
printf("Your name is: %s",name);
Method 2
char name[20]
printf(“Enter your name:”)
gets(name);
printf(“Your name is:”);
puts(name);
87. Accept name from the user
Method 3
#define MAX_LIMIT 20
int main()
{
char name[MAX_LIMIT];
printf("Enter your name:");
fgets(name,MAX_LIMIT,stdin);
printf("Your name is: %s",name);
Method 4
char name[20];
printf("Enter your name:");
scanf("%[^n]%*c",name);
printf("Your name is: %s",name);
90. int a = 10, b = 20, c = 25, d = 25;
printf(“ %d" (a + b) );
printf(“ %d" (a - b) );
printf(“%d “ (a * b) );
printf(“ %d” (b / a) );
printf(“ %d” (b % a) );
printf(“ %d” (c % a) );
printf (“%d“ (a++) );
printf(“%d “ (a--) );
printf(“%d “ (d++) );
printf(“%d “ (++d) );
OUTPUT
30
-10
200
2
0
5
10
11
25
27
95. Example: Bitwise Operators
int a = 60;
int b = 13;
int c = 0;
c = a & b; printf(“%d" + c );
c = a | b; printf(“%d" + c );
c = a ^ b; printf(“%d" + c );
c = ~a; printf(“%d" + c );
c = a << 2; printf(“%d" + c );
c = a >> 2; printf(“%d" + c );
OUTPUT
a= 60 = 0011 1100
b= 13 = 0000 1101
c = a & b; 0000 1100
= 12
c = a | b; 0011 1101
= 61
c = a ^ b; 0011 0001
= 49
c = ~a; 1100 0011
= -61
97. Misc Operators
sizeof() : Returns the size of the variable
& : Returns the address of a variable
* : Pointer variable
?: : Conditional / Ternary operator
98. Operator Precedence
e = (a + b) * c / d;
// Print value of e
e = ((a + b) * c) / d;
// Print value of e
e = (a + b) * (c / d);
// Print value of e
e = a + (b * c) / d;
// Print value of e
int a = 20, b = 10, c = 15, d = 5;
int e;
Value of (a + b) * c / d is : 90
Value of ((a + b) * c) / d is : 90
Value of (a + b) * (c / d) is : 90
Value of a + (b * c) / d is : 50
( 30 * 15 ) / 5
(30 * 15 ) / 5
(30) * (15/5)
20 + (150/5)
associativity of operators determines the direction in which an
expression is evaluated. Example, b = a;
associativity of the = operator is from right to left (RL).
100. Arithmetic Operators
Multiplication operator, Divide
by, Modulus
*, /, % LR
Add, Subtract +, – LR
Relational Operators
Less Than <
LR
Greater than >
Less than equal to <=
Greater than equal to >=
Equal to ==
Not equal !=
Logical Operators
AND && LR
OR || LR
NOT ! RL
1 == 2 != 3
operators == and
!= have the same
precedence, LR
Hence, 1 == 2 is
executed first
101. Hungarian Notation
Hungarian is a naming convention for identifiers. Each identifier
would have two parts to it, a type and a qualifier.
Each address stores one element of the memory array. Each
element is typically one byte.
For example, suppose you have a 32-bit quantity written as
12345678, which is hexadecimal.
Since each hex digit is four bits, eight hex digits are needed to
represent the 32-bit value. The four bytes are: 12, 34, 56, and 78.
There are two ways to store in memory: Bigendian and little endian
102. Endianness
The endianness of a particular computer system is
generally described by whatever convention or set of
conventions is followed by a particular processor or
combination of processor/architecture and possibly
operating system or transmission medium for the
addressing of constants and the representations of
memory addresses.
Often referred to as byte order
103. Big Endian storage
Big-endian: Stores most significant byte in smallest address.
The following shows how 12345678 is stored in big endian
Big Endian Storage
Address Value
1000 12
1001 34
1002 56
1003 78
104. Little Endian storage
Little-endian: Stores least significant byte in smallest
address.
The following shows how 12345678 is stored in big
endian Little Endian Storage
Address Value
1000 78
1001 56
1002 34
1003 12
105. For example 4A3B2C1D at address 100, they store
the bytes within the address range 100 through 103
in the following order:m
106. Type Casting
Type casting is a way to convert a variable from
one data type to another data type.
Implicit Conversions
Explicit Conversions
108. Explicit Conversions
General format / Syntax:
(type_name) expression
Example:
main()
{
int sum = 17, count = 5;
double mean;
mean = (double) sum / count;
printf("Value of mean : %lfn", mean );
}
109. Examples: Type Conversions
float a = 5.25;
int b = (int)a;
char c = ‟A‟;
int x = (int)c;
int x=7, y=5 ;
float z;
z=x/y;
int x=7, y=5;
float z;
z = (float)x/(float)y;
110. Loop Example: Multiplication table
int main()
{
int n, i;
printf("Enter no. to print multiplication table: ");
scanf("%d",&n);
for(i=1;i<=10;++i)
{
printf("%d * %d = %dn", n, i, n*i);
}
}
111. break Statement
The break statement in C programming language has the
following two usages:
When the break statement is encountered inside a loop, the loop
is immediately terminated and program control resumes at the
next statement following the loop.
It can be used to terminate a case in the switch statement
If you are using nested loops, the break statement will stop the
execution of the innermost loop and start executing the next line
of code after the block.
Syntax:
break;
112. int a = 10;
while( a < 20 )
{
printf("value of a: %dn", a);
a++;
if( a > 15)
{
break;
}
}
OUTPUT
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 15
113. int num =0;
while(num<=100)
{
printf("value of variable num is: %dn", num);
if (num==2)
{
break;
}
num++;
}
printf("Out of while-loop");
Output:
value of variable num is: 0
value of variable num is: 1
value of variable num is: 2
Out of while-loop
114. int var;
for (var =100; var>=10; var --)
{
printf("var: %dn", var);
if (var==99)
{
break;
}
}
printf("Out of for-loop");
Output:
var: 100
var: 99
Out of for-loop
115. int a = 4;
while( a < 10 )
{
printf("value of a: %dn", a);
++a;
if( a > 8)
{
break;
printf("Breakn");
}
printf("Hellon");
}
printf("Out of While loopn");
}
116. continue
The continue statement in C programming
language works somewhat like the break
statement.
Instead of forcing termination, continue
statement forces the next iteration of the loop
to take place, skipping any code in between.
117. int a = 10;
do {
if( a == 15)
{
a = a + 1;
continue;
}
printf("value of a: %dn", a);
a++;
} while( a < 20 );
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 16
value of a: 17
value of a: 18
value of a: 19
119. int counter=10;
while (counter >=0)
{
if (counter==7)
{
counter--;
continue;
}
printf("%d ", counter);
counter--;
}
Output:
10 9 8 6 5 4 3 2 1 0
120. int a = 10;
do
{
if( a == 15)
{
a = a + 1;
continue;
}
printf("value of a: %dn", a);
a++;
} while( a < 20 );
121. goto statement
The goto statement is used to alter the normal sequence of
program execution by transferring control to some other part of
the program unconditionally.
Syntax: goto label;
Control may be transferred to anywhere within the current
function.
The target statement must be labeled, and a colon must follow
the label.
label : statement;
122. int w;
printf("Enter the input 1 or 0:n");
scanf("%d", &w);
if (w == 1)
goto CST;
if (w == 0) printf("Value entered is 0n");
return 0;
CST : printf("You belong to CST Sectionn");
goto end;
end : printf("Have a nice Dayn");
return 0;
}
123. Example: Nested Loop
int i, j;
for(i=2; i<10; i++)
{
for(j=2; j <= (i/j); j++)
if(!(i%j)) break;
if(j > (i/j)) printf("%d is primen", i);
}
124. Program to check alphabet, digit or special character
if((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
printf("'%c' is alphabet.", ch);
else if(ch >= '0' && ch <= '9')
printf("'%c' is digit.", ch);
else
printf("'%c' is special character.", ch);
Alphabet: a to z (or) A to Z
Digit : 0 to 9
else it is special character
125. Program to check vowel of consonant
if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u' ||
ch=='A' || ch=='E' || ch=='I' || ch=='O' || ch=='U')
{
printf("'%c' is Vowel.", ch);
}
else if((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
printf("'%c' is Consonant.", ch);
else printf("'%c' is not an alphabet.", ch);
Vowel : a (or) e (or) i (or) o (or) u
Consonant : a to z or A to Z
else: not an alphabet
126. Sum of digits of given number using while
sum = 0;
// Accept number and store in n
num = n;
while( n > 0 )
{
rem = n % 10;
sum += rem;
n /= 10;
}
printf("Sum of digits of %d is %d", num, sum);
OUTPUT
Enter a number: 456
Sum of digits of 456 is 15
127. Sum of digits of given number using while
sum = 0;
// Accept number and store in n
num = n;
while( n > 0 )
{
rem = n % 10;
sum += rem;
n /= 10;
}
printf("Sum of digits of %d is %d", num, sum);
OUTPUT
Enter a number: 456
Sum of digits of 456 is 15
128. Print all ODD numbers from 1 to N using while loop.
number=1;
while(number<=n)
{
if(number%2 != 0)
printf("%d ",number);
number++;
}
130. count total digits in a given integer using loop
do
{
count++;
num /= 10;
} while(num != 0);
printf("Total digits: %d", count);
131. Program to print numbers between 1 and 100 which
are multiple of 3 using the do while loop
int i = 1;
do
{
if(i % 3 == 0)
{
printf("%d ", i);
}
i++;
}while(i < 100);
132. find sum of odd numbers from 1 to n
for(i=1; i<=n; i+=2)
{
sum += i;
}
printf("Sum of odd numbers = %d", sum);
133. Exponential series
int i, n;
float x, sum=1, t=1;
// Accept x
// Accept n
for(i=1;i<=n;i++)
{
t=t*x/i;
sum=sum+t;
}
printf(“Exponential Value of %f = %.4f", x, sum);
134. Program to print its multiplication table
i=1;
while(i<=10)
{
printf("%dn",(num*i));
i++;
}
i=1;
do
{
printf("%dn",(num*i));
i++;
}while(i<=10);
for(i=1;i<=10;i++)
{
printf("%dn",(num*i));
}
135. k = 1;
for(i=1; i<=rows; i++)
{
for( j=1; j<=cols; j++, k++)
{
printf("%-3d", k);
}
printf("n");
}
Print number pattern as shown
143. Structured vs Unstructured Programming
Structured Programming is a
programming paradigm which divides
the code into modules or function.
Unstructured Programming is the
paradigm in which the code is
considered as one single block.
Readability
Structured Programming based
programs are easy to read.
Unstructured Programming based
programs are hard to read.
Purpose
Structured Programming is to make the
code more efficient and easier to
understand.
Unstructured programming is just to
program to solve the problem. It does
not create a logical structure.
Complexity
Structured Programming is easier
because of modules.
Unstructured programming is harder
when comparing with the structured
programming
144. Application
Structured programming can be used for
small and medium scale projects.
Unstructured programming is not applicable
for medium and complex projects.
Modification
It is easy to do changes in Structured
Programming.
It is hard to do modifications in Unstructured
Programming.
Data Types
Structured programming uses many data
types.
Unstructured programming has a limited
number of data types.
Code Duplication
Structured programming avoids code
duplication.
Unstructured programming can have code
duplication.
Testing and Debug
It is easy to do testing and debugging in
Structured Programming.
It is hard to do testing and debugging in
Unstructured programming.
146. Palindrome number
rev=0
origin=n;
while (n != 0)
{
rem = n % 10;
rev = rev * 10 + rem;
n /= 10;
}
if (orig == rev) printf("%d is a palindrome.“,orig);
else printf("%d is not a palindrome.", orig);
147. int i, j;
for(i = 2; i<100; i++)
{
for(j = 2; j <= (i/j); j++)
if(!(i%j)) break; // if factor found, not prime
if(j > (i/j)) printf("%d is primen", i);
}
Print Prime numbers upto 100
149. Palindrome number
rev=0
origin=n;
while (n != 0)
{
rem = n % 10;
rev = rev * 10 + rem;
n /= 10;
}
if (origin == rev) printf("%d is a palindrome.“,orig);
else printf("%d is not a palindrome.", orig);
150. goto statement: Unstructured programming
The goto statement is used to alter the normal sequence
of program execution by transferring control to some
other part of the program unconditionally.
Syntax: goto label;
Control may be transferred to anywhere within the
current function.
The target statement must be labeled, and a colon must
follow the label.
label : statement;