0% found this document useful (0 votes)
21 views8 pages

Programming For Problem Solving: (ES101CS)

The document outlines the curriculum for a Computer Science course focusing on C programming, including textbooks, historical context, and programming fundamentals. It covers the evolution of the C language, its features, and the software development methodology through a case study on converting miles to kilometers. Additionally, it emphasizes the importance of problem-solving skills in programming and provides guidelines for declaring variables in C.

Uploaded by

sathwikjuluri15
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views8 pages

Programming For Problem Solving: (ES101CS)

The document outlines the curriculum for a Computer Science course focusing on C programming, including textbooks, historical context, and programming fundamentals. It covers the evolution of the C language, its features, and the software development methodology through a case study on converting miles to kilometers. Additionally, it emphasizes the importance of problem-solving skills in programming and provides guidelines for declaring variables in C.

Uploaded by

sathwikjuluri15
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

08-09-2025

Text Books:
T1: Computer Science A structured programming approach
using C, Behrouz Forouzan and Richard F. Gilberg ,
Cengage Learning , 2007 ,Third Edition (Unit 1-5)
Programming for Problem Solving T2: Schaum's Outline of Programming with C, Byron
Gottfried, McGraw-Hill 2019, Fourth Edition (Unit 1-5)
(ES101CS)
T3: Data Structures and Program Design in C, Robert Kruse,
N Srikanth Prasad Bruce Leung, Tondo, Pearson, II Edition
[email protected]
+91 – 93 9104 9134 References/ Suggested Reading
R1. C Programming Language, Brian W Kenningham, Dennis
M Ritchie, Pearson, II Edition
R2. How to solve it by Computer, R G Dromey, Pearson
Edition
1 2
MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade

Introduction to C Language: High-Level Languages


• History of C
Language Application Area Origin of Name
• Features FORTRAN Scientific programming Formula translation
Common Business-Oriented
• Structure of C program COBOL Business data processing
Language
• Character set LISP Artificial intelligence List processing
Predecessor language was
C Systems programming
• Tokens named B
Prolog Artificial Intelligence Logic programming
• Variables Ada Augusta Byron
Ada Real-time distributed systems collaborated with Charles
• Data types Babbage
Graphical user interfaces; object- Objects “talk” to one another
• I/O statements Smalltalk
oriented programming via messages
• Type conversion Syntax and Logical Errors in Supports objects and object-
Incremental modification of C
C++ (++ is the C increment
compilation oriented programming
operator)
• Object and executable code. Java Supports Web programming Originally named “Oak”

3 4
MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade

History Of C Programming Language History Of C Programming Language

• The C programming language originated in the early 1970s at Bell • 1973: The Unix operating system kernel is largely rewritten
Labs, developed by Dennis Ritchie. It evolved from earlier in C, demonstrating C's power and efficiency for system
languages like ALGOL 60, BCPL (Basic Combined Programming programming.
Language), and B. • 1978: Brian Kernighan and Dennis Ritchie publish "The C
Programming Language" (K&R C), which becomes the de
• 1960s: ALGOL 60 introduces the concept of block structure,
influencing future languages. Martin Richards develops BCPL in facto standard for the language.
1966 for system programming. • 1989: The American National Standards Institute (ANSI)
• 1970: Ken Thompson creates 'B,' a simplified version of BCPL, standardizes C, leading to ANSI C, enhancing portability and
used for early Unix development. consistency.
• 1990:The International Organization for Standardization
• 1972: Dennis Ritchie develops C at Bell Labs, building upon
BCPL and B. (ISO) adopts the ANSI C standard, creating ISO C.

5 6
MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade

1
08-09-2025

History Of C Programming Language History Of C Programming Language

• 1991: Linus Torvalds begins developing the Linux kernel • 2020s: C continues to be a foundational language for
using C, further solidifying C's role in operating system system programming, embedded systems, operating
development.
systems (like Linux and parts of Windows), and
• 1999: The C99 standard is published by ISO, introducing high-performance computing, with ongoing
new features like variable-length arrays, long long int, and maintenance and minor updates to the standard as
improved floating-point support. needed. While newer languages emerge, C's efficiency,
control over hardware, and vast existing codebase
• 2011: The C11 standard is released, adding features such as ensure its continued relevance through 2025 and
multi-threading support, atomic operations, and generic
selections. beyond.

• 2018: The C17 standard (also known as C18) is published,


primarily focusing on technical corrections and clarifications
to C11.
7 8
MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade

/* Converts distances from miles to kilometers. */


Structure of C program standard header file comment

Features
Preprocessor # include <stdio.h> /*printf, scanf definitions*/
directive # define KMS_PER_MILE 1.609 /*printf, scanf definitions*/
• Efficiency and Speed: C provides low-level memory access and direct reserved words
constant
hardware manipulation, leading to highly efficient and fast programs. int
main(void)
• Portability: C programs can be compiled and run on various hardware {
platforms and operating systems with minimal modifications.
double miles, /*distance in mile*/
• Structured Programming: It supports structured programming variable kms; /*equivalent distance in kilometer*/
constructs like functions, loops, and conditional statements, promoting
/* Get the distance in miles. */ comment
modular and organized code.
printf("Enter the distance in miles> ");
• Rich Library: C has a rich set of built-in functions and libraries that standard
identifier scanf("%lf", &miles);
simplify common programming tasks.
• Memory Management: It provides features for dynamic memory /* Convert the distance to kilometers. */
allocation and deallocation, giving programmers fine-grained control
over memory. kms = KMS_PER_MILE * miles;
special symbol
9 10
MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade

/* Converts distances from miles to kilometers. */


/* Display the distance in kilometers. */ standard header file
comment
printf("That equals %f kilometers.\\n", kms);

reserved word return (0); punctuation Preprocessor # include <stdio.h> /*printf, scanf definitions*/
directive # define KMS_PER_MILE 1.609 /*conversion constant*/
} special symbol reserved words
constant
int
main(void)
{
double miles, /*distance in mile*/
variable kms; /*equivalent distance in kilometer*/
/* Get the distance in miles. */ comment
printf("Enter the distance in miles> ");
standard
identifier scanf("%lf", &miles);

/* Convert the distance to kilometers. */


kms = KMS_PER_MILE * miles;
special symbol

11 12
MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade

2
08-09-2025

/* Display the distance in kilometers. */ Parts of C program


printf("That equals %f kilometers.\\n", kms);
• # include <stdio.h> – This command is a preprocessor directive in C that
return (0); punctuation includes all standard input-output files before compiling any C program so as
reserved word
to make use of all those functions in our C program.
special symbol • int main() – This is the line from where the execution of the program starts.
}
The main() function starts the execution of any C program.
• { (Opening bracket) – This indicates the beginning of any function in the
program (Here it indicates the beginning of the main function).
• /* some comments */ – Whatever is inside /*——-*/ are not compiled and
executed; they are only written for user understanding or for making the
program interactive by inserting a comment line. These are known as
multiline comments. Single line comments are represented with the help of 2
forward slashes “//——”.
• printf(“Hello World”) –The printf() command is included in the C stdio.h
library, which helps to display the message on the output screen.
• getch() – This command helps to hold the screen.
• return 0 –This command terminates the C program and returns a null value,
that is, 0.
• } (Closing brackets)- This indicates the end of the function. (Here it indicates
13 the end of the main function) 14
MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade

Be A Problem Solver The Software Development Method


Design /
• You need to be a problem solver. Problem Analysis
Algorithm
Implementation Testing Maintenance

• A good problem solver → a good programmer.


• Programmers use the Software Development Method.
• This is what you will learn in this course.

15 16
MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade

The Software Development Method The Software Development Method


Case Study: Converting Miles to Kilo Case Study: Converting Miles to Kilo
Design / Design /
Analysis Implementation Testing Maintenance Problem Implementation Testing Maintenance
Algorithm Algorithm

1. Problem: 2. Analysis:
Your summer surveying job requires you to study some 1. Problem Input: miles
maps that give distances in kilometers and some that use 2. Problem Output: kilometers
miles.You and your coworkers prefer to deal in metric
measurements. Write a programthat performs the 3. Relevant Formula: 1 mile = 1.609 kilometers
necessary conversion.

17 18
MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade

3
08-09-2025

The Software Development Method The Software Development Method


Case Study: Converting Miles to Kilo Case Study: Converting Miles to Kilo
Design /
Problem Analysis Implementation Testing Maintenance Problem Analysis Testing Maintenance
Algorithm

4. Implementation:
3. Design / Algorithm:
1. Get the distance in miles.
2. Convert the distance to kilometers.
(1 kilometer = 1.609 miles)
3. Display the distance in kilometers.

19 20
MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade

The Software Development Method The Software Development Method


Case Study: Converting Miles to Kilo Case Study: Converting Miles to Kilo
Design / Design /
Problem Analysis Implementation Maintenance Problem Analysis Implementation Testing
Algorithm Algorithm

5. Testing: 6. Maintenance :
1. Verify that the program works properly. 1. Remove undetected errors.
2. Try few test cases. 2. Keep it up-to-date.

21 22
MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade

Variables Variables
Variables are used to store the value during the execution of There are set of rules to be followed while declaring
variables and data types in C Programming:
a program.
• The 1st letter should be alphabet.
In C Programming we always have to declare variable
• Variables can be combination of alphabets and digits.
before we can use them. Note that the space is allocated to
• Underscore (_) is the only special character allowed.
variable in memory during execution or run-time.
• Variables can be written in both Uppercase and Lowercase or
C is a strongly typed language. What this means it that, the
combination of both.
type of a variable cannot be changed. Suppose we
• Variables are Case Sensitive.
declared an integer type variable so we cannot store
• No Spaces allowed between Characters.
character or a decimal number in that variable.
• Variable name should not make use to the C Reserved
Keywords.
• Variable name should not start with a number.
23 24
MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade

4
08-09-2025

Variables Variables
 Use variables to store the values in the algorithm.
 Variables vs.Constants . Choose good names for the variables:
 Algorithm without variables: • No need to write any comment
1. Get the distance in miles. • Easy to track
2. Convert the distance to kilometers. • Case sensitive
(l kilDmeter = 1.609 miles) • Don't use a Reserved Word
3.Display the distance  The algorithm with good variables' names:
 Algorithm with variables:
1. Get the value X (X: the distance in miles) 1. Get the value TotalMiles
2. Y= X / 1.609 (Y: the distance in kilo) 2. TotalKilo = TotalMiles/1.609
3. Display the value Y
3. Display the value Totalkilo
25 26
MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade

Variables Syntax in C Variables and Memory


The memory stores the last value of each variable in the program.
The following program consists of 3 variables. Show the value of each
True or False: variable in the memory after executing each statement?
1. X = 10; 1. X = 10; # X Y Z
2. Z = 15.5; 1. 10
2. Y = 20 FaIse; Why!
3. Y = X +Z; 2. 15.5
3. Z = 15.5; 4. Y =Y+1; 3. 25.5
4. Y = X +Z; 5. Z = Y-1.5+5; 4. 26.5

5. Y =Y+1; 6. Z = Z/2 + 5; 5. 30
7. X = Z % 3; 6. 20
6. Z = Y-1.5+5; 7. 2
7. 23 = Z; FaIse; Why! What are the values of (X, Y, Z) in the memory after
8. Z = Z/2 + 5; executing the program?
27 28
MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade

Data Types

29 30
MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade

5
08-09-2025

The Different Data Types In C Language


There are 4 different types of data types in C, they are-
4. User-Defined Data Types: These are similar to derived data types in that they are a
combination of or are derived from other basic data types. But one major difference
1.Primitive Data Types: This data type includes- integer data type (int),
between derived and user-defined data types is that the latter is created by users
character data type, i.e., character or small integer value (char), floating-point
themselves.
data type, i.e., containing fractional part (float), and double data type (double),
which is the same as float data type, but it occupies twice the storage space. 5. Void Data Type/ Null Pointer: This is the data type used when the pointer not pointing
to any valid location.
2.Enumerated Data Types: This data type consists of named integral constants
represented by identifiers. For example, false/true for boolean types or days in a
week like Monday/Tuesday, etc.

3.Derived Data Types: These are those data types that are derived from the
other basic data types in C. Some common examples of the same
are Arrays (i.e., a collection of elements having the same data type stored at
contiguous memory locations), Pointers (that store address to a memory location
that holds some particular value), Structure (struct, i.e., a user-defined
composite datatype containing fields each having different datatypes), and
Union contains set of variables sharing common storage area.

31 32
MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade

Memory Size
Data Types In C Format Specifier Range
Primary Data Types In C (in bytes)
unsigned short int %hu 0 to 65,535 2
short int %hd -32,768 to 32,767 2
usigned int %u 0 to 4,294,967,295 4
-2,147,483,648 to
Int %d 4
2,147,483,647
-2,147,483,648 to
long int %ld 4
2,147,483,647
unsigned long int %lu 0 to 4,294,967,295 4
long long int %lld -(2^63) to (2^63)-1 8
unsigned long long int %llu 0 to 8
18,446,744,073,709,551,615
signed char
%c -128 to 127 1

unsigned char %c 0 to 255 1


float %f 1.2E-38 to 3.4E+38 4
double %lf 1.7E-308 to 1.7E+308 8
long double %lf 3.4E-4932 to 1.1E+4932 16

33 34
MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade

Integer Data Type in C (With Example)


