Question

1-Is it possible to run a program without a main() function? Yes No 2- How many...

1-Is it possible to run a program without a main() function?

Yes

No

2- How many main() functions can one have in a program?

  • 2
  • This depends on what compiler you use.
  • As many as you like
  • 1

3- What does the following code fragment leave in x?

char a = 'A';

int x = sizeof (a);

  • 1
  • Depends on what compiler you use.
  • 4
  • 2

4- True or false: In a C program I can have two functions with the same name.

  • True
  • False

5- What will the following print?

int main(void)

{

int a = 10/3;

printf("%d", a);

}

  • 3.0
  • 1
  • 3.33
  • 3

6- What will the following program produce?

int main(void)

{

int a = 3.7;

printf("%d", a);

}

  • 3
  • Compile error
  • 4
  • 3.7

7- What will be the result of the following program fragment?

int a, b, c;

a = b = c = 12;

  • a, b, and c will all be set to 12
  • Runtime error
  • 0

b. 1

c. it will never stop printing hello

   d. this will produce a compile error

  • c will be set to 12, a and b are undefined

8.How many times will "hello" be printed?

int main(void)

{

int i = 0;

while(i < 5)

{

printf("hello\n");

}

}

8- How many times will the "hello" be printed?

int main(void)

{

int i;

for(i = 0; i < 10; i++);

{

printf("%d", "hello");

}

}

  • 1
  • 0
  • This will give a compile error
  • 10

9- What will the following program print?

int main void()

{

int k, m, count = 0;

for (k = 0; k < 5; k++)

{

for(m = 0; m < 2; m++)

{

count++;

}

}

printf("%d", count);

}

  • 17
  • 10
  • 5
  • 0

10- What does the following line of code tell the compiler?

int thing(int, int);

  • thing is a function that requires two int paramaters and returns an int value
  • thing is a subprogram that ultimately does nothing
  • None of the above
  • Nothing. This is an illegal statement
0 0
Add a comment Improve this question Transcribed image text
Answer #1

1) Is it possible to run a program without a main() function?
Answer: No
Explanation: The Program Execution Starts with main() FUnction without main we cannot run the Program

2) How many main() functions can one have in a program?
Answer: Option d)1
Explanation:Each and Every Program should have only one main() functions

3) Answer: Option a) 1
Explanation:

Program:

mtino 1 #include<stdio.h> 2 - int main() { 3 char a = A; int x = sizeof (a); printf(x = %d, x); 6 }

#include<stdio.h>
int main() {
char a = 'A';
int x = sizeof (a);
printf("x = %d", x);
}

Output:

x = 1

4) Answer: Option c) 3
Explanation:

Program:

1 2 3- 4 5 6 #include<stdio.h> int main(void) { int a = 10/3; printf(%d, a); }

#include<stdio.h>
int main(void)
{
int a = 10/3;
printf("%d", a);
}


Output:

6) Answer: Option a) 3

#include<stdio.h>
int main(void)
{
int a = 3.7;
printf("%d", a);
}

Output:

7) Option a) a, b, and c will all be set to 12

Explanation:

Program:

#include<stdio.h>
int main(void)
{
int a, b, c;
a = b = c = 12;
printf("a= %d\n", a);
printf("b= %d\n", b);
printf("c= %d", c);
}

Output:

E

8) Answer: Option c. it will never stop printing hello

Program:

#include<stdio.h>
int main(void)
{
int i = 0;
while(i < 5)
{
printf("hello\n");
}
}

Output:

hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello9) answer: Option b) 10

Explanation:

Program:

#include<stdio.h>
int main(void)
{
int k, m, count = 0;
for (k = 0; k < 5; k++)
{
for(m = 0; m < 2; m++)
{
count++;
}
}
printf("%d", count);
}


Output:

10) Answer: Option a) thing is a function that requires two int paramaters and returns an int value


