fork download
  1. #include<stdio.h>
  2.  
  3. ///Q-1: how many ways variables can be initialized?
  4. ///Q-2: how many places variables can be used?
  5.  
  6. int number2 = 105; //global variable
  7. int number1 = 111;
  8. ///float number1; --> wrong, variable cannot be duplicated
  9. float ff;
  10. double d;
  11.  
  12. int main()
  13. {
  14. int number1 = 101; //local variable
  15. float sal,val,ans;
  16.  
  17. /// if local and global variable has same name
  18. /// local variable will get the priority first
  19. printf("number 1 is = %d\n", number1);
  20. printf("number 2 is = %d\n", number2);
  21.  
  22. }
Success #stdin #stdout 0s 5280KB
stdin
Standard input is empty
stdout
number 1 is = 101
number 2 is = 105