Question

Give the output of the program: void thing1(); void thing2(); int main() {      printf("3 ");...

Give the output of the program:

void thing1();

void thing2();

int main()

{

     printf("3 ");

thing1();

     printf("4");

thing(2);

     printf("5");

     return 0;

}

void thing1()

{

     printf("Gotcha!" );

}

void thing2()

{

     printf("HA! ");

}

Homework Answers

Answer #1

Answer : Error (Linker error)

Explanation: See The program might have run even if we didn't add the header file #include<stdio.h> to use built-in function like printf and scanf.
-But it will generate Warning regarding it.
- So the program will run fine but thing(2) this function is not defined it should be either thing2() so that it would have run fine.
- So in the end the program has generated a error with undefined reference to `thing' error.

#Code

// Header is not included but the program will run with warnings.
//#include<stdio.h>

// Function declaration
void thing1();
void thing2();


int main()
{
   printf("3 ");
// Calling function thing1()  
thing1();
   printf("4");
// Calling function tinng2 which is not defined.
// Or it should be thing2()  
thing(2);
//thing2(2);
   printf("5");
   return 0;
}

// Function defination
void thing1()
{
   printf("Gotcha!");
}

void thing2()
{
   printf("HA! ");
}

#Output

#Running Code

// Header is not included but the program will run with warnings.
//#include<stdio.h>

// Function declaration
void thing1();
void thing2();


int main()
{
   printf("3 ");
// Calling function thing1()  
thing1();
   printf("4");
// Calling function tinng2 which is not defined.
// Or it should be thing2()  
//thing(2);
thing2();
   printf("5");
   return 0;
}

// Function defination
void thing1()
{
   printf("Gotcha!");
}

void thing2()
{
   printf("HA! ");
}

#Running Output

#Note If need any help then ping me in the comments I will be glad to help you out ^_^ and If you liked the answer and explanation then please give a thumbs up I really need a +ve feedback at the moment.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Give the output of the program using Call-By-Reference: int i, a[3]; void f (int x, int...
Give the output of the program using Call-By-Reference: int i, a[3]; void f (int x, int y){ x = (x*y) mod 3; y = y – x; } main(){ i = 0; a[0] = 1; a[1] = 2; a[2] = 0; f(i, a[i]); print(“%d %d %d %d\n”, i, a[0], a[1], a[2]); f(a[i], a[i]); print(“%d %d %d\n”, a[0], a[1], a[2]); }
What is output? #include <stdio.h> void CheckValue(int* pointVar1, int* pointVar2) {       if (pointVar1 == NULL...
What is output? #include <stdio.h> void CheckValue(int* pointVar1, int* pointVar2) {       if (pointVar1 == NULL && pointVar2 == NULL) {       printf("Pointer is null\n");    }    else if (*pointVar2 > *pointVar1) {       printf("%p\n", *pointVar2);    }    else if (*pointVar1 > *pointVar2) {       printf("%p\n", *pointVar1);    } } int main() {    int num1 = 5;    int num2 = 9;       CheckValue(&num1, &num2);           return 0; } a. 0 b. 5 c. 9 d. Pointer is null e....
Consider the following Java program : public static void main (string args [ ]) { int...
Consider the following Java program : public static void main (string args [ ]) { int result, x ; x = 1 ; result = 0; while (x < = 10) { if (x%2 == 0) result + = x ; + + x ; } System.out.println(result) ; } } Which of the following will be the output of the above program? A. 35 B. 30 C. 45 D. 35 2. public static void main(String args[]) { int i =...
Question Rewrite the following C program using switch-case statement. and give me an output please use...
Question Rewrite the following C program using switch-case statement. and give me an output please use printf and scanf #include<stdio.h> int main(void) {      int semester;           printf("What is your Studying Level (1-8)?> ");      scanf("%d" , &semester);      if(semester == 1 || semester == 2)           printf("Your are a freshman!\n ");      else if(semester == 3 || semester == 4)           printf("Your are sophomore!\n ");      else if(semester == 5 || semester == 6)           printf("Your are...
Analyze the following program and write down the output. # include <iostream> using namespace std;    void...
Analyze the following program and write down the output. # include <iostream> using namespace std;    void modifyArray( int [ ], int );    void modifyElement ( int );      int main( ) {   const int arraySize = 8;   int a[arraySize] = { 2, -2, 10, -3, -1 ,0, 10, -5 };      modifyArray ( a, arraySize);      for ( int i =0; i < arraySize; i++)               cout << a[i] << ‘  ’;         modifyElement ( a[4] );          for ( int i =0; i <...
Convert the following C program to inline assembly int main(){ int i; printf("Hex Dec Oct Ch\n");...
Convert the following C program to inline assembly int main(){ int i; printf("Hex Dec Oct Ch\n"); for (i = 32; i < 256; i++){ printf("%2x %3d %3o %c\n",i,i,i,i); } return 0; } the code below shows where to do the assembly at: int main(){ int i = 0; char *hdr = "Hex Dec Oct Ch\n"; char *msg = " %2x %3d %3o %c\n"; printf("%s\n",hdr); ———asm{ // DO ASSEMBLY HERE } system("pause"); }
The function martian() has a prototype of: void martian(int ch); and an implementation of: void (int...
The function martian() has a prototype of: void martian(int ch); and an implementation of: void (int ch) { printf("%c" ,ch); return; } it is called from main as int md= 0x45; martian(md); What is printed on the screen?
could someone please explain this code and the output to me? #include <stdio.h> #include <unistd.h> int...
could someone please explain this code and the output to me? #include <stdio.h> #include <unistd.h> int main(void) { printf("one\n"); fork(); printf("two\n"); return 0; }
1 #include <stdio.h> 2 #include <stdlib.h> 3 4 extern char **environ;    5 void output(char *a[], char...
1 #include <stdio.h> 2 #include <stdlib.h> 3 4 extern char **environ;    5 void output(char *a[], char *b[]) { 6 int c = atoi(a[0]); 7 for (int i = 0; i < c && b[i]; ++i) { 8 printf("%s", b[i]+2); 9 } 10 } 11 12 void main(int argc, char *argv[]) { 13      14 switch (argc) { 15 case 1: 16 for (int i = 0; environ[i]; ++i) {    17 printf("%s\n", environ[i]); 18 } 19 break; 20 default: 21 output(argv +...
#include <stdio.h> extern unsigned long long sum(unsigned int *array, size_t n); int main(void) { unsigned int...
#include <stdio.h> extern unsigned long long sum(unsigned int *array, size_t n); int main(void) { unsigned int array[] = { 1, 1, 1, 3 }; unsigned long long r = sum(array, sizeof(array) / sizeof(*array)); printf("Result is: %llu (%s)\n", r, r == 6 ? "correct" : "incorrect"); return 0; } Complete the code for the line that calls the sum function. Write the sum function.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT