752 views
1 1 vote
Which of the following is TRUE?
A Scope of static variable is within the body of function where it is declared.

B Same variable can be declared multiple times within the same function only if it is extern storage class.

C Malloc always returns base address of block of memory allocated.

D None of the above

This is a multiple select question

1 Answer

2 2 votes

Correct Answer is A & C 

A. "Scope of static variable is within the body of the function where it is declared."

  • This statement is TRUE. The scope of a static variable is limited to the function or block in which it is declared.

B. "Same variable can be declared multiple times within the same function only if it is extern storage class."

  • This statement is FALSE. Regardless of the storage class (including extern), redeclaring the same variable within the same function would result in a compilation error. Redeclaring a variable within the same scope is not allowed in C.

C. "Malloc always returns the base address of the block of memory allocated."

  • This statement is TRUE. The malloc function in C returns a pointer to the base address of the dynamically allocated memory block..

Therefore, the TRUE statements are A and C.

Position:
Show:

Related questions

0 0 votes
1 1 answer
546
546 views
Overflow04 asked Jan 24, 2023
546 views
Someone please explain. Function of ‘^’
0 0 votes
2 answers 2 answers
815
815 views
Overflow04 asked Oct 2, 2022
815 views
#include <stdio.h int main(){ int a[] = {5,3,7,2,4}; int *p = &a[3]; p -= *p; printf("%d ",*p); return 0; } output is 3.Why 2 * sizeof(int) is doene.?
4 4 votes
3 answers 3 answers
1.8k
1.8k views
srestha asked May 20, 2019
1,803 views
#include<stdio.h #include<iostream int bar(int m, int n){ if(m==0)return n; if(n==0)return m; return bar(n%m,m); } int foo(int m,int n){ return(m*n/bar(m,n)); } int main(...
2 2 votes
1 1 answer
1.8k
1.8k views
srestha asked May 19, 2019
1,786 views
Consider the following $C$ implementation which when given $3$ numbers a,b,c as input, find the maximum of $3$ numbers $a,b,c.$int kickstart(int a,int b,int c) { if(B1) r...