Your SlideShare is downloading. ×
  • Like
scope of variables
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply
Published

 

Published in Technology , Travel , Business
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
107
On SlideShare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
9
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. 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
  • 2. Week Target Achieved 1 30 25 2 3 Typing Speed
  • 3. Jobs Applied Week Company Designation Applied Date Current Status 1 2 3
  • 4. WELCOME
  • 5. Scope of variables Midhun sudhakar midhusudhakaran@gmail.c om Midhun.sudhakar.73@face book.com twitter.com/username in.linkedin.com/in/profilen ame
  • 6. Content • Variables • Scope • Types of scopes
  • 7. What is a variable? • A storage location and an associated symbolic name. • Contain some quantity of info, a value. • Variable name is the usual way to reference the stored value. • Its value may change during execution.
  • 8. What is its scope? • It refers visibility of variables. • In other words, which parts of your program can see or use it.
  • 9. Types of scope • Global scope. • Local scope.
  • 10. Global variables • Declared outside all functions. • Every part of your program can access.
  • 11. example #include<stdio.h> int a, b,answer; // Global variables int main() { a = 5; b = 7; ` answer=a+b; printf("%dn",answer); }
  • 12. Local variable • a variable that is declared inside a function. • limit a variable's scope to a single function. • changes inside the function can't affect the main program.
  • 13. example #include<stdio.h> int main() { int a, b,answer; // locall variables a = 5; b = 7; printf("%dn",answer); }
  • 14. example • Example program using global and local variables: #include<stdio.h> // Global variables int a; int b; int Add() { return a + b; } int main() { int answer; // Local variable a = 5; b = 7; answer = Add(); printf("%dn",answer); return 0; }
  • 15. When trying access a local variable outside the function? • It will leads to syntax error. Example: #include<stdio.h> int Add() { return a + b; } int main() { int a,b,answer; // Local variable a = 5; b = 7; answer = Add(); printf("%dn",answer); return 0; }
  • 16. Initializing Local and Global Variables when you define them as follows: Local variable Global variables • must be initialized by the programmer. • initialized automatically by the system. Data Type Initial Default Value int 0 char '0' float 0 double 0 pointer NULL
  • 17. THANK YOU
  • 18. 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
  • 19. 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.