[go: up one dir, main page]

0% found this document useful (0 votes)
15 views338 pages

Subject Code: ESC-105-COM Fundamentals of Programming Languages

Uploaded by

shreyaraut203
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)
15 views338 pages

Subject Code: ESC-105-COM Fundamentals of Programming Languages

Uploaded by

shreyaraut203
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/ 338

Subject Code : ESC-105-COM

Fundamentals of Programming Languages


Teaching Scheme:
TH: 03 Hrs/Week PR : 02 Hrs/Week
Credits 03
Examination Scheme:
Comprehensive Continuous Evaluation CCE : 30 Marks
End-Semester : 70 Marks
PR : 25 Marks
Course Objectives:
1) To understand the fundamental Concepts of C
Programming
2) To acquire knowledge and Compare usage of Operators
and Expressions in C Programming
3) To apply Control Flow structures in C Programming for
Problem solving
4) To design a solution using Arrays, Character and String
Arrays in C programming
5) To design a develop solution for simple computational
problems using User Defined Functions in C Programming
6) Justify the use of structures in Problem solving using C
programming language
Course Outcomes:
CO1: To Design algorithms for simple computational
problems.
CO2: To Use mathematical, Logical Operators and
Expressions.
CO3: To apply Control Flow structures for decision making.
CO4: To design a solution using Arrays, Character and String
Arrays.
CO5: To Design and apply user defined functions.
CO6: To Apply structures in Problem solving using C
programming language.
UNIT I
Introduction to Program Planning &
C Programming
 Program Design Tools: Art of Programming
through Algorithms, Flowcharts.
 Overview of C:History and importance C,
Character Set, C Tokens, Keywords and
Identifiers, Constants, Variables, Data types,
Declaration of variables, Storage Class,
Assigning Values to variables, Defining
Symbolic Constants, declaring a Variable as
Constant, Declaring a Variable as Volatile.
Program Design Tools: Algorithms

 Algorithm is defined as a step-by-step procedure for


calculations or problem solving.
 Example 1 :
 Algorithm for send message to friend. –
 Step 1: Unlock the phone –
 Step 2: Open Menu and got to Message app. –
 Step 3: Select option “create message” – Step
 4: Now type the message and sent it.
Program Design Tools: Algorithms

 Example 2 :
Addition of two numbers.
 Algorithm:
 • Step1: Accept two numbers
 • Step2: Perform addition of two numbers
 • Step3: Display result.
Program Design Tools: Flowchart

 As the name suggest these are charts or


diagrams which represent the flow of the
algorithm.
 There are specific shapes to represent
different types of steps in algorithm.
 This gives graphical representation of
the program
Flowcharts
• As name suggested these are charts or diagrams which represent
the flow of the algorithm.
Oval Start or End of program

Rectangle Computation or Processing step

Parallelogram Data Input Output

Diamond Decision making

Circle Connector

Flowline Flow Lines


UNIT: I Problem Solving, Programming and Python Programming
Program Design Tools:
• Example : Addition of two numbers

START

TAKE TWO
NUMBERS FROM
USER

ADD TWO NUMBERS


AND STORE THE
RESULT

DISPLAY RESULT

STOP
Write a Algorithm and draw the flow
chart for that
Algorithm: Flow chart:
 Step1: Accept two numbers START

 Step2: Perform addition of Input


two numbers A,B

 Step3: Display result. Addition=A+B

Print
Addition

STOP
History and importance C
 C is a programming language developed at AT &
T’s Bell Laboratories of USA in 1972.
 It was designed and written by a man named
Dennis Ritchie.
 In the late seventies C began to replace the more
familiar languages of that time like PL/I, ALGOL,
etc.
 ANSI C standard emerged in the early 1980s, this
book was split into two titles:
 The original was still called Programming in C, and
the title that covered ANSI C was called
Programming in ANSI C
History and importance C
C Tokens
 Character set, Identifiers, Keywords, constants,
Data types, type qualifiers, Declaration and
Initialization of variables.
 C Tokens Token: The smallest individual units in
a program are called tokens.
 The ‘C’ tokens are classified as:
1. Character set
2. Keywords
3. Identifiers
4. Constants
5. Operators
Character Set
Character set consists of
i) alphabet from A-Z or a-z
ii) digits from 0-9
iii) Special characters like (,), {,}, [,], , &, $, #,
%, ^, !, ?, :, ;, ",', .
iv) White space character: blank space v)
Escape sequences:
Character Set
\b : backspace • .

 \a: audible bell


\v: vertical tab
\t: horizontal tab
\f: form feed
\r: carriage return
\” :double quotes
 \’: single quotes
\\ :back slash

\r is a carriage return character; it tells your terminal


emulator to move the cursor at the start of the line.
Keywords and Identifiers
 Keywords are reserved words.
 All keywords have fixed meanings.
 Keywords serve as basic building blocks for
program statements.
 In ‘C’, there are 32 keywords.
 All keywords must be written in lower case.
 These 32 keywords are classified into 3 types
namely
1. Type related Keywords (16)
2. Storage related Keywords (4)
3. Control flow related Keywords (12)
Identifiers
 Identifier refers to the names of the variables,
functions and arrays.
 Rules to name a particular identifier:
1. It must start with either alphabet or underscore.
2. Remaining letters may be alphabet, digit,
underscore.
3. Identifier would not allow any special symbol
except underscore.
4. An identifier can be of any length while most
compilers of ‘C’ language recognize only the first 8
characters.
5. Do not use keywords as an identifier.
Constants
 Constants refer to fixed values that do not change
during the execution of a program.
Constants are 2 types.
1. Numerical constants
2. Non-numerical constants
Numerical Constants are 2 types.
– i. Integer constants
– ii. Real constants
Non- Numerical Constants are 2 types.
– i. Character constants
– ii. String or multiple character constants
Integer constants
 An integer constant refers to a sequence of digits. There are three
types of integers, namely, decimal, octal and hexadecimal.
 Decimal integers consist of a set of digits, 0 through 9,
preceded by an optional – or + sign. Valid examples of
decimal integer constants are: 321, -789, 0, +77

 An octal integer constant consists of any combination of digits


from the set 0 through 7, with leading 0. Some examples of
octal integers are 047, 0, 0543, 0655

 Hexadecimal integer constant consists of a sequence of digits


preceded by 0x or 0X. Examples of hexadecimal integer
constants are: 0X49, 0x8D
Real constants
• A real constant is a sequence of digits with a decimal
point. Examples of real constants are: 0.00876, -
0.456, 543.78, +247.0

• A real number may also be expressed in exponential


or scientific notation. Example is: The value 289.45
may be written as 2.8945e2 in exponential notation.
Real constants
• General form is:
mantissa e exponent
The mantissa is either a real number expressed in
decimal notation or an integer.
 The exponent is an integer number with an
optional plus or minus sign.
The letter e is either in lowercase or uppercase.
Character constants
• A single character constant contains a single
character (alphabet, digit, special symbol,
white space) enclosed within a pair of single
quote marks.
• Examples are: '1', 'a', ' ','@' Note: Character
constants have integer values known as ASCII
values.
• Since each character constant represent an
integer value, so character arithmetic is
possible.
• Example Program: .
#include main()
{
char ch='a';
printf("ch=%c\n",ch);
printf("ASCII value of \'%c\'=%d\n",ch,ch);
}
Output:
ch=a ASCII value of 'a'=97
Multiple characters constants
String is a sequence of characters enclosed in
double quotes.
The characters may be an alphabet, digit,
special symbol and white space.
 Each and every string ends with null character
'\0'.
 Examples are: "ab", "ab5", "@an", "6*7"
Variables
• Variable is a data name which can be used to
store a data and a variable may take different
values at different times during execution.
Declaration of variables:
datatype v1,v2,…,vn
 Initialization of variables: Assign a value to a
variable at the time of the variable is declared
 datatype variable_name=constant;
The process of giving initial values to variables
is called initialization
Data types:
Data type specifies which type of data that we
are storing in a variable.
There are 3 types of data types.
1. Primary or primitive or fundamental data
types
2. User defined data types
3. Derived data types
4. Empty data set
Primary data types:
 There four fundamental data types.
 Integer
 Floating point
 Character
Double precision floating point Integer
 'C' provides three different classes of integers.
They are
– a) int
– b) short int
– c) long int
Floating point types:
.
Floating point or real numbers are stored in 32
bits (on all 16 bit and 32 bit machines) with 6
bits precision. 3 classes of floating point types:
i. float ii. double iii. long double
.
• //Program to find number of bytes occupied by primary data types:
#include main()
{
printf("signed char size=%d\n",sizeof(char));
printf("signed short int size=%d\n",sizeof(short int));
printf("signed int size=%d\n",sizeof(int));
printf("signed long int size=%d\n",sizeof(long int));
printf("unsigned char size=%d\n",sizeof(unsigned char));
printf("unsigned int size=%d\n",sizeof(unsigned int));
}
Output:
signed char size=1
signed short int size=2
signed int size=4
signed long int size=4
unsigned char size=1
User defined data types:
• 'C' supports a feature known as “type definition”
that allows users to define an identifier that would
represent an existing data type.
• The user defined data type identifier can later be
used to declare variables.
• General form: typedef type identifier
• where type is any existing data type, identifier is a
new name given to the data type.
– Examples:
– typedef int units;
– typedef float marks;
– units u1,u2;
– marks m1, m2;
Storage Classes
• These features basically include the scope, visibility, and
lifetime which help us to trace the existence of a particular
variable during the runtime of a program.
Assigning Values to variables
Declaring (Creating) Variables
– To create a variable, specify the type and assign it
a value:
Syntax
• type variableName = value;
Example
 Create a variable called myNum of type int and assign
the value 15 to it:
int myNum = 15;
Defining Symbolic Constants
A label or name that is used to represent some
fixed value that never changes throughout the
course of a program.
Example
const int minutesPerHour = 60;
const float PI = 3.14;
declaring a Variable as Constant,
• #include <stdio.h>

#define PI 3.14159

main() {

printf("%f",PI);

}
Declaring a Variable as Volatile.
• ANSI standard defines qualifier volatile that could be
used tell explicitly the compiler that a variable’s
value may be changed at any time by some external
sources (from outside the program).
• Example: volatile int a;
• Example program:
– #include main()
– {
– volatile int a=5;
– printf("a=%d\n",a);
– a=a*4;
– printf("a=%d\n",a); }
Output: a=5 a=20
C Program to Print “Hello World”
// Simple C program to display "Hello World"
.
// Header file for input output functions
#include <stdio.h>
// main function -
// where the execution of program begins
int main()
{
// prints hello world
printf("Hello World");

return 0;
}
Output Hello World
C Program to Find the Size of int, float, double
and char
#include <stdio.h> // Calculate and Print
// the size of floatType
int main() printf("\nSize of float is:
{
%ld", sizeof(floatType));
int integerType;
char charType;
float floatType; // Calculate and Print
double doubleType; // the size of doubleType
printf("\nSize of double is:
// Calculate and Print
%ld", sizeof(doubleType));
// the size of integer type
printf("Size of int is: %ld",
sizeof(integerType)); return 0;
}
// Calculate and Print OutputSize of int is: 4 Size of
// the size of charType
char is: 1 Size of float is: 4 Size
printf("\nSize of char is: %ld",
sizeof(charType)); of double is: 8
Program to Convert Fahrenheit to
Celcius in C
// Driver code
// Fahrenheit to Celsius int main()
#include <stdio.h> {
float f = 40;

// Function to convert Degree // Passing parameter to


// Fahrenheit to Degree function
Celsius printf("Temperature in
float Degree Celsius : %0.2f",
fahrenheit_to_celsius(float f) fahrenheit_to_celsius(f
));
{ return 0;
return ((f - 32.0) * 5.0 / }
9.0); OutputTemperature in
} Degree Celsius : 4.44
C program to swap two numbers using a temporary
variable.
#include <stdio.h>
// Driver code int main()
Output
{ Enter Value of x 5
int x, y; Enter Value of y 8
printf("Enter Value of x "); After Swapping: x = 8, y = 5
scanf("%d", &x);
printf("\nEnter Value of y ");
scanf("%d", &y);
// Using a temporary variable to swap the values
// Store the value of x in a temporary variable
int temp = x;
// Assign the value of y to x
x = y;
// Assign the value stored in the temporary variable
to // y
y = temp;
printf("\nAfter Swapping: x = %d, y = %d", x, y);
return 0;
}
1) C Program to Print Your Own Name
2) C Program to Add Two Numbers
3) C Program to Check Whether a Number is
Prime or Not
4) C Program to Print the ASCII Value of a
Character
5) C Program to Print Prime Numbers From 1 to
N
6) C Program to Find Simple Interest
7) C Program for Area And Perimeter Of
Rectangle
.

Thank
You
Unit II

