d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Basic C Questions > Paying 10fg Per
Add Reply New Topic New Poll
Member
Posts: 1,856
Joined: Dec 7 2012
Gold: 28,863.00
Feb 22 2013 08:56pm

a few problems that i dont have time to do, should take less than 1min per for a pro. pm me answers and u get 10fg each.


9)
#include<stdio.h>
void main(){
if('\0');
else if(NULL)
printf("a");
else;
}

10)
#include<stdio.h>
void main(){
int a=5,b=10;
clrscr();
if(a<++a||b<++b)
printf("%d %d",a,b);
else
printf("Can you reach me here?");
}

11)
#include<stdio.h>
void main(){
int x=1,y=2;
if(--x && --y)
printf("x=%d y=%d",x,y);
else
printf("%d %d",x,y);
}

12)
#include<stdio.h>
void main(){
signed int a=-1;
unsigned int b=-1u;
if(a==b)
printf("1");
else
printf("2");
}

13)
#include<stdio.h>
void main(){
char c=256;
char *ptr="ZANE";
if(c==0)
while(!c)
if(*ptr++)
printf("%+u",c);
else
break;
}

14)
#include<stdio.h>
void main(){
int a=2;
if(a--,--a,a)
printf("1");
else
printf("2");
}
Member
Posts: 9,803
Joined: Jun 28 2005
Gold: 6.67
Feb 22 2013 09:09pm
What exactly is an answer? Text printed to stdout?

Anyway,

Code
void main()

is not correct portable C, although it might be correct on some machines. It definitely isn't for x86 linux or windows.

9) Will print nothing.

10) Won't compile. If clrscr reference is removed, it's still undefined behaviour.

11) 0 2

12) 1

13) May be undefined behaviour, depending on platform (signed overflow).
On x86, the expected result would be:
0000

14) 2


This post was edited by KrzaQ2 on Feb 22 2013 09:20pm
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll