C Programming - Structures, Unions, Enums - Discussion

Discussion Forum : Structures, Unions, Enums - Find Output of Program (Q.No. 12)
12.
What will be the output of the program ?
#include<stdio.h>

    struct course
    {
        int courseno;
        char coursename[25];
    };
int main()
{
    struct course c[] = { {102, "Java"}, 
                          {103, "PHP"}, 
                          {104, "DotNet"}     };

    printf("%d ", c[1].courseno);
    printf("%s\n", (*(c+2)).coursename);
    return 0;
}
103 DotNet
102 Java
103 PHP
104 DotNet
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
18 comments Page 2 of 2.

Ramakant Mishra said:   10 years ago
*c is initially point to c[0]. So, *(c+2) is now pointing at c[2].

Jitu Rahangdale said:   1 decade ago
Ok, pravin said is right. I agree with him.

Iram said:   1 decade ago
Anyone can explain in detail.

Satyaprakash said:   1 decade ago
Thank you for Apurva Nigam.

Sravanthi Emmadi said:   1 decade ago
Thank you Apurva.

Shabnam said:   8 years ago
Thank you @Safi.

Sivaram said:   1 decade ago
Thanks praveen.

Sivasankari said:   8 years ago
Thank you all.


Post your comments here:

Your comments will be displayed after verification.