C Programming Language
C Programming Language
2nd Edition
ISBN: 9780131103627
Author: Brian W. Kernighan, Dennis M. Ritchie, Dennis Ritchie
Publisher: Prentice Hall
bartleby

Videos

Textbook Question
Book Icon
Chapter 1, Problem 1E

Run the “hello, world” program on your system. Experiment with leaving out parts of the program, to see what error messages you get.

Expert Solution & Answer
Check Mark
Program Plan Intro

To run the hello world program and experiment with leaving out parts of the hello world program, to see the error message.

Explanation of Solution

Program:

//Leaving out header file
//#include <stdio.h>
main()
{
printf("Hello, ");
	printf("World");
printf("\n");
}

Explanation:

The program above leaving the header file <stdio.h> statement to see the error. There is a warning in the program and shows the output.

Sample Output:

C Programming Language, Chapter 1, Problem 1E , additional homework tip  1

Program: 

#include <stdio.h>
//Leaving out main function
//main()
{
printf("Hello, ");
	printf("World");
printf("\n");
}

Explanation:

The program above leaving the main function to see the error. There is an error in program line 4.

Sample Output:

C Programming Language, Chapter 1, Problem 1E , additional homework tip  2

Program: 

#include <stdio.h>
main()
{
//Leaving out first statement line
//printf("Hello, ");
	printf("World");
printf("\n");
}

Explanation:

The program above leaving the first statement line to see the error. There is no error and print world, then a new line.

Sample Output:

C Programming Language, Chapter 1, Problem 1E , additional homework tip  3

Program: 

#include <stdio.h>
main()
{
printf("Hello, ");
//Leaving out second statement line
	//printf("World");
printf("\n");
}

Explanation:

The program above leaving the second statement line to see the error. There is no error and print hello, then a new line.

Sample Output:

C Programming Language, Chapter 1, Problem 1E , additional homework tip  4

Program: 

#include <stdio.h>
main()
{
printf("Hello, ");
	printf("World");
	//Leaving out third statement line
//printf("\n");
}

Explanation:

The program above leaving the third statement line to see the error. There is no error and print hello,world without a new line.

Sample Output:

C Programming Language, Chapter 1, Problem 1E , additional homework tip  5

Program: 

#include <stdio.h>
//Leaving out curley braces.

main()
//{
printf("Hello, ");
printf("World");
printf("\n");
//}

Explanation:

On leaving the curly braces the program will not compile and produce compilation error.

Sample Output:

C Programming Language, Chapter 1, Problem 1E , additional homework tip  6

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
can I see the screenshot of the whole coding in the program?
Please help by using Java Script Note:- Do not provide handwritten solution. Maintain accuracy and quality in your answer. Take care of plagiarism.Answer completely.You will get up vote for sure.
With the use of code snippets, I'll demonstrate how the Scanner class in Java programming may be used to accept data from the keyboard.
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
The Top Down Approach to Software Development; Author: Christopher Kalodikis;https://www.youtube.com/watch?v=v9M8LA2uM48;License: Standard YouTube License, CC-BY