The document discusses data structures and algorithms. It defines a data structure as a particular way of organizing data in a computer so that it can be used efficiently. Common data structures include arrays, stacks, queues, linked lists, trees, heaps, and hash tables. An algorithm is defined as a finite set of instructions to accomplish a particular task. Analyzing algorithms involves determining how resources like time and storage change with input size. Key considerations in algorithm design include requirements, analysis, data objects, operations, refinement, coding, verification, and testing.
The document discusses modular programming in C. Modular programming involves breaking a large program into smaller sub-programs or modules. This makes the program easier to use, maintain and reuse code. Functions are a key part of modular programming in C. Functions allow breaking a program into reusable modules that perform specific tasks. Functions can be called anywhere in a program to perform tasks without rewriting code. Modular programming improves readability, reduces errors and makes programs easier to maintain and modify.
Slides introduce hardware and software components of Computer System and it also discusses generations of Programming language and Programming language translators. It will be Useful for 1st Engineering students of all disciplines.
C Programming Language is the most popular computer language and most used programming language till now. It is very simple and elegant language. This lecture series will give you basic concepts of structured programming language with C.
This document discusses procedural programming. It defines procedural programming as specifying a sequence of steps to implement an algorithm, with code kept concise and focused on a specific result. Procedural programming breaks problems down into hierarchical sub-problems and sub-procedures. It focuses on processes, storing data and functions separately. Programs are made up of independently coded and tested modules. Procedural languages define procedures as imperative statements organized into functions. The document discusses advantages like reusability and modularity, and disadvantages like lack of data encapsulation and security. It provides an example Fibonacci series program in C using recursion.
This document discusses different programming paradigms and languages. It describes batch programs which run without user interaction and event-driven programs which respond to user events. It lists many popular programming languages from Machine Language to Java and C#, and describes low-level languages that are close to machine code and high-level languages that are more human-readable. It also discusses the different types of language translators like compilers, interpreters, and assemblers and how they convert code between languages. Finally, it covers testing, debugging, and different types of errors in programming.
The document discusses the scope of variables in C programming. It defines variables as storage locations that hold temporary data. Variables can be declared locally within a function or globally outside of all functions. Local variables are only accessible within their declaration block, while global variables can be accessed from any function. The document provides examples of local and global variable declarations and discusses best practices around their use.
A pointer is a variable that stores the memory address of another variable. Pointers allow functions to modify variables in the caller and are useful for handling arrays and dynamic memory allocation. Pointers contain the address of the memory location they point to. Pointer variables can be declared to hold these memory addresses and can then be used to indirectly access the value at the addressed location.
What are variables and keywords in c++Abdul Hafeez
Hi I am Abdul Hafeez ,I made this videos for Beginner and intermediate students, they can easily understand basic structure of c++ programming.
In this lecture students can understand easily:
* what is variables in c++ Programming?
* variables and data types in c++ Programming
* how to declare variables in c++ Programming
* how to initialize variables in c++ Programming
* keywords in c programming
* keywords in c++ programming
* variables and data types in c++ Programming
* size of data types in c++ Programming
* range of data types in c++ programming
* how are variables stored in memory?
C++ tutorials in URDU - HINDI
Basic concepts and advance concepts
This PPT is for First year engineering student,It covered all about C Programming according to Rajastha Technical University Kota.
flowchart, pseudo code, Programming Languages and Language Translators, Identifiers, Constants, Variables, Basic Data Types, Operators, Expressions, type casting, Input / Output Statement, Scope Rules and Storage classes, Preprocessor and Macro Substitution.
Algorithms Lecture 1: Introduction to AlgorithmsMohamed Loey
We will discuss the following: Algorithms, Time Complexity & Space Complexity, Algorithm vs Pseudo code, Some Algorithm Types, Programming Languages, Python, Anaconda.
Data types, Variables, Expressions & Arithmetic Operators in javaJaved Rashid
This document covers fundamentals of programming in Java, including data types, variables, expressions, and arithmetic operators. It discusses the 8 primitive data types in Java (byte, short, int, long, float, double, char, boolean), rules for naming variables, how to declare and assign values to variables, and how expressions are evaluated using arithmetic operators. It provides examples of declaring variables of different data types and using variables in expressions and print statements.
Macros allow programmers to define abbreviations for sequences of instructions. A macro definition specifies the macro name and the sequence of instructions to be abbreviated. When a macro is called, it is expanded by replacing the macro name with the defined sequence of instructions. Macros can call other macros, requiring macro processors to handle nested macro expansion. Macro processors implement macros using a single or double pass approach to first save macro definitions and then expand macro calls by substituting argument values.
C++ provides built-in and user-defined data types. Built-in data types are pre-defined in C++ and include character, integer, floating point, double, void, and boolean. User-defined data types are composed of built-in types and include arrays, structures, unions, classes, and pointers. Data types determine the type of data that can be stored and the operations that can be performed on that data.
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 ...
Algorithms Lecture 2: Analysis of Algorithms IMohamed Loey
This document discusses analysis of algorithms and time complexity. It explains that analysis of algorithms determines the resources needed to execute algorithms. The time complexity of an algorithm quantifies how long it takes. There are three cases to analyze - worst case, average case, and best case. Common notations for time complexity include O(1), O(n), O(n^2), O(log n), and O(n!). The document provides examples of algorithms and determines their time complexity in different cases. It also discusses how to combine complexities of nested loops and loops in algorithms.
The document discusses functions in C programming. It defines functions as blocks of code that perform a specific task and can be called by other parts of the code. It covers the different components of functions like declarations, definitions, calls, passing arguments, and recursive functions. Recursive functions are functions that call themselves to break down a problem into smaller sub-problems until a base case is reached.
The document discusses the central processing unit (CPU) and its components like registers, arithmetic logic unit (ALU), control unit, and bus. It explains the general register organization of CPU with multiple registers like R1-R7 connected to the ALU, control unit, and bus. The control unit directs information flow and selects components in the CPU to perform operations like addition and shifting. The document also covers addressing modes, instruction formats, data transfer and manipulation instructions, and stack organization in a CPU.
The document provides an introduction to Python programming. It discusses key concepts like variables, data types, operators, and sequential data types. Python is presented as an interpreted programming language that uses indentation to indicate blocks of code. Comments and documentation are included to explain the code. Various data types are covered, including numbers, strings, booleans, and lists. Operators for arithmetic, comparison, assignment and more are also summarized.
A small journey in programming using C Language. In This Presentation i provide a small introduction about C Language.
Our Company APSMIND TECHNLOGY PVT LTD actually provide Application/software development training using various language like C, C++, java, .Net, PHP etc.
We also ,develop application and website for various client as for their requirement.
Getters and setters are used to effectively protect data in classes. Getters return the value of a variable while setters set the value. They follow a standard naming convention starting with get/set followed by the variable name capitalized. Constructors initialize objects and can provide initial values. They have the same name as the class and no return type. Value types like int store values directly while reference types store references to objects. The Math class provides predefined math methods that can be accessed without creating an object.
The document discusses multi-dimensional arrays, specifically two-dimensional arrays. It defines two-dimensional arrays as rows and columns that can represent tables, vectors, or matrices. It provides examples of declaring, initializing, inputting, outputting, and storing two-dimensional arrays in C code. It includes code examples for adding, transposing, and multiplying matrices using two-dimensional arrays.
General register organization (computer organization)rishi ram khanal
This document discusses the organization of a CPU and its registers. It includes tables that encode the register selection fields and ALU operations. It also provides examples of micro-operations for the CPU, showing the register selections, ALU operations, and control words. Key registers discussed include the accumulator, instruction register, address register, and program counter.
The document discusses algorithms and their building blocks. It defines an algorithm as a collection of well-defined, unambiguous and effectively computable instructions that return a proper output. The three building blocks of algorithms are identified as sequence, selection, and iteration. Sequence refers to a series of actions performed in order. Selection allows a program to choose between different actions or conditions. Iteration allows a block of code to be repeated while a condition is true. Pseudocode and flowcharts are introduced as common ways to express algorithms and illustrate the control flow and logic of a program.
A pointer is a variable that stores the memory address of another variable. Pointers allow functions to modify variables in the caller and are useful for handling arrays and dynamic memory allocation. Pointers contain the address of the memory location they point to. Pointer variables can be declared to hold these memory addresses and can then be used to indirectly access the value at the addressed location.
What are variables and keywords in c++Abdul Hafeez
Hi I am Abdul Hafeez ,I made this videos for Beginner and intermediate students, they can easily understand basic structure of c++ programming.
In this lecture students can understand easily:
* what is variables in c++ Programming?
* variables and data types in c++ Programming
* how to declare variables in c++ Programming
* how to initialize variables in c++ Programming
* keywords in c programming
* keywords in c++ programming
* variables and data types in c++ Programming
* size of data types in c++ Programming
* range of data types in c++ programming
* how are variables stored in memory?
C++ tutorials in URDU - HINDI
Basic concepts and advance concepts
This PPT is for First year engineering student,It covered all about C Programming according to Rajastha Technical University Kota.
flowchart, pseudo code, Programming Languages and Language Translators, Identifiers, Constants, Variables, Basic Data Types, Operators, Expressions, type casting, Input / Output Statement, Scope Rules and Storage classes, Preprocessor and Macro Substitution.
Algorithms Lecture 1: Introduction to AlgorithmsMohamed Loey
We will discuss the following: Algorithms, Time Complexity & Space Complexity, Algorithm vs Pseudo code, Some Algorithm Types, Programming Languages, Python, Anaconda.
Data types, Variables, Expressions & Arithmetic Operators in javaJaved Rashid
This document covers fundamentals of programming in Java, including data types, variables, expressions, and arithmetic operators. It discusses the 8 primitive data types in Java (byte, short, int, long, float, double, char, boolean), rules for naming variables, how to declare and assign values to variables, and how expressions are evaluated using arithmetic operators. It provides examples of declaring variables of different data types and using variables in expressions and print statements.
Macros allow programmers to define abbreviations for sequences of instructions. A macro definition specifies the macro name and the sequence of instructions to be abbreviated. When a macro is called, it is expanded by replacing the macro name with the defined sequence of instructions. Macros can call other macros, requiring macro processors to handle nested macro expansion. Macro processors implement macros using a single or double pass approach to first save macro definitions and then expand macro calls by substituting argument values.
C++ provides built-in and user-defined data types. Built-in data types are pre-defined in C++ and include character, integer, floating point, double, void, and boolean. User-defined data types are composed of built-in types and include arrays, structures, unions, classes, and pointers. Data types determine the type of data that can be stored and the operations that can be performed on that data.
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 ...
Algorithms Lecture 2: Analysis of Algorithms IMohamed Loey
This document discusses analysis of algorithms and time complexity. It explains that analysis of algorithms determines the resources needed to execute algorithms. The time complexity of an algorithm quantifies how long it takes. There are three cases to analyze - worst case, average case, and best case. Common notations for time complexity include O(1), O(n), O(n^2), O(log n), and O(n!). The document provides examples of algorithms and determines their time complexity in different cases. It also discusses how to combine complexities of nested loops and loops in algorithms.
The document discusses functions in C programming. It defines functions as blocks of code that perform a specific task and can be called by other parts of the code. It covers the different components of functions like declarations, definitions, calls, passing arguments, and recursive functions. Recursive functions are functions that call themselves to break down a problem into smaller sub-problems until a base case is reached.
The document discusses the central processing unit (CPU) and its components like registers, arithmetic logic unit (ALU), control unit, and bus. It explains the general register organization of CPU with multiple registers like R1-R7 connected to the ALU, control unit, and bus. The control unit directs information flow and selects components in the CPU to perform operations like addition and shifting. The document also covers addressing modes, instruction formats, data transfer and manipulation instructions, and stack organization in a CPU.
The document provides an introduction to Python programming. It discusses key concepts like variables, data types, operators, and sequential data types. Python is presented as an interpreted programming language that uses indentation to indicate blocks of code. Comments and documentation are included to explain the code. Various data types are covered, including numbers, strings, booleans, and lists. Operators for arithmetic, comparison, assignment and more are also summarized.
A small journey in programming using C Language. In This Presentation i provide a small introduction about C Language.
Our Company APSMIND TECHNLOGY PVT LTD actually provide Application/software development training using various language like C, C++, java, .Net, PHP etc.
We also ,develop application and website for various client as for their requirement.
Getters and setters are used to effectively protect data in classes. Getters return the value of a variable while setters set the value. They follow a standard naming convention starting with get/set followed by the variable name capitalized. Constructors initialize objects and can provide initial values. They have the same name as the class and no return type. Value types like int store values directly while reference types store references to objects. The Math class provides predefined math methods that can be accessed without creating an object.
The document discusses multi-dimensional arrays, specifically two-dimensional arrays. It defines two-dimensional arrays as rows and columns that can represent tables, vectors, or matrices. It provides examples of declaring, initializing, inputting, outputting, and storing two-dimensional arrays in C code. It includes code examples for adding, transposing, and multiplying matrices using two-dimensional arrays.
General register organization (computer organization)rishi ram khanal
This document discusses the organization of a CPU and its registers. It includes tables that encode the register selection fields and ALU operations. It also provides examples of micro-operations for the CPU, showing the register selections, ALU operations, and control words. Key registers discussed include the accumulator, instruction register, address register, and program counter.
The document discusses algorithms and their building blocks. It defines an algorithm as a collection of well-defined, unambiguous and effectively computable instructions that return a proper output. The three building blocks of algorithms are identified as sequence, selection, and iteration. Sequence refers to a series of actions performed in order. Selection allows a program to choose between different actions or conditions. Iteration allows a block of code to be repeated while a condition is true. Pseudocode and flowcharts are introduced as common ways to express algorithms and illustrate the control flow and logic of a program.
The document provides an introduction and overview of problem solving techniques for programming. It discusses identifying skills needed for problem solving, applying standard problem solving methods, and generating potential solutions. Specific techniques covered include problem solving steps, strategies, algorithm design, flowcharts, and the C language. Problems are classified as having algorithmic or heuristic solutions. The document then demonstrates applying problem solving techniques to sample problems through defining the problem, analyzing it, designing a solution, implementing it, and evaluating it.
The document discusses various computer programming concepts in C language including data types, operators, control structures, functions, and algorithms. It provides an overview of different types of languages like machine language, assembly language, and high-level languages. It also explains concepts like variables, expressions, I/O functions, data structures and their implementation in C programs through examples. Flowcharts and algorithms for basic mathematical and logical problems are presented. Different loops and decision making statements supported in C like if-else, switch-case, for, while, do-while are described along with their syntax and usage.
Here are the algorithms in pseudocode:
1. Find largest number of unknown set:
- Read first number and assign to largest
- Read next number
- If number is greater than largest, assign it to largest
- Repeat step 2 until no more numbers
- Output largest
2. Find average of numbers:
- Read number of elements n
- Initialize sum = 0
- Initialize i = 0
- Repeat while i < n
- Read element at array[i]
- Add element to sum
- Increment i
- Calculate average = sum / n
- Output average
Here are the algorithms in pseudocode:
1. Find largest number of unknown set:
- Read first number and assign to largest
- Read next number
- If number is greater than largest, assign it to largest
- Repeat step 2 until no more numbers
- Output largest
2. Find average of numbers:
- Read number of elements n
- Initialize sum = 0
- Initialize i = 0
- Repeat while i < n
- Read element at array[i]
- Add element to sum
- Increment i
- Calculate average = sum / n
- Output average
Here is a C program to produce a spiral array as described in the task:
#include <stdio.h>
int main() {
int n = 5;
int arr[n][n];
int num = 1;
int rowBegin = 0;
int rowEnd = n-1;
int colBegin = 0;
int colEnd = n-1;
while(rowBegin <= rowEnd && colBegin <= colEnd) {
// Top row
for(int i=colBegin; i<=colEnd; i++) {
arr[rowBegin][i] = num++;
}
rowBegin++;
// Right column
for(int i=rowBegin;
C and Data structure lab manual ECE (2).pdfjanakim15
This document contains information about regulations for a C programming and data structures laboratory course at PERI Institute of Technology. It includes the vision and mission statements of the institution and computer science department. It provides objectives, list of experiments, outcomes, and other details about the course content and structure.
This document contains a C program to compute the roots of a quadratic equation. It begins by reading in the coefficients a, b, and c from the user. It then calculates the discriminant and determines if the roots are real, equal, or complex. Appropriate messages are printed. If the roots are real and distinct, it calculates and prints them. If equal, it prints the single root. If complex, it separates into real and imaginary parts and prints both roots. The program uses decision making and math functions to systematically solve the quadratic equation.
The document discusses the basics of C programming language including the need for programming languages, problem solving, algorithms, flowcharts, pseudocode, data types, variables, operators, expressions, conditional statements, and arrays. It explains the basic structure of a C program, functions like main(), return statement, preprocessor directives, different types of variables and operators used in C programming.
This document discusses program structure, data types, variables, operators, input/output functions, and debugging in C programming. It provides sample code for a program that calculates the sum of two integers entered by the user. The key steps are: 1) declaring integer variables for the two numbers and their sum, 2) using printf and scanf functions to input the numbers and output the result, and 3) returning 0 at the end of the main function. The document also covers preprocessor directives, data types, naming conventions, arithmetic and logical operators, and debugging techniques.
C is a middle-level general purpose programming language developed in 1972. It uses characters, keywords, variables, constants, data types, expressions and operators. Variables are named locations used to store and manipulate data during execution. C supports several data types including integer, float, character and others. Operators perform actions like arithmetic, relational, logical and bitwise operations on variables and constants.
The document provides an introduction to C programming, covering topics such as what a program is, programming languages, the history of C, and the development stages of a C program. It discusses the key components of a C program including preprocessing directives, the main function, and program layout. Examples are provided to illustrate C code structure and the use of variables, keywords, operators, input/output functions, and formatting output with printf.
Asit Bangalore is providing best Programming course "C LANGUAGE" and helped them to take internship program which is helped to get real time exposure and placements in global world. For more details Please visit our website.
This document provides an overview of the C programming language. It covers various C language concepts like data types, operators, control structures, arrays, strings, functions and more. The document is divided into 9 sections with each section covering a specific C concept. For example, section 1 provides an introduction to C including its history, the difference between compilers and interpreters. Section 2 covers data types, constants and variables in C. Section 3 discusses operators and expressions. Section 4 explains various control structures like if-else, switch case etc. Section 5 is about looping constructs like while, do-while and for loops. Section 6 demonstrates looping with patterns. Section 7 describes arrays in C including 1D and 2D arrays. Section 8 covers
This document provides an introduction to the C programming language. It discusses that C was developed in 1972 by Dennis Ritchie at Bell Labs to create the UNIX operating system. C is a structured, procedural programming language that is widely used to develop operating systems, databases, networks, and more. The document then covers some key concepts in C including functions, header files, variables, data types, operators, and escape sequences. It provides examples of basic C programs and exercises for practicing programming concepts.
The document provides an outline of topics for a C/C++ tutorial, including a "Hello World" program, data types, variables, operators, conditionals, loops, arrays, strings, functions, pointers, command-line arguments, data structures, and memory allocation. It gives examples and explanations of key concepts in C/C++ programming.
The document provides an introduction to algorithms and key concepts related to algorithms such as definition, features, examples, flowcharts, pseudocode. It also discusses different types of programming languages from first to fifth generation. Key points of structured programming approach and introduction to C programming language are explained including data types, variables, constants, input/output functions, operators, type conversion etc.
1. A program to display a name. It prints "My name is John" using printf.
2. A program that adds two numbers. It uses scanf to input two integers, adds them together with +, and prints the result with printf.
3. A program that calculates the radius of a circle given its area. It uses scanf to input the area, calculates the radius by taking the square root of (area/pi), and prints the radius to 3 decimal places using printf and the format specifier %.3f.
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.
4th International Conference on Computer Science and Information Technology (...ijait
4th International Conference on Computer Science and Information Technology
(COMSCI 2025) will act as a major forum for the presentation of innovative ideas,
approaches, developments, and research projects in the area computer Science and
Information Technology. It will also serve to facilitate the exchange of information
between researchers and industry professionals to discuss the latest issues and
advancement in the research area.
This document provides information about the Fifth edition of the magazine "Sthapatya" published by the Association of Civil Engineers (Practicing) Aurangabad. It includes messages from current and past presidents of ACEP, memories and photos from past ACEP events, information on life time achievement awards given by ACEP, and a technical article on concrete maintenance, repairs and strengthening. The document highlights activities of ACEP and provides a technical educational article for members.
David Boutry - Mentors Junior DevelopersDavid Boutry
David Boutry is a Senior Software Engineer in New York with expertise in high-performance data processing and cloud technologies like AWS and Kubernetes. With over eight years in the field, he has led projects that improved system scalability and reduced processing times by 40%. He actively mentors aspiring developers and holds certifications in AWS, Scrum, and Azure.
Water demand - Types , variations and WDSdhanashree78
Water demand refers to the volume of water needed or requested by users for various purposes. It encompasses the water required for domestic, industrial, agricultural, public, and other uses. Essentially, it represents the overall need or quantity of water required to meet the demands of different sectors and activities.
Rigor, ethics, wellbeing and resilience in the ICT doctoral journeyYannis
The doctoral thesis trajectory has been often characterized as a “long and windy road” or a journey to “Ithaka”, suggesting the promises and challenges of this journey of initiation to research. The doctoral candidates need to complete such journey (i) preserving and even enhancing their wellbeing, (ii) overcoming the many challenges through resilience, while keeping (iii) high standards of ethics and (iv) scientific rigor. This talk will provide a personal account of lessons learnt and recommendations from a senior researcher over his 30+ years of doctoral supervision and care for doctoral students. Specific attention will be paid on the special features of the (i) interdisciplinary doctoral research that involves Information and Communications Technologies (ICT) and other scientific traditions, and (ii) the challenges faced in the complex technological and research landscape dominated by Artificial Intelligence.
WIRELESS COMMUNICATION SECURITY AND IT’S PROTECTION METHODSsamueljackson3773
In this paper, the author discusses the concerns of using various wireless communications and how to use
them safely. The author also discusses the future of the wireless industry, wireless communication
security, protection methods, and techniques that could help organizations establish a secure wireless
connection with their employees. The author also discusses other essential factors to learn and note when
manufacturing, selling, or using wireless networks and wireless communication systems.
A SEW-EURODRIVE brake repair kit is needed for maintenance and repair of specific SEW-EURODRIVE brake models, like the BE series. It includes all necessary parts for preventative maintenance and repairs. This ensures proper brake functionality and extends the lifespan of the brake system
Impurities of Water and their Significance.pptxdhanashree78
Impart Taste, Odour, Colour, and Turbidity to water.
Presence of organic matter or industrial wastes or microorganisms (algae) imparts taste and odour to water.
Presence of suspended and colloidal matter imparts turbidity to water.
Blood bank management system project report.pdfKamal Acharya
The main objective of the “Blood Bank management System” all the details in the Blood
Bank’sprocess. This project has some tasks to maintain the Blood Bank through computerization.
Using this blood bank system people can search blood group available which they are needed.
They check it on using our blood bank management website. If in case blood group is not available
in blood bank they can also contact numbers of the persons who has the same blood group he is
need. And he can request the person to done the blood for saving someone life.
The Project describes the smart Blood Bank management system. This report will help you
to know in deep the actual work that has been done as a team work. The main objective of this
application is to automate the complete operations of the blood bank. They need to maintain
hundreds of thousands of records. Also searching should be very faster, so they can find required
details instantly. Main objective is to create a system which helps them to complete their work
faster in simple way by using computer not the oldest way which is used paper. Also our project
contains updated information and many things else.
The project consists of a central repository containing various blood deposits available
along with associated details. These details include blood type, storage area and date of storage.
These details help in maintaining and monitoring the blood deposits. The project is an online
system that allows checking weather required blood deposits of a particular group are available in
the blood bank. Moreover the system also has added features such as patient name and contacts,
blood booking and even need for certain blood group is posted on the website to find available
donors for a blood emergency. This online system is developed on PHP platform and supported
by an MYSQL database to store blood and user specific details.
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;