This document provides an overview of C programming concepts such as data types, variables, constants, keywords, operators, functions, and comments. It includes examples of simple C programs and explanations of concepts like #include directives, printf and scanf functions, and return types. The document is presented as a slideshow by Pradeep Dwivedi and was intended to teach basic C programming.
This document discusses the history and basics of C programming. It covers the different generations of computer languages including machine language, assembly language, procedural languages like C/C++, and non-procedural languages. It provides details on the development of C programming by Dennis Ritchie in 1972 at Bell Labs. It also outlines how to compile and run C programs using IDEs like Turbo C++ in Windows or using commands like gcc in Linux. Finally, it thanks the reader.
This document contains slides about C programming operators from a presentation given by Pradeep Dwivedi. It discusses unary, binary, and ternary operators in C and provides examples of arithmetic, relational, logical, assignment, increment/decrement, conditional, and bitwise operators. It also covers conditional/decision statements like if-else, switch-case, and the ternary operator. Code examples are given to demonstrate the use of various operators and conditional statements.
This document provides information about various loop constructs in C programming including while, for, do-while loops as well as the break, continue, and goto statements. It includes syntax examples and sample code to demonstrate each concept. The document was created by Pradeep Dwivedi, a student pursuing their B.Tech in IT from Hindustan College of Science and Technology in Mathura, India.
This document summarizes common C programming concepts including data types, arrays, functions, conditionals, loops, and the main function. It discusses declaring variables of basic data types like int, float, and double. It also covers one-dimensional and two-dimensional arrays, defining functions with different return types, and using if/else, switch, for, while loops for control flow. The main() function is described as the required entry point for all C programs.
The document provides an overview of a C programming course, including:
1) The course will teach programming C elegantly and writing good algorithms, without fancy graphics.
2) Programming is useful for applying math concepts to the real world through simulation.
3) C was chosen as it is small, common, stable, and quick-running, forming the basis for many languages.
4) The document defines some programming terminology and covers basic C programming concepts like variables, functions, and debugging techniques.
VTU PCD Model Question Paper - Programming in CSyed Mustafa
This document contains Prof. A. Syed Mustafa's answers to a model question paper for the Programming in C and Data Structures course. It includes answers to questions on C variable names, the printf statement, finding the area of a triangle using Heron's formula, determining the size of data types using sizeof, relational and logical operators in C, nested if-else statements, finding the largest of three numbers, do-while loops and calculating factorials, finding the GCD of two numbers using a ternary operator and for loop, and a basic calculator program using a switch statement.
The document discusses various input and output functions in C programming. It describes formatted and unformatted input/output functions. Formatted functions like scanf() and printf() require format specifiers to identify the data type being read or written. Unformatted functions like getchar() and putchar() only work with character data. The document also covers control statements like if, if-else, switch case that allow conditional execution of code in C. Examples are provided to demonstrate the use of various input, output and control functions.
This document summarizes key differences between C and C++. It discusses how C++ made all data types first-class objects, introduced classes with data hiding and member functions, allowed more flexible variable declarations, and added new features like bool, enum types and comments. C++ aimed to make C more object-oriented and added object-oriented programming concepts.
This document discusses the history and basics of C programming. It covers the different generations of computer languages including machine language, assembly language, procedural languages like C/C++, and non-procedural languages. It provides details on the development of C programming by Dennis Ritchie in 1972 at Bell Labs. It also outlines how to compile and run C programs using IDEs like Turbo C++ in Windows or using commands like gcc in Linux. Finally, it thanks the reader.
This document contains slides about C programming operators from a presentation given by Pradeep Dwivedi. It discusses unary, binary, and ternary operators in C and provides examples of arithmetic, relational, logical, assignment, increment/decrement, conditional, and bitwise operators. It also covers conditional/decision statements like if-else, switch-case, and the ternary operator. Code examples are given to demonstrate the use of various operators and conditional statements.
This document provides information about various loop constructs in C programming including while, for, do-while loops as well as the break, continue, and goto statements. It includes syntax examples and sample code to demonstrate each concept. The document was created by Pradeep Dwivedi, a student pursuing their B.Tech in IT from Hindustan College of Science and Technology in Mathura, India.
This document summarizes common C programming concepts including data types, arrays, functions, conditionals, loops, and the main function. It discusses declaring variables of basic data types like int, float, and double. It also covers one-dimensional and two-dimensional arrays, defining functions with different return types, and using if/else, switch, for, while loops for control flow. The main() function is described as the required entry point for all C programs.
The document provides an overview of a C programming course, including:
1) The course will teach programming C elegantly and writing good algorithms, without fancy graphics.
2) Programming is useful for applying math concepts to the real world through simulation.
3) C was chosen as it is small, common, stable, and quick-running, forming the basis for many languages.
4) The document defines some programming terminology and covers basic C programming concepts like variables, functions, and debugging techniques.
VTU PCD Model Question Paper - Programming in CSyed Mustafa
This document contains Prof. A. Syed Mustafa's answers to a model question paper for the Programming in C and Data Structures course. It includes answers to questions on C variable names, the printf statement, finding the area of a triangle using Heron's formula, determining the size of data types using sizeof, relational and logical operators in C, nested if-else statements, finding the largest of three numbers, do-while loops and calculating factorials, finding the GCD of two numbers using a ternary operator and for loop, and a basic calculator program using a switch statement.
The document discusses various input and output functions in C programming. It describes formatted and unformatted input/output functions. Formatted functions like scanf() and printf() require format specifiers to identify the data type being read or written. Unformatted functions like getchar() and putchar() only work with character data. The document also covers control statements like if, if-else, switch case that allow conditional execution of code in C. Examples are provided to demonstrate the use of various input, output and control functions.
This document summarizes key differences between C and C++. It discusses how C++ made all data types first-class objects, introduced classes with data hiding and member functions, allowed more flexible variable declarations, and added new features like bool, enum types and comments. C++ aimed to make C more object-oriented and added object-oriented programming concepts.
This document discusses functions in C/C++ programming. It explains that functions allow complex problems to be broken down into smaller parts or tasks. Functions separate the concept or logic of a program from its implementation. They make programs easier to understand and allow code to be reused by calling the same function multiple times. The document also covers function definitions, prototypes, parameters, arguments, return types and provides examples of built-in library functions.
1. The document discusses basic concepts in the C programming language including data types, variables, operators, input/output functions like printf and scanf, and examples of simple C code.
2. It covers fundamental topics such as declaring variables, performing math operations, taking user input, and outputting results to the screen.
3. The document serves as an introduction to programming in C, outlining key building blocks needed to write basic C programs.
This document provides an overview of the C programming language course contents which includes data types, operators, control statements, functions, arrays, pointers, input/output and string functions. It also discusses the seven steps of programming, C strengths such as efficiency and portability, weaknesses like not being object-oriented, and provides simple C program examples and explanations.
This document contains Prof. A. Syed Mustafa's answers to a model question paper for the Programming in C and Data Structures course. It includes answers to questions on C variable names, the printf statement, finding the area of a triangle using Heron's formula, determining the size of data types using sizeof, relational and logical operators in C, nested if-else statements, finding the largest of three numbers, do-while loops and calculating factorials, finding the GCD of two numbers using a ternary operator and for loop, and a basic calculator program using a switch statement.
Programming is an essential skill if you seek a career in software development, or in other fields of Coding. This fundamental of programming course is the first in the specialization for Introduction to Programming in C, but its lessons extend to any language you might want to study. This is because programming is primarily about solving a set of problems and writing the algorithm.
This lab report summarizes an experiment on conditional operators, nested loops, and goto statements in C programming. It includes examples of using conditional operators to check student results, nested for loops to print a pattern of numbers, and the goto statement to repeat a number input. The report concludes the experiment taught important programming concepts like decision making and loop control flow. Homework problems provide additional examples of half pyramids, largest number comparisons, and nested loop patterns.
Preprocessor directives are commands that are executed by the C preprocessor before compilation. Common preprocessor directives include #include to add header files, #define for macros, #if/#elif/#else for conditional compilation, and #undef to remove macros. Standard input/output functions like printf(), scanf(), gets(), puts() handle formatted and unformatted console I/O. These functions allow reading user input from the keyboard and displaying output to the monitor.
The document discusses the F# programming language. It provides an overview of F# including that it is a functional, object-oriented .NET language. It also summarizes key features of F# like strong typing, higher-order functions, pattern matching and compares syntax examples to C#. Additionally, it mentions resources for learning F# such as books, jobs listings, conferences and community sites.
This document summarizes an lecture on applications of strings and pointers in C programming. It includes examples of using arrays of strings, pointer arithmetic, double pointers, scanf vs gets functions, generating Fibonacci series using recursion, and using the ceil() and floor() math functions. The lecture covers basic and advanced concepts of strings and pointers through examples and explanations.
The document discusses various input/output functions in C including character I/O functions like getchar() and putchar(), string I/O functions like gets() and puts(), and general I/O functions like printf() and scanf(). It provides examples of using these functions to read keyboard input, write output to the screen, read from and write to files. The document also covers format specifiers that can be used with scanf() to read different data types from the input and control skipping or suppressing assignment of certain values.
C formatted and unformatted input and output constructsGopikaS12
This document discusses various C input and output functions such as getchar(), putchar(), gets(), puts(), scanf(), printf(), getch(), and getche(). It explains that getchar() reads a single character from standard input while putchar() displays a character. Gets() reads a line into a buffer until a newline, and puts() writes the string and newline to output. Scanf() stops reading after spaces but gets() reads spaces. Printf() uses format specifiers in a control string to display variables in the desired format.
The document discusses functions in C programming. It provides examples of defining functions with parameters and return types, calling functions by passing arguments, using header files to declare functions, and recursion. It shows functions being defined and called to perform tasks like calculating factorials, displaying prices based on hotel rates and nights, and converting numbers to binary. Functions allow breaking programs into smaller, reusable components.
The document discusses input and output functions in C programming such as printf() and scanf(). It provides examples of how to use format specifiers in printf() and scanf() to output and input different data types like integers, characters, strings and floating point numbers. It also discusses other input/output functions like getchar(), putchar(), gets() and puts() that can be used to read and write single characters and strings. Finally, it demonstrates how to use field widths and flags in output formatting to control the alignment and padding of printed values.
C programming is a widely used programming language. The document provides an overview of key concepts in C programming including variables, data types, operators, decision and loop control statements, functions, pointers, arrays, strings, structures, and input/output functions. It also provides examples to illustrate concepts like arrays, strings, functions, pointers, and structures. The main function is the entry point for all C programs where code execution begins.
The document provides an overview of input and output in C programming. It discusses:
1. The standard input/output library provides a set of universal input and output functions that can be used across hardware platforms.
2. The library implements a simple text stream model for inputting and outputting data to and from devices like keyboards and monitors.
3. While it provides basic terminal-like facilities, the standard library does not support features like graphics, sound, or mouse input that require hardware-specific handling. Other libraries need to be used for these capabilities.
The document provides information about the C programming language. It discusses that C is a procedural language that is case sensitive and can be compiled on various platforms. It also provides examples of C programs, including printing "Hello World", using data types like int and float, and control structures like if-else statements and for loops. The document contains code snippets to demonstrate basic C programming concepts.
The document discusses input and output functions in C programming. It describes formatted functions like printf() and scanf() that allow input and output with formatting. It also describes unformatted functions like getchar(), putchar(), gets(), and puts() that handle character and string input/output without formatting. The formatted functions require format specifiers while the unformatted functions work only with character data types.
The document discusses model-driven app development for iPhone and Android. It introduces some common issues in traditional software development like boring code, accidental complexity, and wrong levels of abstraction. It then presents model-driven development as an approach to address these issues by raising the level of abstraction and generating code from models. Domain-specific languages (DSLs) are presented as a tool for describing domains at a higher level of abstraction. The document demonstrates an example DSL for developing mobile apps and how concepts in the DSL like entities, data providers, views and actions can be mapped to generated code.
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.
This document discusses functions in C/C++ programming. It explains that functions allow complex problems to be broken down into smaller parts or tasks. Functions separate the concept or logic of a program from its implementation. They make programs easier to understand and allow code to be reused by calling the same function multiple times. The document also covers function definitions, prototypes, parameters, arguments, return types and provides examples of built-in library functions.
1. The document discusses basic concepts in the C programming language including data types, variables, operators, input/output functions like printf and scanf, and examples of simple C code.
2. It covers fundamental topics such as declaring variables, performing math operations, taking user input, and outputting results to the screen.
3. The document serves as an introduction to programming in C, outlining key building blocks needed to write basic C programs.
This document provides an overview of the C programming language course contents which includes data types, operators, control statements, functions, arrays, pointers, input/output and string functions. It also discusses the seven steps of programming, C strengths such as efficiency and portability, weaknesses like not being object-oriented, and provides simple C program examples and explanations.
This document contains Prof. A. Syed Mustafa's answers to a model question paper for the Programming in C and Data Structures course. It includes answers to questions on C variable names, the printf statement, finding the area of a triangle using Heron's formula, determining the size of data types using sizeof, relational and logical operators in C, nested if-else statements, finding the largest of three numbers, do-while loops and calculating factorials, finding the GCD of two numbers using a ternary operator and for loop, and a basic calculator program using a switch statement.
Programming is an essential skill if you seek a career in software development, or in other fields of Coding. This fundamental of programming course is the first in the specialization for Introduction to Programming in C, but its lessons extend to any language you might want to study. This is because programming is primarily about solving a set of problems and writing the algorithm.
This lab report summarizes an experiment on conditional operators, nested loops, and goto statements in C programming. It includes examples of using conditional operators to check student results, nested for loops to print a pattern of numbers, and the goto statement to repeat a number input. The report concludes the experiment taught important programming concepts like decision making and loop control flow. Homework problems provide additional examples of half pyramids, largest number comparisons, and nested loop patterns.
Preprocessor directives are commands that are executed by the C preprocessor before compilation. Common preprocessor directives include #include to add header files, #define for macros, #if/#elif/#else for conditional compilation, and #undef to remove macros. Standard input/output functions like printf(), scanf(), gets(), puts() handle formatted and unformatted console I/O. These functions allow reading user input from the keyboard and displaying output to the monitor.
The document discusses the F# programming language. It provides an overview of F# including that it is a functional, object-oriented .NET language. It also summarizes key features of F# like strong typing, higher-order functions, pattern matching and compares syntax examples to C#. Additionally, it mentions resources for learning F# such as books, jobs listings, conferences and community sites.
This document summarizes an lecture on applications of strings and pointers in C programming. It includes examples of using arrays of strings, pointer arithmetic, double pointers, scanf vs gets functions, generating Fibonacci series using recursion, and using the ceil() and floor() math functions. The lecture covers basic and advanced concepts of strings and pointers through examples and explanations.
The document discusses various input/output functions in C including character I/O functions like getchar() and putchar(), string I/O functions like gets() and puts(), and general I/O functions like printf() and scanf(). It provides examples of using these functions to read keyboard input, write output to the screen, read from and write to files. The document also covers format specifiers that can be used with scanf() to read different data types from the input and control skipping or suppressing assignment of certain values.
C formatted and unformatted input and output constructsGopikaS12
This document discusses various C input and output functions such as getchar(), putchar(), gets(), puts(), scanf(), printf(), getch(), and getche(). It explains that getchar() reads a single character from standard input while putchar() displays a character. Gets() reads a line into a buffer until a newline, and puts() writes the string and newline to output. Scanf() stops reading after spaces but gets() reads spaces. Printf() uses format specifiers in a control string to display variables in the desired format.
The document discusses functions in C programming. It provides examples of defining functions with parameters and return types, calling functions by passing arguments, using header files to declare functions, and recursion. It shows functions being defined and called to perform tasks like calculating factorials, displaying prices based on hotel rates and nights, and converting numbers to binary. Functions allow breaking programs into smaller, reusable components.
The document discusses input and output functions in C programming such as printf() and scanf(). It provides examples of how to use format specifiers in printf() and scanf() to output and input different data types like integers, characters, strings and floating point numbers. It also discusses other input/output functions like getchar(), putchar(), gets() and puts() that can be used to read and write single characters and strings. Finally, it demonstrates how to use field widths and flags in output formatting to control the alignment and padding of printed values.
C programming is a widely used programming language. The document provides an overview of key concepts in C programming including variables, data types, operators, decision and loop control statements, functions, pointers, arrays, strings, structures, and input/output functions. It also provides examples to illustrate concepts like arrays, strings, functions, pointers, and structures. The main function is the entry point for all C programs where code execution begins.
The document provides an overview of input and output in C programming. It discusses:
1. The standard input/output library provides a set of universal input and output functions that can be used across hardware platforms.
2. The library implements a simple text stream model for inputting and outputting data to and from devices like keyboards and monitors.
3. While it provides basic terminal-like facilities, the standard library does not support features like graphics, sound, or mouse input that require hardware-specific handling. Other libraries need to be used for these capabilities.
The document provides information about the C programming language. It discusses that C is a procedural language that is case sensitive and can be compiled on various platforms. It also provides examples of C programs, including printing "Hello World", using data types like int and float, and control structures like if-else statements and for loops. The document contains code snippets to demonstrate basic C programming concepts.
The document discusses input and output functions in C programming. It describes formatted functions like printf() and scanf() that allow input and output with formatting. It also describes unformatted functions like getchar(), putchar(), gets(), and puts() that handle character and string input/output without formatting. The formatted functions require format specifiers while the unformatted functions work only with character data types.
The document discusses model-driven app development for iPhone and Android. It introduces some common issues in traditional software development like boring code, accidental complexity, and wrong levels of abstraction. It then presents model-driven development as an approach to address these issues by raising the level of abstraction and generating code from models. Domain-specific languages (DSLs) are presented as a tool for describing domains at a higher level of abstraction. The document demonstrates an example DSL for developing mobile apps and how concepts in the DSL like entities, data providers, views and actions can be mapped to generated code.
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.
Functions allow programmers to divide complex problems into smaller subproblems by defining reusable blocks of code (functions) to solve specific subtasks. Functions make programs easier to understand and maintain by separating implementation from concept. In C++, functions are defined with a return type, name, parameters, and body. Functions can be called to reuse their code from other parts of a program like the main function. Function prototypes declare the interface while definitions implement the body.
This document provides an introduction to functions in C++. It discusses how functions allow complex problems to be broken down into smaller parts, making the code more modular and reusable. The key aspects of functions covered include: defining functions with a return type and parameters, calling functions by passing arguments, using function prototypes to declare the interface, and placing function definitions in the code. Examples are provided of functions to calculate the absolute value of a number and total seconds from hours, minutes and seconds.
This document provides an overview of embedded systems programming. It discusses that embedded computers are used as part of larger systems to control physical devices. Reliability is often critical and resources are limited. Application areas include microcontrollers, real-time response requirements, and possible organization of embedded systems. C is discussed as a commonly used programming language for embedded systems due to its efficiency, ability to handle low-level activities, and ability to be compiled on different computers.
Compiler Construction | Lecture 2 | Declarative Syntax DefinitionEelco Visser
The document describes a lecture on declarative syntax definition. It discusses the perspective on declarative syntax definition explained in an Onward! 2010 essay. It also mentions an OOPSLA 2011 paper that introduced the SPoofax Testing (SPT) language used in the section on testing syntax definitions. Finally, it provides a link to documentation on the SDF3 syntax definition formalism.
1. The document discusses abstract data types (ADTs) and how they are represented by classes in C++. It provides examples of ADT specifications and how classes define the public interface and encapsulate private data.
2. The concepts of encapsulation, inheritance, polymorphism are explained. Operator overloading and friend functions are demonstrated with examples for a Point class.
3. Guidelines are given for organizing code into header and implementation files and compiling them, along with instructions for an upcoming quiz.
This document provides an overview of the Lecture 2 on Declarative Syntax Definition for the CS4200 Compiler Construction course. The lecture covers the specification of syntax definition from which parsers can be derived, the perspective on declarative syntax definition using SDF, and reading material on the SDF3 syntax definition formalism and papers on testing syntax definitions and declarative syntax. It also discusses what syntax is, both in linguistics and programming languages, and how programs can be described in terms of syntactic categories and language constructs. An example Tiger program for solving the n-queens problem is presented to illustrate syntactic categories in Tiger.
The document discusses preprocessor directives in C programming. It explains that the preprocessor processes the source code before it is passed to the compiler. Some key preprocessor directives discussed include #define for defining macros, #include for including header files, #line for renumbering source lines, and predefined macros like _ _DATE_ _ and _ _LINE_ _. It also discusses macros for logical and mathematical operations and identifies standard input/output streams.
C was initially developed for writing system software. It has since become a popular language for various software programs. C is a high-level language that uses functions and supports structured programming. It facilitates low-level programming through pointers and access to hardware addresses. C is commonly used for systems programming due to its portability, efficiency and ability to access hardware. A C program contains functions, and execution begins with the main() function. Variables must be declared before use and are given a data type. Comments can be included to document a program. Standard headers and libraries provide common functions to C programs.
The document provides an overview of topics that will be covered in a C programming course across 10 sessions. Session 1 introduces basic C concepts. Session 2 covers data types and variables. Session 3 discusses various operators in C like arithmetic, assignment, unary, conditional, relational and logical operators. Later sessions will cover loops, arrays, functions, structures, pointers, file I/O and more advanced C topics. The document includes examples of basic C programs to demonstrate concepts like input/output, arithmetic operations and unary operators.
The main function serves as the starting point for program execution. It controls program flow by calling other functions. A program typically ends at the end of main. All C programs must have a main function which takes no arguments and returns an int. Main contains the core logic that runs the program. Preprocessor directives like #include add functionality by including header files. Macros defined with #define are text replacements that occur before compilation. Conditional compilation with #ifdef/#ifndef includes or excludes blocks of code based on symbol definitions.
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.
slides1-introduction to python-programming.pptxAkhdanMumtaz
This document provides an introduction to the Python programming language. It discusses what Python is, how it works, how to get Python installed, and examples of simple Python programs. Key points covered include that Python is an interpreted, high-level programming language created in 1991, it has an easy to use syntax, and it can be used for a wide range of tasks. The document also demonstrates running Python programs and discusses common programming errors like syntax, runtime, and logic errors.
1. Functions allow programmers to break complex problems into smaller, discrete tasks, making code more modular and reusable. Functions perform specific tasks and can optionally return values or receive parameters.
2. There are two types of functions - predefined functions from standard libraries like stdio.h and math.h, and user-defined functions created for specialized tasks. Functions have a name, parameters, return type, and body.
3. Functions improve code organization and readability. They separate implementation from interface and allow code reuse. Parameters can be passed by value, where copies are used, or by reference, where the function can modify the original arguments.
Utkarsh Kapoor expresses gratitude to various people who helped and supported him in completing another chapter of his life. He thanks his industrial supervisor Mr. Setu Maheshwari for guiding him during his training. He also thanks his colleagues for their kindness and help. Finally, he thanks his parents for their sacrifice and inspiration in allowing him to pursue his studies.
This document provides an overview of Objective-C and discusses several key concepts:
1. It begins with instructions for setting up the Objective-C development environment on Linux, Mac OS X, and Windows systems.
2. A "Hello World" example program is presented to demonstrate the basic structure of an Objective-C application and how to print output.
3. Object-oriented concepts like classes, inheritance, and polymorphism are explained through examples showing how to define classes with interfaces and implementations, create class instances, and call methods.
4. Additional Objective-C features are demonstrated like method parameters, constructors, access privileges, class methods, and exceptions handling.
1- Modeling Hierarchy
2- Creating Testbenches
Skills gained:
1- Reuse design units several times in a design hierarchy
2- Automate testing of design units
This is part of VHDL 360 course
The document discusses object oriented programming concepts including applets, differences between applets and applications, the lifecycle of an applet, creating applets, passing parameters to applets, an introduction to Swing components and limitations of AWT. It also discusses the MVC architecture and its components - model, view and controller.
6. Some program and explanations.TOPIC:- Monday, August 30, 2010 2 PRADEEP DWIVEDI [pur.B.TECH-IT]
7. SAMPLE PROGRAM(SEE-SAMPLE.C) Monday, August 30, 2010 PRADEEP DWIVEDI [pur.B.TECH-IT] 3 #include<stdio.h> #include<conio.h> void main() { clrscr(); printf(“hello, I am pradeep”); getch(); }
8. #include directve Monday, August 30, 2010 PRADEEP DWIVEDI [pur.B.TECH-IT] 4 c programs are divided in to modules or functions. some functions are written by users, like us , and many other are stored in the c library. library functions are grouped category-wise and stored in different files known as header files. if we want to access the function stored in the library , it is necessary to tell the compiler about the file to be accessed. this is achieved by using the preprocessor directive #include.
9.
10. SAMPLE PROGRAM(SEE-SAMPLE.C) Monday, August 30, 2010 PRADEEP DWIVEDI [pur.B.TECH-IT] 7 this program when executed will produce the following output. hello, I am pradeep the first inform that the execution of our program begin at this line. the main is a predefine(special) function used by the c system to tell the compiler where the program starts. every program must have exactly one main function. if we use more than one main function the compiler can not understand which one marks the beginning of the program.
11. SAMPLE PROGRAM(SEE-SAMPLE.C) Monday, August 30, 2010 PRADEEP DWIVEDI [pur.B.TECH-IT] 8 the opening brace { in the second line marks the beginning of the function main() and the closing brace } in the last line indicates the end of the function. printf() is a standard predefine c function for printing output. predefined means that it is a function that has already been written and compiled and linked together with program at the time of linking. the printf function every thing between the starting and the ending quotation marks to be printed out. semicolon(;) sign is called terminator. every statement in c should end with a semicolon.
12. TERMs RELATED TO PROG Monday, August 30, 2010 PRADEEP DWIVEDI [pur.B.TECH-IT] 9 clrscr(); is a predefine function that clear the output screen. it comes from conio.h header file. getch(); is also a predefine function which is used to pause the output screen.
13. FORMAT OF SIMPLE C PROGRAM Monday, August 30, 2010 PRADEEP DWIVEDI [pur.B.TECH-IT] 10 main() function name { start the program } end the program program statements (body)
14. CHARACTER SET Monday, August 30, 2010 PRADEEP DWIVEDI [pur.B.TECH-IT] 11 The character in c are grouped into the following categories. Letters Digits Special characters White space
15. C TOKENS Monday, August 30, 2010 PRADEEP DWIVEDI [pur.B.TECH-IT] 12 in a passage of text individual words and punctuation are called tokens. Similarly, in c program the smallest individual units are known as c tokens.
17. VARIABLES Monday, August 30, 2010 PRADEEP DWIVEDI [pur.B.TECH-IT] 14 Variables are a place holder that holds the place in computer memory for the value. Because its value may be varied that’s why it is known as variable. int a; (this is called variable declaration). data type variable. int a=10;(this is called initialization of variable.
18. DATA TYPES Monday, August 30, 2010 PRADEEP DWIVEDI [pur.B.TECH-IT] 15 data type decide that what kind of value should be held by the variable. in c data types are classified into three categories. primary(or fundamental data) types. derived data types. user defined data types.
21. DATA TYPES Monday, August 30, 2010 PRADEEP DWIVEDI [pur.B.TECH-IT] 18 void type:- void has no value. this is usually used to specify the type of function.
22. KEYWORDS AND IDENTIFIERS Monday, August 30, 2010 PRADEEP DWIVEDI [pur.B.TECH-IT] 19 KEYWORDS are the reserve words those are having some predefine meaning and those are only use for their predefine meaning. all keywords in c are in lower case. in c we have 32 keywords. eg, if, else, for, while, char, int etc. IDENTIFIERS refers to the names of variable, function and arrays.
23. NAMING RULES AND CONVENTIONS FOR THE VARIABLE NAME(IDENTIFIERS) Monday, August 30, 2010 PRADEEP DWIVEDI [pur.B.TECH-IT] 20 a variable name can be anything but it should be short and meaningful. a variable name can not start with a digit. it must be started with an alphabet letter. but a variable name can be followed by n number of digits. it can be started with an underscore sign(_) also. we can not use any special symbol like @,#,*,& in a variable name. we can not use any space in a variable name. if we are having mare than one word in a variable name and space is required that time we can use the underscore(_) sign between them. my_name ,myName. any keywords can not be a variable name.
24. prog:1 Monday, August 30, 2010 PRADEEP DWIVEDI [pur.B.TECH-IT] 21 /*WRITE A PROGRAM TO ACCEPT A NUMBER FROM THE USER AND PRINT THEM*/ #include<stdio.h> #include<conio.h> void main() { int number; clrscr(); printf("Enter a number"); scanf("%d",&number); printf("the number is: %d",number); getch(); }
25. TERMs RELATED TO PROG Monday, August 30, 2010 PRADEEP DWIVEDI [pur.B.TECH-IT] 22 printf() is a predefine function with the help of that we can print the data in any specified format or agates if it is in double quotes. (“ “); scanf() is again a predefine function that can accept data in any specified format.
26. FORMAT STRING Monday, August 30, 2010 PRADEEP DWIVEDI [pur.B.TECH-IT] 23 format string is used to specify the format of the data . these are following type of:- %d (decimal) %f (float) %c (character) %s (string) %x (hexadecimal)
27. ADDRESS OPERATOR(&) Monday, August 30, 2010 PRADEEP DWIVEDI [pur.B.TECH-IT] 24 It is used to keep the address of that place where the value is placed.
28. prog4 Monday, August 30, 2010 PRADEEP DWIVEDI [pur.B.TECH-IT] 25 /*write a program to convert a character to its ascii value*/ #include<stdio.h> #include<conio.h> void main() { char alph; clrscr(); printf("Enter a character"); scanf("%c",&alph); printf("value of character is %c",alph); printf("value of character equivalent is %d",alph); getche(); }
29. SOME POINTS Monday, August 30, 2010 PRADEEP DWIVEDI [pur.B.TECH-IT] 26 note:- each and every character is internally treated as an integer. getch(); is a predefine function that accept a character on the output screen . it just wait for a character. getche(); is having same functionality like getch() function but different is that it displayed the accepted character on the consol screen. getchar(); is also a predefine function that accept a character but that character must be followed by the enter key. note:-drawback of scanf function is that it never accept the space.
30. COMMENTS Monday, August 30, 2010 PRADEEP DWIVEDI [pur.B.TECH-IT] 27 commets are used to give the better readability of a program. at the time of program execution comments are ignored by the compiler. these are two types of: //single line comments /* multiple line comments */ note:-we can not use nested comments.
31. RETURN TYPE Monday, August 30, 2010 PRADEEP DWIVEDI [pur.B.TECH-IT] 28 It decide what kind of value should be returned by the function. if we don’t use any return type before the function that time by default there is int. return is a keyword with the help of that we can return a value and a value is always return where the function is being called.