The document discusses the basics of C programming language including the structure of a C program, constants, variables, data types, operators, and expressions. It explains the different sections of a C program such as documentation, link, definition, global declaration, main function, and user-defined function sections. It also describes various data types in C like integer, floating point, character, and void. Furthermore, it covers various operators used in C like arithmetic, assignment, relational, logical, bitwise, ternary, and increment/decrement operators and provides examples.
The document provides an introduction to the C programming language. It discusses the structure of a C program including documentation, preprocessor directives, header files, and function definitions. It also describes various math and trigonometric functions available in the standard library like sqrt, pow, sin, cos, and log. The rest of the document outlines the steps to compile and execute a C program and defines key concepts like variables, constants, and data types in C.
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.
This document provides an introduction to the C programming language. It discusses that C was developed in 1972 and explains some key concepts in C including data types, variables, constants, and functions. It also demonstrates a simple C program to print text and explains how C code is compiled and executed.
The document provides information about C language and its features. It discusses that C was developed by Dennis Ritchie in 1972 and is a general purpose programming language well suited for business and scientific applications. It also summarizes the basic structure of a C program and describes various C language components like data types, operators, and conditional statements.
This document provides an introduction and overview of the C programming language. It discusses what a computer is and how programming languages work. It introduces machine language and high-level languages like C. Key aspects of C are explained, including data types, variables, operators, functions, and basic syntax. Examples of simple C programs are provided.
This document provides an introduction to the C programming language. It discusses fundamental C elements like data types, variables, constants, operators, and input/output functions. It explains how a basic C program is structured and compiled. Examples are provided to demonstrate simple C statements, arithmetic expressions, and how to write and run a first program that prints text. The key topics covered include basic syntax, program structure, data types, identifiers, operators, and input/output functions like printf() and scanf().
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 basic concepts in C++ programming including:
1. The structure of a basic C++ program including main function, includes, namespaces, and return statements.
2. Data types in C++ including integer, floating point, character types and their sizes. It also discusses variables, constants, and identifiers.
3. Key concepts like comments, data types, variables, constants, and identifiers that are fundamental to C++ programming. Examples are provided to demonstrate how to declare and use variables and constants.
The document provides an overview of the C programming language. It discusses that C is commonly used for embedded systems and systems programming tasks like operating systems and compilers. It was developed between 1969-1973 along with Unix. The "Hello World" example program is shown to demonstrate the basic structure of a C program with main() as the entry point. Data types, variables, and basic I/O functions like printf() and scanf() are described. Operators for arithmetic, comparison, logic, and assignment are also covered.
The document discusses header files and C preprocessors. It defines header files as files containing C declarations and macro definitions that can be shared between source files by including them using the #include directive. Common header files like stdio.h, conio.h, and math.h are given as examples. Preprocessors are described as a macro processor that transforms the program before compilation by handling preprocessor directives like #define. It allows defining macros which are abbreviations for longer code constructs. The document also provides examples of preprocessor directives like #include and #define.
C is a general purpose programming language developed in the 1970s. It has features like control structures, looping statements, and arrays that make it well-suited for business and scientific applications. A C program executes in four steps - creating the program, compiling it, linking it to libraries, and executing the final executable file. C has keywords, variables, data types, operators, and conditional statements that allow for structured programming and control flow.
This document provides an overview of C programming and data structures. It begins with an introduction to C language concepts like data types, variables, constants, I/O functions, operators, and control statements. It then discusses the history and evolution of C from earlier languages like ALGOL and BCPL. The document outlines characteristics of C and its applications. It also covers topics like keywords, identifiers, data type sizes, variable naming rules, and comment syntax. Library functions for input/output like scanf and printf are explained. The different types of constants in C like integer, real, character, and string constants are defined along with their syntax rules.
This document provides an overview of C programming basics and features. It discusses problem solving techniques like algorithms, flowcharts, and pseudo codes. It then introduces C programming, highlighting its features like portability and support for data types. It describes the typical structure of a C program including preprocessor directives, global declarations, the main function, and subprograms. It also covers the compilation and linking process. Finally, it discusses key concepts like variables, identifiers, keywords, and integer, floating point, character, and string constants.
This document provides an introduction to the C programming language. It discusses the basic structure of C programs, including the main function, use of comments, and variable declaration. It also covers the four main data types (integer, float, double, character), and how variables can be initialized and assigned values. The document demonstrates basic input/output using printf statements and formatting specifiers.
The document discusses various topics related to tokens, variables, data types, and operators in C programming. It defines tokens as the smallest elements identified by the compiler, such as keywords, identifiers, string literals, and operators. It describes different variable types like local variables, global variables, and static variables. It also explains various data types in C like integer, float, char, etc and their sizes and ranges. Finally, it discusses various arithmetic, relational, logical, and assignment operators in C and their precedence.
The document provides an introduction to the C programming language, including its history, features, character sets, tokens, data types, operators, and the basic structure of a C program. It discusses key concepts such as variables, constants, comments, functions, input/output, and how to compile and execute a C program.
The document provides an introduction to the C programming language, including its history, features, character sets, tokens, data types, operators, and the basic structure of a C program. It discusses key concepts such as variables, constants, comments, functions, preprocessing directives, and how to compile and execute a C program.
1. Comments are used to explain the purpose of code and are ignored by the compiler. They can be single-line or multiline.
2. Preprocessor directives like #include are used to include header files. Preprocessor statements start with #.
3. A C program structure includes comments, preprocessor directives, global declarations, function declarations, a main function containing declaration and executable sections, and tokens like keywords and identifiers.
CS 3251 Programming in c all unit notes pdfBalamuruganV28
The document discusses the structure of a C program, which includes documentation, link, definition, global declaration, main function, and subprogram sections. It provides an example C program to demonstrate these sections and their usage. It also introduces C programming concepts like data types, constants, keywords, operators, expressions, and control statements.
This document provides an introduction and overview of the C programming language. It begins with a brief history of C and discusses its importance. It then describes the basic structures of a C program, including common sections like the documentation, include, definition, global declaration, main function, and subprogram sections. It also covers C libraries and common header files. The document continues with explanations of constants, variables, data types, and operators in C. It provides details on integer, floating point, character, and void data types. Finally, it discusses defining and declaring variables in C.
This document summarizes key concepts from an introduction to C++ programming chapter, including:
- The main parts of a C++ program are comments, preprocessor directives, the main() function, and statements.
- Variables are used to store and manipulate data in a program. Variables are declared with a name and type before use.
- Arithmetic operators allow performing calculations in C++ programs. Expressions follow order of operations rules.
- Input and output streams allow getting user input and displaying output to the screen.
Introduction to C++ lecture ************Emad Helal
Here is a C++ program to calculate the volume of a sphere:
#include <iostream>
#define PI 3.14159
using namespace std;
int main() {
float radius, volume;
cout << "Enter the radius of the sphere: ";
cin >> radius;
volume = (4/3.0) * PI * radius * radius * radius;
cout << "Volume of the sphere is: " << volume << endl;
return 0;
}
This program first includes the iostream library for input/output functions. It then defines PI as a constant. In main(), it prompts the user to enter the radius, reads it using cin and stores it in
Mca i pic u-2 datatypes and variables in c languageRai University
This document discusses various concepts related to data types and variables in the C programming language. It covers the basic structure of a C program and sections like documentation, definition, global declaration, main function, and subprogram sections. It describes rules for comments, the main method, declaration, data types like integer, floating point, character, and string. It also discusses variables, assigning values, and declaring variables with different storage classes.
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 basic concepts in C++ programming including:
1. The structure of a basic C++ program including main function, includes, namespaces, and return statements.
2. Data types in C++ including integer, floating point, character types and their sizes. It also discusses variables, constants, and identifiers.
3. Key concepts like comments, data types, variables, constants, and identifiers that are fundamental to C++ programming. Examples are provided to demonstrate how to declare and use variables and constants.
The document provides an overview of the C programming language. It discusses that C is commonly used for embedded systems and systems programming tasks like operating systems and compilers. It was developed between 1969-1973 along with Unix. The "Hello World" example program is shown to demonstrate the basic structure of a C program with main() as the entry point. Data types, variables, and basic I/O functions like printf() and scanf() are described. Operators for arithmetic, comparison, logic, and assignment are also covered.
The document discusses header files and C preprocessors. It defines header files as files containing C declarations and macro definitions that can be shared between source files by including them using the #include directive. Common header files like stdio.h, conio.h, and math.h are given as examples. Preprocessors are described as a macro processor that transforms the program before compilation by handling preprocessor directives like #define. It allows defining macros which are abbreviations for longer code constructs. The document also provides examples of preprocessor directives like #include and #define.
C is a general purpose programming language developed in the 1970s. It has features like control structures, looping statements, and arrays that make it well-suited for business and scientific applications. A C program executes in four steps - creating the program, compiling it, linking it to libraries, and executing the final executable file. C has keywords, variables, data types, operators, and conditional statements that allow for structured programming and control flow.
This document provides an overview of C programming and data structures. It begins with an introduction to C language concepts like data types, variables, constants, I/O functions, operators, and control statements. It then discusses the history and evolution of C from earlier languages like ALGOL and BCPL. The document outlines characteristics of C and its applications. It also covers topics like keywords, identifiers, data type sizes, variable naming rules, and comment syntax. Library functions for input/output like scanf and printf are explained. The different types of constants in C like integer, real, character, and string constants are defined along with their syntax rules.
This document provides an overview of C programming basics and features. It discusses problem solving techniques like algorithms, flowcharts, and pseudo codes. It then introduces C programming, highlighting its features like portability and support for data types. It describes the typical structure of a C program including preprocessor directives, global declarations, the main function, and subprograms. It also covers the compilation and linking process. Finally, it discusses key concepts like variables, identifiers, keywords, and integer, floating point, character, and string constants.
This document provides an introduction to the C programming language. It discusses the basic structure of C programs, including the main function, use of comments, and variable declaration. It also covers the four main data types (integer, float, double, character), and how variables can be initialized and assigned values. The document demonstrates basic input/output using printf statements and formatting specifiers.
The document discusses various topics related to tokens, variables, data types, and operators in C programming. It defines tokens as the smallest elements identified by the compiler, such as keywords, identifiers, string literals, and operators. It describes different variable types like local variables, global variables, and static variables. It also explains various data types in C like integer, float, char, etc and their sizes and ranges. Finally, it discusses various arithmetic, relational, logical, and assignment operators in C and their precedence.
The document provides an introduction to the C programming language, including its history, features, character sets, tokens, data types, operators, and the basic structure of a C program. It discusses key concepts such as variables, constants, comments, functions, input/output, and how to compile and execute a C program.
The document provides an introduction to the C programming language, including its history, features, character sets, tokens, data types, operators, and the basic structure of a C program. It discusses key concepts such as variables, constants, comments, functions, preprocessing directives, and how to compile and execute a C program.
1. Comments are used to explain the purpose of code and are ignored by the compiler. They can be single-line or multiline.
2. Preprocessor directives like #include are used to include header files. Preprocessor statements start with #.
3. A C program structure includes comments, preprocessor directives, global declarations, function declarations, a main function containing declaration and executable sections, and tokens like keywords and identifiers.
CS 3251 Programming in c all unit notes pdfBalamuruganV28
The document discusses the structure of a C program, which includes documentation, link, definition, global declaration, main function, and subprogram sections. It provides an example C program to demonstrate these sections and their usage. It also introduces C programming concepts like data types, constants, keywords, operators, expressions, and control statements.
This document provides an introduction and overview of the C programming language. It begins with a brief history of C and discusses its importance. It then describes the basic structures of a C program, including common sections like the documentation, include, definition, global declaration, main function, and subprogram sections. It also covers C libraries and common header files. The document continues with explanations of constants, variables, data types, and operators in C. It provides details on integer, floating point, character, and void data types. Finally, it discusses defining and declaring variables in C.
This document summarizes key concepts from an introduction to C++ programming chapter, including:
- The main parts of a C++ program are comments, preprocessor directives, the main() function, and statements.
- Variables are used to store and manipulate data in a program. Variables are declared with a name and type before use.
- Arithmetic operators allow performing calculations in C++ programs. Expressions follow order of operations rules.
- Input and output streams allow getting user input and displaying output to the screen.
Introduction to C++ lecture ************Emad Helal
Here is a C++ program to calculate the volume of a sphere:
#include <iostream>
#define PI 3.14159
using namespace std;
int main() {
float radius, volume;
cout << "Enter the radius of the sphere: ";
cin >> radius;
volume = (4/3.0) * PI * radius * radius * radius;
cout << "Volume of the sphere is: " << volume << endl;
return 0;
}
This program first includes the iostream library for input/output functions. It then defines PI as a constant. In main(), it prompts the user to enter the radius, reads it using cin and stores it in
Mca i pic u-2 datatypes and variables in c languageRai University
This document discusses various concepts related to data types and variables in the C programming language. It covers the basic structure of a C program and sections like documentation, definition, global declaration, main function, and subprogram sections. It describes rules for comments, the main method, declaration, data types like integer, floating point, character, and string. It also discusses variables, assigning values, and declaring variables with different storage classes.
This presentation was provided by Bill Kasdorf of Kasdorf & Associates LLC and Publishing Technology Partners, during the fifth session of the NISO training series "Accessibility Essentials." Session Five: A Standards Seminar, was held May 1, 2025.
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingCeline George
The Accounting module in Odoo 17 is a complete tool designed to manage all financial aspects of a business. Odoo offers a comprehensive set of tools for generating financial and tax reports, which are crucial for managing a company's finances and ensuring compliance with tax regulations.
How to Set warnings for invoicing specific customers in odooCeline George
Odoo 16 offers a powerful platform for managing sales documents and invoicing efficiently. One of its standout features is the ability to set warnings and block messages for specific customers during the invoicing process.
Understanding P–N Junction Semiconductors: A Beginner’s GuideGS Virdi
Dive into the fundamentals of P–N junctions, the heart of every diode and semiconductor device. In this concise presentation, Dr. G.S. Virdi (Former Chief Scientist, CSIR-CEERI Pilani) covers:
What Is a P–N Junction? Learn how P-type and N-type materials join to create a diode.
Depletion Region & Biasing: See how forward and reverse bias shape the voltage–current behavior.
V–I Characteristics: Understand the curve that defines diode operation.
Real-World Uses: Discover common applications in rectifiers, signal clipping, and more.
Ideal for electronics students, hobbyists, and engineers seeking a clear, practical introduction to P–N junction semiconductors.
GDGLSPGCOER - Git and GitHub Workshop.pptxazeenhodekar
This presentation covers the fundamentals of Git and version control in a practical, beginner-friendly way. Learn key commands, the Git data model, commit workflows, and how to collaborate effectively using Git — all explained with visuals, examples, and relatable humor.
Geography Sem II Unit 1C Correlation of Geography with other school subjectsProfDrShaikhImran
The correlation of school subjects refers to the interconnectedness and mutual reinforcement between different academic disciplines. This concept highlights how knowledge and skills in one subject can support, enhance, or overlap with learning in another. Recognizing these correlations helps in creating a more holistic and meaningful educational experience.
Contact Lens:::: An Overview.pptx.: OptometryMushahidRaza8
A comprehensive guide for Optometry students: understanding in easy launguage of contact lens.
Don't forget to like,share and comments if you found it useful!.
Real GitHub Copilot Exam Dumps for SuccessMark Soia
Download updated GitHub Copilot exam dumps to boost your certification success. Get real exam questions and verified answers for guaranteed performance
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schoolsdogden2
Algebra 1 is often described as a “gateway” class, a pivotal moment that can shape the rest of a student’s K–12 education. Early access is key: successfully completing Algebra 1 in middle school allows students to complete advanced math and science coursework in high school, which research shows lead to higher wages and lower rates of unemployment in adulthood.
Learn how The Atlanta Public Schools is using their data to create a more equitable enrollment in middle school Algebra classes.
1. Chapter 1
Fundamentals of C
1
Dr. A. PHILIP AROKIADOSS
Assistant Professor
Department of Statistics
St. Joseph’s College (Autonomous)
Tiruchirappalli-620 002.
2. INTRODUCTION
This chapter serves as a formal introduction to the
C programming language.
The fundamental elements of the C language.
Algorithms requires as least five statement types;
input, output, arithmetic calculations, selection,
and repetition.
2
3. PROGRAM 1: A C Program that Computes City Tax
Requirements Specification Develop a program
that does the following
1. Prints on the monitor screen a brief description
of the program’s purpose.
2. Prompts the user to enter a value for gross
annual income using the terminal keyboard.
3. Reads a value for gross income.
4. Computes the city income tax for the city of
Oxford, Ohio. The city income tax is 1.75
percent of the gross annual income.
5. Prints the computed city income tax.
3
4. Analysis
Input. Gross annual income in dollars.
Output. The computed city income tax in
dollars.
Formulas. The city income tax is computed
using the formula.
income_tax = 0.0175 * gross_income
4
5. Design
print “A PROGRAM THAT COMPUTES
CITY INCOME TAX”
print “Enter gross income:”
read gross_income
compute city_tax = 0.0175 * gross_income
print city_tax
5
6. Implementation
A PROGRAM THAT COMPUTES CITY INCOME TAX
Enter gross income : 18657
City tax is 326.497500 dollars.
The five lines that we have just explained are
examples of C statements. Notice that they all
terminate with a semicolon.
6
7. LANGUAGE CHARACTER SET AND TOKENS
types of tokens
1. Reserved words (keywords)
2. Identifiers
3. Constants
4. String literals
5. Punctuators
6. Operators
7
8. 1. Reserved words :
Identify language entities, they have special
meanings to the compiler. C reserved words must
be typed fully in lowercase. Some examples of
reserved words from the program are const,
double, int, and return.
8
9. 2. Identifiers
programmer-defined words. Needed for program
variables, functions, and other program constructs.
gross_income and city_tax are examples. Must be
unique within the same scope
1. A to Z , a to z , 0 to 9 , and the underscore “_”
2. The first character must be a letter or an underscore.
3. Only the first 32 characters as significant.
4. There can be no embedded blanks.
5. Reserved words cannot be used as identifiers.
6. Identifiers are case sensitive.
9
10. 3. Constants
fixed values CITY_TAX_RATE = 0.0175 is an
example of a constant.
Integer Constants
commas are not allowed in integer constants.
Floating-Point Constants
either in conventional or scientific notation. For
example, 20.35; 0.2035E+2
Character Constants and Escape Sequences
a character enclosed in single quotation marks.
Precede the single quotation mark by a backslash,
printf(“%c”, ‘”);
Escape sequence
causes a new line during printing. n
10
11. 4. String Literals
characters surrounded by double quotation
marks.
format specifier for output converts the internal
representation of data to readable characters.( %f )
for example,
City tax is 450.000000 dollars.
precede it with a backslash as
“Jim ”Mac” MacDonald”
backslash character can be used as a continuation
character
printf(THIS PROGRAM COMPUTES CITY INCOME
TAX”);
11
12. 5. Punctuators
[ ] ( ) { } , ; : ………* #
6. Operators
result in some kind of computation or action
city_tax = CITY_TAX_TATE * gross_income ;
operators act on operands.
12
13. THE STRUCTURE OF A C PROGRAM
C program consists of following components:
1. Program comments
2. Preprocessor directives
3. Type declarations
4. Named constants
5. Statements
6. Function declarations (prototypes)
7. Function definitions
8. Function calls
13
14. 1. Program Comments
use /* and */ to surround comments, or // to begin comment
lines.
2. Preprocessor Directives
Lines that begin with a pound sign, #,
A preprocessor directive is can instruction to the
preprocessor. Named file inclusion is concerned with adding the
content of a header file to a source program file. Standard
header files. For example,
#include <stdio.h>
#include causes a headerfile to be copied into the code.
programmer-defined header file surrounded by double quotation
marks. #include <d:header1.h>
to advantage in partitioning large programs into several files.
14
15. 3. Data Types and Type Declarations
double gross_income;
double city_tax;
variable’s type determines
1. How it is stored internally
2. What operations can be applied to it
3. How such operations are interpreted
15
16. declare a variable to be of type integer, the compiler
allocates a memory location for that variable. The size of
this memory location depends on the type of the
compiler.
int is 2 bytes the range –32768 through 32768 designed
to perform arithmetic operations and assignment
operations. Two classes of data types:
1. Fundamental data types
2. Programmer-defined data types
to classes of built-in data types:
1. Fundamental data types
2. Derived data types
Examples of derived data types are arrays, strings, and
structures.
16
17. Data Type int
Data Type char
Data Type double
Data initialization
be initialized in two ways,
1. Compile-time initialization
2. Run-time initialization
Strings as a Derived Data Type
A string is a sequence of characters that is
treated as a single data item. A string variable is a
variable that stores a string constant.
17
18. how to declare string variables.
1. Begin the declaration with the keyword char,
Char report_header [41]
2. To initialize a string variable at complie time,
char report_header [41] = “Annual Report”
18
19. 4. Named Constants
const double CITY_TAX_RATE = 0.0175;
is an identifier whose value is fixed and does not
change during the execution of a program in which
it appears.
In C the declaration of a named constant begins
with the keyword const.
During execution, the processor replaces every
occurrence of the named constant .
19
20. 5. Statements
A statement is a specification of an action to be
taken by the computer as the program executes.
Compound Statements
is a list of statements enclosed in braces, { }
20
21. A FIRST LOOK AT FUNCTIONS
as a block of code that performs a specific task.
The function main( )
int main(void) {
Statement;
Statement;
……
……
return 0;
}
21
22. return statement ensures that the constant value 0,
the program status code, is returned to the program
or the operating system that has triggered the
execution of this function main.
Each C program must have one main function.
The type specifier for functions can be int, double,
char, void, and so on, depending on the type of data
that it returns.
22
23. BUILDING A MINIMUM LANGUAGE SUBSET
An expression is a syntactically correct and meaningful
combination of operators and operands.
city_tax = CITY_TAX_RATE * gross_income
An expression statement is any expression followed by
a semicolon.
city_tax = CITY_TAX_RATE * gross_income
23
24. Example 2
area ? short_side 10.05 long_side 20.00
area = short_side * long_side
area 210.00 short_side 10.05 long_side 20.00
24
25. The Standard Output Function printf
This statement is a function call to the standard
library function printf. The parentheses ( ) are known
as the function call operator.
Following compilation, the linker fetches the object
code corresponding to printf from the standard C
library and combines it with your object program.
25
26. Quantity Type printf Format Specifier
int %d
double %f or % lf
char %c
printf(“Your year of birth is %d, and in 2000 you
will be %d years old.” , year_of_birth, 2000 –
year_of_birth);
26
27. Variable Type scanf Format Specifier
int %d
double %lf
char %c
printf(“Type your weight in pounds: “);
scanf(“%d” , &weight_in_pounds);
27
28. Input of String Variables
char string1 [31];
scanf(“%s” , string1);
The reason is that scanf skips whitespace during
string input and picks string values delimited by
whitespace.
the input string values that contain whitespace,
we can use several techniques in C. We will explain
one easy way, which requires the use of the gets
function.
28
29. PREPARING C SOURCE PROGRAM FILES
Here are some style conventions
1. Insert blank lines between consecutive program
sections.
2. Make liberal use of clear and help comments.
3. Keep your comments separate from the program
statements.
4. Type each statement or declaration on a single line.
29
30. 5. Avoid running a statement over multiple lines.
6. Avoid line splicing.
7. Indent all lines that form a compound
statement by the same amount.
8. Type the beginning and end braces, { }, for
compound statements
9. Use whitespace in typing statements.
10. Conclude each function by a comment to
mark its end.
30
31. EXAMPLE PROGRAM 2 : A C Program that Converts
Height and Weight to Metric Units
Enter your first name : Kelly
Enter your last name : Johnson
Enter your height in “inches” : 64
Enter your weight in “pounds” : 110
Kelly Johnson, your height is 162.560000
centimeters, and your weight is 49.894900
kilograms.
31
32. PROGRAM DEBUGGING
1 #include <stdio.h>
2
3 int main (void) {
4 double number;
5
6 printf(“Enter a number : “)
7 scanf(“%lf” , &number);
8 Inverse = 1.0 / number ;
9 printf(“Inverse of %f is %f” , number, inverse);
32
33. ---Configuration : debug – Win32 Debug ---
Compiling …
Debug.c
D:cprogsdebug.c(7) : error C2146: cyntax error :
missing ‘;’ before identifier ‘scanf’
D:cprogsdebug.c(8) : error C2065 ‘inverse’ :
undeclared identifier.
D:cprogsdebug.c(8) : warning C4244 : ‘=‘ :
conversion from ‘const double ‘ to ‘ int ‘ , possible
loss of data.
D:cprogsdebug.c(10) : fatal error C1004 :
unexpected end of file found
Error executing c1.exe
Debug.exe – 3 error(s), 1 warning(s)
33
34. Debugging for Warning Diagnostics
do not force it to stop the compilation.
Debugging Run-Time Errors
Enter a number : 0
Floating point error : Divide by 0 .
Abnormal program termination .
34
35. if number is equal to zero
print “Zero does not have a finite inverse.”
else
compute inverse = 1 / number
end_if
35