Your SlideShare is downloading. ×
lets play with "c"..!!! :):)
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

lets play with "c"..!!! :):)

549
views

Published on

hey this is Rupendra choudhary..!! i shared my "c" lang ppt..!!! u just goto that ppt if u r in deep with "c" ..!!! i create after i hv played a much with "c"..(sorry bt ppt is slightly disturbd may …

hey this is Rupendra choudhary..!! i shared my "c" lang ppt..!!! u just goto that ppt if u r in deep with "c" ..!!! i create after i hv played a much with "c"..(sorry bt ppt is slightly disturbd may be due to unsupportable msppt2010 by slideshare)...find me on rupendrachoudhary1990@gmail.com or https://rupendrachoudhary.wordpress.com

Published in: Education, Technology, Business

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
549
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
22
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Presented By:- RUPENDRA CHOUDHARY B.Tech.- 2 nd YEAR (CSE) E.C.B. ,BIKANER FUNCTION IN ‘C’
  • 2. A function is a block of code that perform special task of some kind. WHAT IS FUNCTION?
  • 3. WHY WE USE FUNCTION?
    • main()
    • {
    • int i;
    • printf(“computer science n”);
    • for(i=0;i<20;i++)
    • {
    • printf(“*”);
    • }
    • printf(“n engineering hobby n”);
    • for(i=0;i<10;i++)
    • {
    • printf(“#”);
    • }
    • }
  • 4. C:function.c
    • void function(int x,char y)
    • {
    • int i;
    • for(i=0;i<x;i++)
    • {
    • printf(“%c”,y);
    • }
    • }
  • 5.
    • #include<c:function.c>
    • void main()
    • {
    • int i;
    • printf(“computer science’s runner n”);
    • function(20,’*’);
    • printf(“engineering is hobby n”);
    • function(10,’#’);
    • }
  • 6. PARTS OF FUNCTION
    • 1)-Declaration
    • 2)-Calling
    • 3)-Definition
  • 7. DESCRIPTION
    • int sum(int,int);
    • void main()
    • {
    • int a,b,add;
    • scanf(“%d%d”,&a,&b);
    • add=sum(a,b);
    • printf(“add is %d”,add);
    • }
    • int sum(int x,int y)
    • {
    • return x+y;
    • }
  • 8. FUNCTION TYPES
    • 1)-No argument & No return value
    • 2)-No argument & Having return value
    • 3)-Having argument & No return value
    • 4)-Having argument & Return value
    • 5)-Recursive function
  • 9. ILLUSTRATIONS
    • 1)-What will be output?
    • void main()
    • {
    • int i=3,r;
    • r=sizeof f(++i)+f(--i)+f(i-2);
    • printf(“%d%d”,r,i);
    • }
    • int f(int j)
    • {
    • if(!!j)
    • return ++j;
    • else
    • return --j;
    • }
  • 10. 2)-What will be output?
    • main()
    • {
    • int a=5,b;
    • {
    • int b=10;
    • ++b;
    • ++a;
    • printf(“%d%dn”,a,b);
    • {
    • int a=20;
    • ++a;
    • a=++b;
    • printf(“%d%dn”,a,b);
    • }
    • ++a;
    • ++b;
    • Printf(“%d%dn”,a,b);
    • }
    • Printf(“%d%dn”,a,b);
    • }
  • 11. 3)-What will be output ?
    • func(int i)
    • {
    • if(i%2)
    • return 0;
    • else
    • return 1;
    • }
    • main()
    • {
    • int i=1;
    • i=func(i);
    • i=func(i);
    • printf(“%d”,i);
    • }
  • 12. 4)- What will be output?
    • int max(int x,int y)
    • {
    • return x>y?x:y;
    • }
    • void main()
    • {
    • int m;
    • m=max(max(4,max(11,6)),max(10,5));
    • printf(“%d”,m);
    • }
  • 13. 5) -What will be output?
    • int *fun();
    • void main()
    • {
    • int *j;
    • j=fun();
    • printf(“%d”,*j);
    • }
    • int *fun()
    • {
    • int k=35;
    • return &k;
    • }
  • 14. 6)-what will be output?
    • void increment();
    • void main()
    • {
    • increment();
    • increment();
    • }
    • void increment()
    • {
    • auto int i=1;
    • printf(“%d”,i);
    • printf(“%d”,&i);
    • }
  • 15. 7)-Will error occur?
    • void display();
    • void main()
    • {
    • goto label;
    • printf(“ecb alumni”);
    • }
    • void display()
    • {
    • label:
    • printf(“computer science”);
    • }
  • 16. Concept of return value
    • void swap(int,int);
    • void main()
    • {
    • int a=1,b=2;
    • swap(a,b);
    • printf(“%d%d”,a,b);
    • }
    • void swap(int x,int y)
    • {
    • int t;
    • t=x;
    • x=y;
    • y=t;
    • printf(“%d%d”,x,y);
    • }
    • void swap(int*,int*);
    • void main()
    • {
    • int a=1,b=2;
    • swap(&a,&b);
    • printf(“%d%d”,a,b);
    • }
    • void swap(int *x,int *y)
    • {
    • int t;
    • t=*x;
    • *x=*y;
    • *y=t;
    • }
  • 17. Recursive function is a function which contains a call to itself RECURSIVE FUNCTION
  • 18. 8)-What will be output?
    • /* Based on stack */
    • void main()
    • {
    • int a=1,b=2,c=3,d;
    • printf(“%d%d%d%d”);
    • }
  • 19. DESCRIPTION
    • int fact(int);
    • void main()
    • {
    • int a=4;
    • result=fact(a);
    • printf(“factorial vauue is=%d”,result);
    • }
    • int fact(int x)
    • {
    • if(x==1)
    • return 1;
    • else
    • return x*fact(x-1);
    • }
  • 20. 9)-Will error occur?
    • void main()
    • {
    • int n;
    • scanf(“%d”,n);
    • printf(“%d”,fac());
    • }
    • int fac(int n)
    • {
    • if(x==0)
    • return 1;
    • else
    • return n*fac(n-1);
    • }
  • 21. 10)-What will be output?
    • int i=1;
    • void main()
    • {
    • if(i<=3)
    • {
    • i++;
    • main();
    • }
    • printf(“%d%d%d”,i,++i,i++);
    • }
  • 22. RECURSION V/S ITERATION
    • Recursive solution is always logical and it is very difficult to trace.
    • Recursion takes a lot of stack space.
    • Recursive calling increase the space complexity.
    • A recursive definition defines an object in simpler cases of itself reducing nested looping complexity.
    • Every recursive problem can be done by iteration but vice versa is not always true.
  • 23. THANKS ANY QUERY….?