Example of integer data type in C: Variables and Data Types in C
#include <stdio.h>
#include <limits.h>
int main ( )
{
int minIntValue;
minIntValue = INT_MIN ;
printf("Minimum limit for Integer data stores : %d \n",minIntValue);
return 0;

}
Output:
Minimum limit for Integer data stores: -2147483648

35 36
MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade

6
08-09-2025

EXAMPLE 2: Float Variable in C


EXAMPLE 1: Integer Variable in C
#include <stdio.h>
#include <stdio.h>
void main()
void main()
{
{
int i = 10;
float f = 3.1415;
printf("This is my integer: %d \n", i);
printf("This is my float: %f \n", f);
}
}
The %f is to tell printf() function to format the float variable f as a decimal floating
number. The output from this program would be This is my float: 3.1415.
The %d is to tell printf() function to format the integer i as a
decimal number. The output from this program would be This is Now if we want to see only the first 2 numbers after the floating point, we would
my integer: 10. have to modify printf() function call to be as given below:

printf("This is my shorter float: %.2f \n", f);

37
The output from this program would be This is my float: 3.14. 38
MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade

EXAMPLE 3: Character Variable in C


#include <stdio.h> Data types in C Programming
void main()
{ Data Type Size Value Range
char c; char 1 byte -128 to 127 or 0 to 255
c = 'b'; unsigned char 1 byte 0 to 255
printf("This is my character: %c \n", c); signed char 1 byte -128 to 127
} -32,768 to 32,767 or -
int 2 or 4 bytes 2,147,483,648 to
The %c is to tell printf() function to format the variable “c” as a character. 2,147,483,647
The output from this program would be This is my character: b. 0 to 65,535 or 0 to
unsigned int 2 or 4 bytes
4,294,967,295
short 2 byte -32,768 to 32,767
unsigned short 2 byte 0 to 65,535
-2,147,483,648 to
long 4 byte
2,147,483,647
unsigned long 4 byte 0 to 4,294,967,295
39 40
MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade

Derived Data Types in C


EXAMPLE 3: Calculate Size of Data type on Your Machine
Derived data types in C are created from basic or primitive data types. There are five
To find out the size of each data type on your machine compile and run this subtypes of derived/ user-defined types in C; they are as follows:
program. It uses one new language construct sizeof(). This tells us how many
bytes a data type takes up. 1.Array Type: They are a collection of data stored together as a single unit and
indexed according to the associated value or index. Here, one or more elements can
#include <stdio.h> be arranged under a common name.
int main()
2.Pointers: They reference other variables by storing their address in memory. Note
{ that multiple pointers can point to the same object, but they will always have
printf("sizeof(char) == %d\n", sizeof(char)); separate addresses
printf("sizeof(short) == %d\n", sizeof(short));
3.Structures Types: They are composed of many fields declared within the same
printf("sizeof(int) == %d\n", sizeof(int));
block of memory that may contain different types or values. Structure types are
printf("sizeof(long) == %d\n", sizeof(long)); accessed via dot notation (e.g., struct_name .field_name).
printf("sizeof(long long) == %d\n", sizeof(long long));
4.Unions: They allow users to combine two different sets of values into one
return 0;
variable, with only one set being active at any given time due to limited resources.
}
5.Functions: These allow grouping logic statements representing calculations or
sequences, which can then be referred to through their name without having re-write
41 42
every time it needs to use
MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade

7
08-09-2025

Operators in C Programming Arithmetic Operators

• C Programming Language support several operators to • Arithmetic C operators are used to perform
perform different operations. These operators in c mathematical operations such as addition, subtraction,
programming are mostly in the form of symbols which used
multiplication and division on numerical values
to perform logical and arithmetic operations. These operators
generally work on many types of variables and constants (variables and constants).
although some are restricted to work on specific types.
Operators Operations Example
+ Addition a+b
– Subtraction a-b
* Multiplication a*b
/ Division a/b
% Modulus a%b
43 44
MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade

EXAMPLE 1: Demonstrate working on Arithmetic Operators. In this


example two values “6” and “4” used to perform arithmetic operations
such as addition, subtraction, multiplication, division, modulus and output
displayed for each output.
#include <stdio.h>

int main()
{
int a = 6, b = 4, c;
c = a+b;
c=a/b;
printf("a+b = %d \n",c);
printf("a/b = %d \n",c);
c = a-b;
c=a%b;
printf("a-b = %d \n",c); printf("Remainder when a divided by b = %d \n",c);
c = a*b; return 0;
printf("a*b = %d \n",c); }
45
MET HODIST COLLEGE OF ENGINEERING AND T ECHNOLOGY (AN AUT ONOMOUS INST IT UT ION) Accredited by NBA & NAAC with A+ Grade

You might also like