Add a comment
Know the answer?
Add Answer to:
1-Is it possible to run a program without a main() function? Yes No 2- How many...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • OPERATING SYSTWM Question 31 What is the output of this C program? #include #include void main()...

    OPERATING SYSTWM Question 31 What is the output of this C program? #include #include void main() int mptr, *cptr mptr = (int*)malloc(sizeof(int)); printf("%d", "mptr); cptr = (int)calloc(sizeof(int),1); printf("%d","cptr); garbage 0 000 O garbage segmentation fault Question 8 1 pts If this program "Hello" is run from the command line as "Hello 12 3" what is the output? (char '1'is ascii value 49. char '2' is ascii value 50 char'3' is ascii value 51): #include<stdio.h> int main (int argc, char*argv[]) int...

  • 1) Consider the following Java program: 1 public class HelloWorld { 2     // My first program!...

    1) Consider the following Java program: 1 public class HelloWorld { 2     // My first program! 3     public static void main(String[] args) { 4         System.out.println("Hello, World!"); 5     } 6 } What is on line 1? a. a variable declaration b. a statement c. a method (subroutine) definition d. a comment e. a class definition 2) Which one of the following does NOT describe an array? a. It can be used in a for-each loop. b. It has a numbered sequence...

  • c program void funcint x, int *y) { 1. Whof the Rings gical ASA All of...

    c program void funcint x, int *y) { 1. Whof the Rings gical ASA All of the above 1.0.2.4) What will be the out of the de int, pat) A) 10 12 (1.03.2) What will be the output of the following int , printf(d, a,b); A) & B) 17 11.12 D) 17.25 13. (L032) An array is a group of memory locations related by the fact that they all have my name and pe A) different different B) same, different...

  • computers. 1. How many times will this loop repeat? include <stdlib.h> #include <stdio.h> void main(void) int...

    computers. 1. How many times will this loop repeat? include <stdlib.h> #include <stdio.h> void main(void) int 10 for(= 0; i < 101) printf("d", 1); A. 10 times B. 1 time C. It will run forever D. 0 times 2. What will be the output of this program? #include <stdlib.h> #include <stdio.h> int main() int a = 100, b = 200, C = 300; if(!a >= 500) b = 300; C = 400; printf("%d, 8d, &d", a, b, c); return 0;...

  • 1 Rewrite the following program so that it will use function. include <stdio.h> Int main) printf...

    1 Rewrite the following program so that it will use function. include <stdio.h> Int main) printf ("Hello!") return 0 2 Assume a program has the following declarations: short s- 4 int i--5; long m-3 float f-19.3f; double d-3.6; What are the following values? (a) s+m (b) (float) d (c) d s (e) (int) f 3 What will be the output of the following program: int x = 3 float a 2.76; y-2* x; print f("X-2d, y*ta, z»%d", x, y, z);...

  • How many times does the message, “Hello” get printed out by the code segment below? int...

    How many times does the message, “Hello” get printed out by the code segment below? int count = 0; while (count < 41) {     printf(“Hello\n”);     count = count+3; } D Question 2 1 pts How many times does the message, "Hello" get printed out by the code segment below? int count = 0; while (count < 41) printf("Helloln"); count count+3;

  • How can I convert the following C code to MIPS Assembly? +++++++++++++++++++++++++++++++++ MIPS main program ++++++++++++++++++++++++++++++++...

    How can I convert the following C code to MIPS Assembly? +++++++++++++++++++++++++++++++++ MIPS main program ++++++++++++++++++++++++++++++++ .data # Defines variable section of an assembly routine. array: .word x, x, x, x, x, x, x, x, x, x # Define a variable named array as a word (integer) array # with 10 unsorted integer numbers of your own. # After your program has run, the integers in this array # should be sorted. .text # Defines the start of the code...

  • QUESTION 1 In order to print the members of structures in the array, what will be...

    QUESTION 1 In order to print the members of structures in the array, what will be the contents of blanks in the printf statement of the code snippet given below? #include <stdio.h> struct virus {    char signature[25];       char status[20]; } v[2] = {                               "Yankee Doodle", "Deadly",                               "Dark Avenger", "Killer"                   } ; void main( ) {       for (int i = 0; i < 2; i++)                   printf( "\n%s %s", _______________ , _____________ ); } A. signature, status B. v.signature,...

  • Step 4: Write a Sum Function Since we can write, compile and run simple c files,...

    Step 4: Write a Sum Function Since we can write, compile and run simple c files, lets add a bit to make a program that will sum an entire array of integers. To do this we are going to simply overwrite the main.c file to include the new function. The sum function below is not complete and must be finished before the program will execute properly. %%file main.c #include <stdio.h> int sum(int array[], int arrayLength) {     int i =...

  • Java 1. Can you explain it how it will be printed step by step? Thanks!! What...

    Java 1. Can you explain it how it will be printed step by step? Thanks!! What is printed by the following? for (int i=1; i<4; i++) { for (char c=’a’; c<=’c’; c++) { if (i%2==0) { i++; System.out.println(i + " " + c); } else { c++; System.out.println(c + " " + i); } } } 2. Is there a compiler error in this code? If so, what is it? If not, what’s printed? Is there a compiler error in...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT