Computer Science, asked by ashutoshtripathi034, 4 months ago

Find the output of the following C code?
#include <stdio.h>
int maino
{
int a=23;
i
printf("%d",a);
return 0;
}
O a. 23
O b. 23;
O C.;23;
0-d. error​

Answers

Answered by nehashanbhag0729
0

Question

  • Find the output of the following C code?

Answer

  • 0-d. error
Answered by mrajwade823
1

programs.

Question 1

c

#include<stdio.h>

char *getString()

{

char str[] = "Will I be printed?";

return str;

}

int main()

{

printf("%s", getString());

getchar();

}

Output: Some garbage value

The above program doesn’t work because array variables are stored in Stack Section. So, when getString returns values at str are deleted and str becomes dangling pointer.

Question 2

C

#include<stdio.h>

int main()

{

static int i=5;

if(--i){

main();

printf("%d ",i);

}

}

Output

0 0 0 0

Explanation: Since i is a static variable and is stored in Data Section, all calls to main share same i.

Question 3

c

#include<stdio.h>

int main()

{

static int var = 5;

printf("%d ",var--);

if(var)

main();

}

Output

follow me and one like plz

Similar questions