Operators
and
Expressions
Content
Operators and Expressions:
Arithmetic Operators, Relational Operators,
 Logical Operators, Assignment Operators,
 Increment and Decrement Operators, Conditional
Operators, Bitwise Operators,
Special Operators. Arithmetic Expressions,
Evaluation of Expressions, Precedence of Arithmetic
Operators,
Operator Precedence and Associativity, Mathematical
Functions
Operators
 Operators are symbols which take one or more operands or
expressions and perform arithmetic or logical computations.
 Operands are variables or expressions which are used in
conjunction with operators to evaluate the expression.
 Combination of operands and operators form an expression.
 Expressions are sequences of operators, operands, and
punctuators that specify a computation.
 Evaluation of expressions is based on the operators that the
expressions contain and the context in which they are used.
 Expression can result in a value and can produce side effects.
 A side effect is a change in the state of the execution
environment.
Arithmetic Operators
Example
#include<stdio.h>
int main()
{
int a=40,b=20, add,sub,mul,div,mod;
add = a+b;
sub = a-b;
mul = a*b;
div = a/b;
mod = a%b;
printf("Addition of a, b is : %dn", add);
printf("Subtraction of a, b is : %dn", sub);
printf("Multiplication of a, b is : %dn", mul);
printf("Division of a, b is : %dn", div);
printf("Modulus of a, b is : %dn", mod);
return 0;
}
Relational Operators
Example
#include<stdio.h>
int main()
{
int m=40,n=20;
if (m == n)
{
printf("m and n are equal");
}
Else
{
printf("m and n are not equal");
}
return 0;
}
Logical Operators
#include <stdio.h> .
int main()
{
int m=40,n=20;
int a=20,p=30;
if (m>n && m !=0)
{ printf("&& Operator : Both conditions are truen"); }
if (a>p || p!=20)
{ printf("|| Operator : Only one condition is truen"); }
if (!(m>n && m !=0))
{ printf("! Operator : Both conditions are truen"); }
else
{ printf("! Operator : Both conditions are true. " "But, status is
inverted as falsen"); }
return 0;
}
Assignment Operators
Example
# include<stdio.h>
int main()
{
int Total=0,i;
for(i=0;i<10;i++)
{
Total+=i; // This is same as Total = Total+i
}
printf("Total = %d", Total);
return 0;
}
Increment and Decrement Operators

Increment operators are used to increase the


value of the variable by one and decrement
operators are used to decrease the value of the
variable by one in C programs.
 Increment operator ++ var_name; (or)
var_name++;
Decrement operator - -var_name; (or)
var_name – -;
 Increment / Decrement Operators
Example of Increment Operators
#include<stdio.h>
int main()
{
int i=1;
while(i<10)
{
printf("%d ",i); i++;
}
return 0;
}
Example of Decrement Operators
#include<stdio.h>
int main()
{
int i=1;
while(i<10)
{
printf("%d ",i); i--;
}
return 0;
}
Rules for ++ & -- operators
1) These require variables as their operands
2) When postfix either ++ or – is used with the
variable in a given expression, the expression
is evaluated first and then it is incremented or
decremented by one
3) When prefix either ++ or – is used with the
variable in a given expression, it is
incremented or decremented by one first and
then the expression is evaluated with the
new value
Conditional Operators
Syntax:
 A return one value if exp1 ? exp2 : exp3
condition is true and Where exp1,exp2 and exp3 are
returns another value is expressions
condition is false Working of the ? Operator:
Exp1 is evaluated first, if it is
 This operator is also nonzero(1/true) then the expression2 is
called as ternary evaluated and this becomes the value of
operator. the expression,
 Syntax : If exp1 is false(0/zero) exp3 is evaluated
and its value becomes the value of the
 (Condition true_value: expression
false_value); Ex: m=2;
 Example :. n=3
 (A> 100 ? 0 : 1); r=(m>n) ? m : n;
Example
#include <stdio.h>
int main()
{
int x=1, y ;
y = ( x ==1 ? 2 : 0 ) ;
printf("x value is %dn", x);
printf("y value is %d", y);
return 0;
}
Bitwise Operators
 These operators are used to perform bit
operations.
 Decimal values are converted into binary values
which are the sequence of bits and bit wise
operators work on these bits.
 Following are bitwise operator
