Ads

Wednesday, November 18, 2009

Few C++ Programs

Answer for Previous Post: Ventriloquist.

Ventriloquism is an act of stagecraft in which a person (a Ventriloquist) manipulates his or her voice so that it appears that the voice is coming from elsewhere, usually a puppeteered "dummy".

Please try to solve below C++ Programs.

1)

main()
{
float i = 1.1;
double j = 1.1;
if(i==j)
printf("Equal value");
else
printf("Not an equal value");
}

Answer: Not an equal value

2)

main()
{
int i=-1,j=-1,k=0,l=2,m;
m=i++&&j++&&k++||l++;
printf("%d %d %d %d %d",i,j,k,l,m);
}

Answer: 0 0 1 3 1

3)

main()
{
char string[]="Hello World";
display(string);
}
void display(char *string)
{
printf("%s",string);
}

Answer: the function "display" definition should be before the main funtion. otherwise the parameter "string" datatype will be considered as int by default.

1 comment: