can we declare a variable in different scopes with different
data types? answer in detail
Answers were Sorted based on User's Feedback
Answer / rajasekhar
yes we can declare the same variable with different data types in different scopes...
y bcoz as the scope ends the availability of that particular variable also ends..
so, if u create a variable which is declared in the another scope there will be no error...
ex: void main()
{
int a;
}/*the availability of a has ended here*/
int print()
{
char a;
return 0;
}/* as this is next scope, the variabla declared in the main function does not affect this function*/
hope u understood
thank u
| Is This Answer Correct ? | 7 Yes | 0 No |
Answer / tatukula
Yes,
why because that variable scope is ends with in that block only...
int main()
{
int a=20;
printf("%d\n",a);
{
char a='c';
printf("%c\n",a);
}
printf("%d\n",a);
}
output: 20 c 20
| Is This Answer Correct ? | 0 Yes | 0 No |
ya we can declare, ex: int array b[],
char array c[]
| Is This Answer Correct ? | 1 Yes | 3 No |
What is the difference between text and binary modes?
what is the other ways to find a logic to print whether a number is an even or odd wit out using % symbol??????? i know three different ways to print it. so i need any other different logic>>>>>
When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd
What is a C array and illustrate the how is it different from a list.
What is function definition in c?
Why we use stdio h in c?
What are the uses of pre-processor directives?
What is the difference between typedef and #define?
Whether there can be main inside another main?If so how does it work?
List at least 10 sorting methods indicating their average case complexity, worst case complexity and best case complexity.
What are the uses of null pointers?
i want to make a program in which we use input having four digits(4321) and get output its reciprocal(1234).