1) & Bitwise AND
2) | Bitwise OR
3) ~ Bitwise NOT
4) ^ XOR
5) << Left Shift
6) >> Right Shift
#include<stdio.h> Example
int main()
{
int m = 40,n = 80,AND_opr,OR_opr,XOR_opr,NOT_opr ;
AND_opr = (m&n);
OR_opr = (m|n);
NOT_opr = (~m);
XOR_opr = (m^n);
printf("AND_opr value = %dn",AND_opr );
printf("OR_opr value = %dn",OR_opr );
printf("NOT_opr value = %dn",NOT_opr );
printf("XOR_opr value = %dn",XOR_opr );
printf("left_shift value = %dn", m << 1);
printf("right_shift value = %dn", m >> 1);
}
Special Operators
sizeof Operator
sizeof is much used in the C programming
language.
It is a compile-time unary operator which can
be used to compute the size of its operand.
The result of sizeof is of the unsigned integral
type which is usually denoted by size_t.
Syntax
– sizeof (operand)
Special Operators
Comma Operator ( , )
The comma operator (represented by the
token) is a binary operator that evaluates its
first operand and discards the result, it then
evaluates the second operand and returns this
value (and type).
The comma operator has the lowest
precedence of any C operator.
Comma acts as both operator and separator.
Syntax
operand1 , operand2
Special Operators
Conditional Operator ( ? : )
 The conditional operator is the only ternary
operator in C++.
 Here, Expression1 is the condition to be evaluated. If
the condition(Expression1) is True then we will
execute and return the result of Expression2
otherwise if the condition(Expression1) is false then
we will execute and return the result of Expression3.
 We may replace the use of if..else statements with
conditional operators.
Syntax
operand1 ? operand2 : operand3;
Special Operators
dot (.) and arrow (->) Operators
Member operators are used to reference
individual members of classes, structures, and
unions.
The dot operator is applied to the actual object.
The arrow operator is used with a pointer to an
object.
Syntax
• structure_variable . member;
Cast Operator
.
 Casting operators convert one data type to another. For example,
int(2.2000) would return 2.
 A cast is a special operator that forces one data type to be
converted into another.
 The most general cast supported by most of the C compilers is as
follows − [ (type) expression ].
 Syntax
(new_type)operand;

addressof (&) and Dereference (*) Operators


 Pointer operator & returns the address of a variable.
For example &a; will give the actual address of the variable.
 The pointer operator * is a pointer to a variable.
For example *var; will pointer to a variable var.
• Example of Other C Operators
#include <stdio.h> int main().
{ // integer variable
int num = 10;
int* add_of_num = &num;
printf("sizeof(num) = %d bytes\n", sizeof(num));
printf("&num = %p\n", &num);
printf("*add_of_num = %d\n", *add_of_num);
printf("(10 < 5) ? 10 : 20 = %d\n", (10 < 5) ? 10 : 20);
printf("(float)num = %f\n", (float)num);
Output
return 0; sizeof(num) = 4 bytes
} &num = 0x7ffe2b7bdf8c
*add_of_num = 10 (10 < 5)
? 10 : 20 = 20
(float)num = 10.000000
Arithmetic Expressions

 Arithmetic Expressions consist of numeric literals,


arithmetic operators, and numeric variables.
 They simplify to a single value, when evaluated.
 Here is an example of an arithmetic expression
with no variables:
3.14*10*10
This expression evaluates to 314, the approximate
area of a circle with radius 10.
 Similarly, the expression 3.14*radius*radius
would also evaluate to 314, if the variable radius stored
the value 10.
Arithmetic Expressions
Unary /
Symbol Description
Binary
+ unary denotes that the number is a positive integer.
- Unary denotes that the number is a negative integer.
++ Unary Increments the value of the variable by 1
-- Unary Decreases the value of the variable by 1
performs the mathematical addition of the two given
+ Binary
operands.
performs the mathematical subtraction of the two
- Binary
given operands.
performs the mathematical multiplication of the two
* Binary
given operands.
performs the mathematical division of the two given
\ Binary
operands and returns the quotient.
performs the mathematical division of the two given
% Binary
operands and returns the remainder as the result.
Evaluation Of Arithmetic Expressions in C
Evaluation Of Arithmetic Expressions based on
BODMAS stands for Bracket, Of, Division,
Multiplication, Addition, and Subtraction.
The BODMAS is used to explain the order of
operation of a mathematical expression.
In some regions, the BODMAS is also known as
PEDMAS which stands for Parentheses,
Exponents, Division, Multiplication, Addition,
and Subtraction.
Precedence of Arithmetic Operators
 An Arithmetic expression can have more than one
