P1 P2 P3 #include <stdio.h>
int a=5;
int main(){
int a=7;
return(0);
}#include <stdio.h>
int main(){
int a=5;
int a=7;
return(0);
}#include <stdio.h>
int main(){
int a=5;
float a=7;
return(0);
}
Which one of the following statements is true?
This question asks to identify which of the three given C programs (P1, P2, P3) will compile successfully without errors. We need to analyze the variable declarations and scope rules in each program.
Program P1:
$#include <stdio.h>
int a=5; // Global variable 'a'
int main(){
int a=7; // Local variable 'a'
return(0);
}
$
Program P2:
$#include <stdio.h>
int main(){
int a=5;
int a=7; // Error: Redefinition of 'a'
return(0);
}
$
Program P3:
$#include <stdio.h>
int main(){
int a=5;
float a=7; // Error: Redefinition of 'a'
return(0);
}
$
Based on the analysis:
Thus, only P1 will compile without any error.
Which among the following is a valid string function?
A function which calls itself is called a
Which of the following function sets first n characters of a string to a given character?
Which of the following statement provides an easy way to dispatch execution to different parts of code based on the value of the expression?
Which of the following operators has left to right associativity?