Can anyone clear this doubt..??

First C compiler program compiled on which compiler..???

void main()
{
int x=4,i;
i=fun(x=x/4);
printf("%d",i);
}
int fun(int c)
{
return c/2;
}

the answer is 1...how??please reply ....

that prog doesn't give output 1. definitely output will be 0 only. because fun returns 1/2 i.e 0.5 but fun return type is int so fun returns 0 only.. check ur code once again

#include<iostream.h>
#include<conio.h>
int &maxref(int &a, int &b)
{
if (a>b)
return a;
else
return b;
}
void main()
{
int x=20,y=30, max=0;
clrscr();
maxref(y,y)=-1;
cout<<"\n value of x is :"<<x;
cout<<"\n value of y is :"<<y;
getch();
}

This program output is
value of xis 20
value of y is : -1
but how to get this output?
help me.

because fun returns variable as return type is int &. if & is omitted in fun return type,value will be returned but it leads to error as invalid assignment in main function (20=-1).

>First C compiler program compiled on which compiler..???
Unknown, but probably either an assembler or Ken Thompson's B compiler on the PDP-11.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.