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"); }
#include <sys/types.h> #include <unistd.h> #include <stdio.h> int main(void) {       pid_t child_pid; int   count = 6;...
#include <sys/types.h> #include <unistd.h> #include <stdio.h> int main(void) {       pid_t child_pid; int   count = 6;       child_pid = fork();       if (child_pid == 0) {             execl("/bin/ls", "ls", "-l", NULL);             ++count;             exit(1); }       else             count = count * 2;       printf ("The counter = %d \n", count);       return 0;} If execl succeeds, what will be the output for the child process? For the parent process? If execl fails, what will be the output for the child process? For...
create case 4 #include <stdio.h> int main(void) { int counter; int choice; FILE *fp; char item[100];...
create case 4 #include <stdio.h> int main(void) { int counter; int choice; FILE *fp; char item[100]; while(1) { printf("Welcome to my shopping list\n\n"); printf("Main Menu:\n"); printf("1. Add to list\n"); printf("2. Print List\n"); printf("3. Delete List\n"); printf("4. Remove an item from the List\n"); printf("5. Exit\n\n"); scanf("%i", &choice); switch(choice) { case 1: //add to list //get the input from the user printf("Enter item: "); scanf("%s", item); //open the file fp = fopen("list.txt","a"); //write to the file fprintf(fp, "\n%s", item); //close the file...
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; }
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT