Scope of variable
Upcoming SlideShare
Loading in...5
×
 

 

Statistics

Views

Total Views
122
Views on SlideShare
122
Embed Views
0

Actions

Likes
0
Downloads
3
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Scope of variable Scope of variable Presentation Transcript

  • Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring Partner Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
  • Week Target Achieved 1 30 23 2 3 Typing Speed
  • Jobs Applied Week Company Designation Applied Date Current Status 1 2 3
  • WELCOME
  • Muhammed Ajmal IK ajuik2008@gmail.com www.facebook.com/username twitter.com/username in.linkedin.com/in/profilename 9745020951 Scope Of Variable
  • Overview  Variable  Scope Of Variable  Global Variable  Local Variable  Program
  • Variable • Element of the Programing Language. • Hold data temporary. • Value Lost as soon as program terminate • Declaration: data type variable name;
  • Scope of Variables • Scope refers to the visibility of variables. • Two types Local Global
  • Global Variables • Declared out side of all Function. • Every part of program can access. • Many functions use the same data.
  • Example • Example: #include <stdio.h> int count; /* count is global */ void func1(void); void func2(void); main(void) { count = 100; func1(); }
  • void func1(void) { printf("count is %d", count); } void func2(void) { for(count=0; count<10; count++) printf("count is %d", count); } Example contd..
  • Local Variables • Declared inside a function or Block. • Scope restricted. • Scope begun by an opening brace and ends with its closing brace.
  • Example #include <stdio.h> void func1(void); void func2(void); main() { int count; /* count is global */ count = 100; func1(); }
  • Example cont. void func1(void) { Int count; printf("count is %d", count); } void func2(void) { for(count=0; count<10; count++) //error printf("count is %d", count); }
  • Example combination int g = 20; funcn() { Int g=30; //print 30 Printf(“%d”,g); } int main () { Printf(“%d”,g); //print 20 }
  • Factorial Of a Number #include<stdio.h> int Factorial(int n) { int fact=1; if(n==1) return 1; else return fact=n*Factorial(n-1); }
  • Factorial contd.. main() { int n,f; printf("enter Number to find factorial: "); scanf("%d",&n); f=Factorial(n); printf("factorial of %d: %d",n,f); }
  • Return 3*2 i.e 6 • N=5 • 5*Factorial(4); • 4*Factorial(3); • 3*Factorial(2); • 2*Factorial(1); • Return 1 Return 4*6 i.e 24 Return 2*1 i.e 2 Return 5*24 i.e 120 Factorial of 5 :120
  • Thank you
  • If this presentation helped you, please visit our page facebook.com/baabtra and like it. Thanks in advance. www.baabtra.com | www.massbaab.com |www.baabte.com
  • Contact Us Emarald Mall (Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Start up Village Eranakulam, Kerala, India. Email: info@baabtra.com IKK Road, East Hill, Kozhikode Kerala, India. Ph: + 91 – 495 30 63 624 NIT-TBI, NIT Campus, Kozhikode, Kerala, India.
  • In C++ Int main() { Private: Protected: Public: }
  • In java Int main() { Default: Private: Protected: Public: }