arithmetic operator within it. Then how can you
determine in which order will you execute them

Precedence Order Operator

0 parenthesis ()

Unary plus (+), Unary minus (-), Increment


1
(++), Decrement (--)

2 multiplication (*), division (/), modulo (%)

3 addition (+), Subtraction (-)


Associativity of Arithmetic Operators
• The Associativity property of the C programming language, states
the direction in which the operation will be performed. Apart from
specifying the direction of the operation that has to be performed,
the ssociativity property also helps us solve the problem of which
operation to perform when two operations have the same
precedence.
Operator Associativity
Unary Plus (+) Right to Left
Unary Minus (-) Right to Left
Increment (++) Depends on the usage
Decrement (--) Depends on the usage
Addition (+) Left to Right
Subtraction (-) Left to Right
Multiplication (*) Left to Right
Division (/) Left to Right
Modulo (%) Left to Right
Ws…

Result= (4*5)+(9+6)-8
Result= 20+15-8
Result= 35-8
Result= 27
Program for Arithmetical Expression
#include <stdio.h>
int main()
{
int x = 5, y = 10;
if (x == y)
{ printf("x is equal to y\n"); }
Else
{ printf("x is not equal to y\n"); }
return 0;
}
Program for Arithmetical Expression

#include <stdio.h>
int main()
{
int a = 5;
printf("%d", -++a*2);
return 0;
}
Output= -12
Mathematical Functions
1. Add: sum = a + b
This function calculates the sum of two numbers.
Note: This function does not require the <math.h> header.
Example:
#include <stdio.h>
int main() {
int num1 = 10;
int num2 = 5;
int sum = num1 + num2;
printf("Addition: %d + %d = %d\n", num1, num2, sum);
return 0;
}
Output:
Addition: 10 + 5 = 15
2. Subtract: subtraction = a - b
.
This function subtracts one number from another. Note: This function
does not require the <math.h> header.
Example:
#include <stdio.h>
int main() {
int num1 = 10;
int num2 = 5;
int difference = num1 - num2;
printf("Subtraction: %d - %d = %d\n", num1, num2, difference);
return 0;
}
Output:
Subtraction: 10 - 5 = 5
EXAMPALE :
1) Write a program for Multiplication using math function
2) Write a program for Division using math function
Power: pow()
This function raises a number to a specified power.
Example:
#include <stdio.h>
#include <math.h>
int main() {
double base = 2.0;
double exponent = 3.0;
double result = pow(base, exponent);
print(power:%2lf^%.2lf=%.2lf/n”, base, exponent, results ):
return 0;
}
Output:
Power: 2.00^3.00 = 8.00
Round Up: ceil()
This function rounds a floating-point number up to the
nearest integer.
Example:
#include <stdio.h>
#include <math.h>
int main() {
double num = 4.3;
double ceilResult = ceil(num);
printf("Ceiling: %.2lf rounded up to the nearest
integer is %.2lf\n", num, ceilResult);
return 0;
}
Output:
Ceiling: 4.30 rounded up to the nearest integer is 5.00
• Some other math function
.
1. Round Down: floor(): This function rounds a floating-point
number down to the nearest integer
2. Tangent: tan():This function calculates the tangent of an
angle.
3. Tangent: tan(): This function calculates the tangent of an
angle
4. Square Root: To find the square root of a number, use
the sqrt() function: Example printf("%f", sqrt(16));
5. ceil(number) rounds up the given number. It returns the
integer value which is greater than or equal to given
number.
6. floor(number)rounds down the given number. It returns the
integer value which is less than or equal to given number.
7. abs(number)returns the absolute value of given number.
Program
1) Write a program for integer arithmetic to convert a given number
of days into month and days.
2) C Program to Check Whether a Number is Positive, Negative, or
Zero
3) C Program to Check Whether Number is Even or Odd
4) C Program to Check Whether a Character is Vowel or
Consonant
5) C Program to Find Largest Number Among Three Numbers
6) C Program to Calculate Sum of Natural Numbers
7) C Program to Check Leap Year
8) C Program to Find Factorial of a Number
9) C Program to Print Fibonacci Series
10) C Program to Check Armstrong Number
11) C Program to Reverse a Number
12) C Program to Check Whether a Number is a Palindrome or Not
13) C Program to Check Whether a Number is Prime or Not
Thank
You

You might also like