256 views
1 votes
1 votes
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

1 votes
1 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.

Related questions

286
views
1 answers
0 votes
Overflow04 asked Jan 24, 2023
286 views
Someone please explain. Function of ‘^’
407
views
2 answers
0 votes
Overflow04 asked Oct 2, 2022
407 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.?
1.1k
views
3 answers
4 votes
srestha asked May 20, 2019
1,061 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* ... { int x=foo(1000,1500); printf("%d",x); return 0; }Output of the program is ___________
1.1k
views
1 answers
2 votes
srestha asked May 19, 2019
1,063 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) return a ... $I) and II)$ or $I) and IV)$