What will be the output of the following C code if the value of ‘p’ is 10 and that of ‘q’ is 15? [code]#include<stdio.h> int main() {

Tam ca

New member
What will be the output of the following C code if the value of ‘p’ is 10 and that of ‘q’ is 15?
Code:
#include<stdio.h>
int main()
{
    int p,q;
    printf("Enter two numbers\n");
    scanf("%d",&p);
    scanf("%d",&q);
    #if(4<2)
    printf("%d",p);
    #elif(2>-1)
    printf("%d",q);
    #else
    printf("bye");
    #endif
}
A. 10
B. 15
C. bye
D. error
 
Answer: b
Explanation: The output of the code shown above is 15. The values given for ‘p’ and ‘q’ are 10 and 15 respectively. Since the condition given for #elif is true, the value stored in ‘q’ will be printed, that is 15.
 

Tìm kiếm

Back
Top