EXAM!!! IMPORTANT!!!

closed account (9ihb7k9E)
please I got an exam on this Thursday can U please help to solve this?
THE EXAM IS ABOUT C LANGUAGE

(content removed)
Last edited on by admin
Do you believe that we would answer all that ? Don't be lazy and go study.
closed account (9ihb7k9E)
I am studying I would like just to compare my answers with yours
I'd like to compare your answers with the ones I'm about to write.
closed account (9ihb7k9E)
2.2 Mark by '*' all instructions with compilation errors

void syntaxErrors(void)
{
char *p1="12345";
char a0[]="12345";
char a1[1]="123"; *warning: initializer-string for array of chars is too long|
char c;
p1=a0;
a0=p1; * error: incompatible types in assignment|
a0==p1; *warning: statement with no effect|
p1=c; *warning: assignment makes pointer from integer without a cast|
p1=&c;
strcmp(c,a0); *warning: implicit declaration of function `strcmp'| **warning: passing arg 1 of `strcmp' makes pointer from integer without a cast|
strcmp(@c,p1); *error: stray '@' in program| **warning: passing arg 1 of `strcmp' makes pointer from integer without a cast|
a0=(char*) calloc(1,10); *error: incompatible types in assignment| **warning: implicit declaration of function `calloc'|
p1=(char*) calloc(1,10);
free(a1); *warning: implicit declaration of function `free'|
free(c);
free(&c);
return 'a'; } *warning: `return' with a value, in function returning void|
closed account (9ihb7k9E)
1. Initializes an integer pointer to an integer variable located in the global memory
area.

static int var = 1;
int *ptr;
ptr = &var;

2. Initializes an integer pointer to an integer variable located on the stack.

int var = 1;
int *ptr;
ptr = &var;

3. Initializes an integer pointer to an integer variable located on the heap.

???
not sure if you can make integers on the heap, just pointers

4. Defines an enumerative type Color that includes back, white and yellow.

enum
{
black,
white,
yello,
};

5. Defines a recursive function.

int factorial (int i)
{
int f;
if(i==1)
return 1;
else
f = i* factorial (i-1);
return f;
}

6. Defines a function with an output parameter, its value is to be multiplied by 4;

???
from my online searches, output parameters are something to do with C# not C, so i'm not sure what he means

7. Defines a function that tests if a number is the multiple of 17.

int multiple (int multi)
{
if (multi % 17 == 0)
printf("%d is a multiple if 17", multi);
else
printf("%d is not a multiple if 17", multi);
return 0;
}


8. Defines a function that tests if a number is positive and odd.

{
int x
if (x % 2) /* x is odd */

if (x %1) /* x is even */
}
closed account (9ihb7k9E)
5.1 Which functions are not properly defined. Justify your
answer.

int * p1() {
int i1;
return(&i1); |6|warning: function returns address of local variable|
}
int * p2() {
static int i1;
return(&i1);
}
int globInt;
int * p3() {
return(&globInt);
}
int p4() {
int result;
return(result);
}
int *p5() {
return((int*) malloc(sizeof(int)));
}

when compiled i get this error again: |undefined reference to `_WinMain@16'|
closed account (zb0S216C)
ANGELOJOKER wrote:
i get this error again: |undefined reference to `_WinMain@16'| (sic)

The linker is telling you that it cannot find the definition of _WinMain(). This is due to an incorrect project setup; that is, your project is a Win32 GUI, not a console. Normally, the target medium can be set in the project's settings.

Wazzak
OP:
(content removed)
Last edited on by admin
closed account (9ihb7k9E)
Thanks I dont need Ur helps I solved them all :D
Topic archived. No new replies allowed.