162 views
0 votes
0 votes
1)Please correct me if anything written in comment //  is wrong 
2) also tell me why why did ABC getdata()and ABC & getdata() both are true as return type
#include<stdio.h>
struct ABC
{
	int x;
	ABC getdata()//ABC & getdata() is also true
	{
        ABC *obj;
	obj->x=10;
	return *obj;//same as returning in normal_variable()
         }

	
};
//because NV is int so return type is int
int  normal_variable(int *p)//int & normal_variable is also true
{
    (*p)++;
    return *p;//because NV is variable so NV=*p
}
//as NVP is int* so return type is int*
int * variable_pointer(int *p)
{
	(*p)++;
	return p;//NVP=p
}
int main()
{
    int x=5;
    int NV;
    int *NVP;
    NV = normal_variable(&x);
    printf("%d\n",NV);
    x=5;
    NVP=variable_pointer(&x);
    printf("%d\n",*NVP);
    x=5;
    *NVP=normal_variable(&x);
    printf("%d\n",*NVP);
    ABC obj,obj1;
    obj1=obj.getdata();
    printf("%d\n",obj1.x);
}

Output:-6
6
6
10
[Finished in 0.1s]  

Please log in or register to answer this question.

Related questions

1 votes
1 votes
1 answer
1
jugnu1337 asked May 10, 2022
289 views
SOURCE NAME::: UNDERSTANDING POINTER IN C (BOOK) BY YASHWANT KANETKARmy answer is C am i right?
1 votes
1 votes
0 answers
2
aakash pandey asked Apr 30, 2022
292 views
We use character array to declare string in C. So, if I declare an array likecharacter ch[ ] = {‘a’,’k’,’a’,’/o’};and try printing ch[3] like :printf(“%...
0 votes
0 votes
0 answers
3
Anirudh Kaushal asked Apr 6, 2022
202 views
#include<stdio.h struct marks { int p:3; int c:3; int m:2; }; void main() { struct marks s = {2, -6, 5}; printf("%d %d %d", s.p, s.c, s.m); }What does p:3 means here ?
0 votes
0 votes
0 answers
4