The document discusses various aspects of functions in C programming including passing values to functions, returning values from functions, and more advanced features like returning non-integer values, call by value/reference, and recursion. It provides examples of defining and calling functions, passing arguments, returning single and multiple values, and illustrates proper and improper usage of functions.
LCS: The longest common place or the sequential sequence in each sequential sequence is a sequence that appears in the same order, but not necessarily continuously.
Fractional Knapsack: Given the weight and value of the n items, these items need to place the bag at the maximum opportunity W sum value to enter the bag.
0-1 on the knapsack problem that can not be allowed to break items. Are all items taken or taken away
LCS: The longest common place or the sequential sequence in each sequential sequence is a sequence that appears in the same order, but not necessarily continuously.
Fractional Knapsack: Given the weight and value of the n items, these items need to place the bag at the maximum opportunity W sum value to enter the bag.
0-1 on the knapsack problem that can not be allowed to break items. Are all items taken or taken away
List build linked in - jigsaw - salesforce - free toolsRWolfrum
Build a master list you can use for the rest of your sales career leveraging free and almost free services like: JigSaw , Data.com , $2 / Mo. Salesforce.com . Turn paid services into free services using this strategy.
Presentation Ukay Metal Ind.Pvt.Ltd.-Ashok 7-2015Ashok Chandak
Ukay Metal Industries.Pvt.Ltd.,Nashik,INDIA manufactures Liquid Molding Resin parts(LMR), NVH products ( floor carpets, floor mats, noise insulations, firewalls, bonnet insulation, dash mat etc), Plastic molded parts, Interior parts, door trims, Head Liners, PU Foam Seat cushions, Head rest assembly, Sun Visors, Integral Skin PU foam moulded parts , Automobile Soft Trims such as seat covers and precision machined parts for passenger cars, SUV, MPV, Light duty trucks, Medium duty trucks and Heavy duty trucks -Trucks , Tractors, construction and off road vehicles.. We are an ISO/TS 16949-2002, ISO 14001 and OHSAS 18001 certified company.
Ukay Metal Industries Pvt. Ltd. , Nashik, India is an OEM supplier and manufacturer of Automotive Parts such as NVH parts, Floor Carpets, PU foam Seats pad, head rest, Injection Moulded Parts, Upholstery,Machined precision parts, painted parts, Vacuum Formed parts etc.
Ukay Metal Ind.Pvt.Ltd. India- manufactures Liquid Molding Resin parts(LMR), NVH products ( floor carpets, floor mats, noise insulations, firewalls, bonnet insulation, dash mat etc), Plastic molded parts, Interior parts, door trims, Head Liners, PU Foam Seat cushions, Head rest assembly, Sun Visors, Integral Skin PU foam moulded parts , Automobile Soft Trims such as seat covers and precision machined parts for passenger cars, SUV, MPV, Light duty trucks, Medium duty trucks and Heavy duty trucks -Trucks , Tractors, construction and off road vehicles.. We are an ISO/TS 16949-2002, ISO 14001 and OHSAS 18001 certified company.
Ukay metal company profile.
Ukay is an automotive parts manufacturer making NVH parts-such as insulators, carpets, PU foam Seats, Injection moulded parts- such as console assy., trims, door trims etc.
It is supported by in house Tool shop and design .
Upload on RIM process,it is very useful substitute for parts molded on 1200 Tonnes injection molding and above .It is economical, mold cost is low comaored to Injection Molding.More strength in part.
C program to find factorial of number using recursion as well as iteration ,
Calculate power of a number program in c using Recursion and Iteration, Write a C program to count digits of a number using Recursion and Iteration, Write a C program to find sum of first n natural numbers using Recursion, C program to print sum of digits of a given number using recursion ,Write a C program to find nth term in Fibonacci Series using Recursion, C program to find out the GCD (Greatest Common Divisor )of the two numbers using recursion,
Write a C program to find the first upper case letter in the given string using recursion, write C program to calculate length of the string using Recursion ,
Write a program in C to count number of divisors of a given number using recursion, Recursive program to check whether a given number is prime or composite,
C program to displays integers 100 through 1 using Recursion and Iteration, Write a program in C to convert a decimal number to binary using recursion,
Recursion Stack of factorial of 3 Recursion stack of 4th term of Fibonacci
1. Break From The Outermost Loop
main( )
{
for ( i = 1 ; i <= 22 ; i+= 2 )
{
for ( j = 5 ; j <= 50 ; j++ )
{
for ( k = 1 ; k <= 9 ; k += 3 )
{
… …
if ( i + j % k >= 2 )
break ;
}
}
}
}
break ;
break ;
Go to work
only once
if ( i + j % k >= 2 )
if ( i + j % k >= 2 )
break ;
break ;
2. main( )
{
for ( i = 1 ; i <= 22 ; i+= 2 )
{
for ( j = 5 ; j <= 50 ; j++ )
{
for ( k = 1 ; k <= 9 ; k += 3 )
{
… …
if ( i + j % k >= 2 )
goto out ;
}
}
}
}
Better Way...
out :
;
Never use
a goto
3. main( )
{
in :
goto there ;
for ( i = 1 ; i <= 22 ; i+= 2 )
{
for ( j = 5 ; j <= 50 ; j++ )
{
there :
for ( k = 1 ; k <= 9 ; k += 3 )
{
… …
if ( i + j % k >= 2 )
} goto out ;
}
}
}
Where Am I...
out :
goto in ;
5. Communication
main( )
{
int a = 10, b = 20, c = 30 ;
calsum ( ) ;
printf ( ”%d”, s ) ;
}
calsum( )
{
int a, b, c, s ;
}
int s ;
s = a + b + c ;
printf ( ”%d”, s ) ;
Garbage
Garbage
6. Passing Values
main( )
{
Actual
Arguments
int a = 10, b = 20, c = 30 ; int s ;
calsum ( a, b, c
) ;
printf ( ”%d”, s ) ;
}
calsum ( )
{
int s ;
}
int x, int y, int z
s = x + y + z ;
printf ( ”%d”, s ) ;
Garbage
Formal
Arguments
60
7. main( )
{
Returning Values
int a = 10, b = 20, c = 30, s ;
calsum ( a, b, c ) ;
}
calsum ( int x, int y, int z )
{
int ss ;
ss = x + y + z ;
return ( ss ) ;
}
s = calsum ( a, b, c ) ;
printf ( ”%d”, s ) ;
60
return ; Returns only
return ; Returns only
control
control
Return control
and value
Return control
and value
return ( ss ) ;
return ( 60 ) ;
return ( x + y + z ) ;
8. Are These Calls OK?
calsum ( a, 25, d ) ;
calsum ( 10 + 2, 25 % 3, d ) ;
calsum ( a, calsum ( 25, 10, 4 ), d ) ;
d = calsum ( a, 25, d ) * calsum ( a, 25, d ) + 23 ;
calsum ( int x, int y, int z )
{
int ss ;
ss = x + y + z ;
return ( ss ) ;
}
Nested calls are legal.
Call within an expression are legal.
Nested calls are legal.
Call within an expression are legal.
9. Returning More Than 1 Value
main( )
{
int a = 10, b = 20, c = 30 ;
ssu, mp p=r soudm ( par, obd, c ( )a ;, b , c ) ;
printf ( ”%d%d”, s, p ) ;
}
sumprod ( i n t x , i n t y , i n t z )
ss = x + y + z ;
pp = x * y * z ;
{
int ss, pp ;
return ( ss, pp ) ;
}
int s, p ;
A function can return only
1 value at a time
10. main( )
{
One More Try
int a = 10, b = 20, c = 30 ;
int s, p ;
s = sumprod ( a, b, c ) ;
p = sumprod ( a, b, c ) ;
printf ( ”%d%d”, s, p ) ;
} sumprod ( int x, int y, int z )
{
ss = x + y + z ;
pp = x * y * z ;
return ( ss ) ;
return ( pp ) ;
}
int ss, pp ;
60 60
Redundant
11. main( )
{
The Only Way Out
int a = 10, b = 20, c = 30 ; int s, p ;
s = sumprod ( a, b, c ) ;
p = sumprod ( a, b, c ) ;
printf ( ”%d%d”, s, p ) ;
}
, 1
, 2
sumprod ( int x, int y, int z, )
{
int ss, pp ;
ss = x + y + z ; pp = x * y * z ;
}
int code
if ( code == 1 )
return ( ss ) ;
else
return ( pp ) ;
Sum, Product,
Average, Variance
Standard Deviation
12. A Better Way
sumprod ( int x, int y, int z, int code )
{
int ss, pp ;
ss = x + y + z ;
pp = x * y * z ;
}
if ( code == 1 )
return ( ss ) ;
else
return ( pp ) ;
code == 1 ? return ( x + y + z ) : return ( x * y * z ) ;
return ( code == 1 ? x + y + z : x * y * z ) ;
13. ANSI V/s K R
calsum ( int x, int y, int z )
{
..
}
calsum ( int x, int y, int z )
{
..
}
calsum ( x, y, z )
int x, y, z ;
{
..
}
calsum ( x, y, z )
int x, y, z ;
{
..
}
ANSI
Kernighan
Ritchie
14. main( )
{
int y ;
printf ( ”Enter year” ) ;
scanf ( ”%d”, y ) ;
romanize ( y ) ;
}
romanize ( int yy )
{
int n, i ;
n = yy / 1000 ;
for ( i = 1 ; i = n ; i ++ )
printf ( ”m” ) ;
Decimal Roman
1000 m
500 d
100 c
50 l
10 x
5 v
1 i
}
Roman Equivalent
1998 m d c c c c l x x x x i i i
1998
v
15. A More General Call
main( )
{
int y ;
printf ( ”Enter year” ) ;
scanf ( ”%d”, y ) ;
, 1000 , ’m’
y romanize = romanise ( y ( y, 1000, ’) m’ ;
) ;
}
romanize ( int yy , int j , char ch
)
{
int n, i ;
n = yy / j ;
for ( i = 1 ; i = n ; i ++ )
printf ( ) ;
}
”%c”, ch
return ( yy % j ) ;
16. main( )
{
...
1998 md c c c c lx xx x v i ii
, ’m’
y = romanise ( y, 1000 ) ;
y = romanise ( y, 500, ’d’ ) ;
y = romanise ( y, 100, ’c’ ) ;
y = romanise ( y, 50, ’l’ ) ;
y = romanise ( y, 10, ’x’ ) ;
y = romanise ( y, 5, ’v’ ) ;
romanise ( y, 1, ’i’ ) ;
}
romanize ( int yy )
{
}
, int j, char ch
int n, i ;
n = yy / j ;
for ( i = 1 ; i = n ; i ++ )
printf ( ”%c”, ch ) ;
return ( yy % j ) ;
Works
17. Advanced Features of
Functions
Returning a non-integer value
Call by value / Call by reference
Recursion
18. Returning a Non-Integer Value
main( )
{
a = square ( 2.0 ) ;
b = square ( 2.5 ) ;
c = square ( 1.5 ) ;
printf ( ” %f %f %f ”, a, b, c, ) ;
square ( 2.0 ) ;
} square ( ) float x
{
float y ;
y = x * x ;
printf ( ” %f ”, y ) ;
return ( y ) ;
}
Function
Prototype
4.0 6.0 2.0
float a, b, c ; float square ( float ) ;
4.0
6.25
2.25
float square ( float x )