Computer Science: A Structured Programming Approach Using C, Third Edition
3rd Edition
ISBN: 9780534491321
Author: Behrouz A. Forouzan, Richard F. Gilberg
Publisher: Course Technology, Inc.
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 2, Problem 4PS
Which of the following statements about the structure of a C
a. A C program starts with a global declaration section.
b. Declaration sections contain instructions to the computer.
c. Every program must have at least one function.
d. One and only one function may be named main.
e. Within each function there is a local declaration section.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
I need to write a code in c, and it also has to meet the following requiremnts ,Write a very simple program that: 1. Has a main function (all C executables have one). 2. Has two different functions that are called by the program. 3. Uses at least one of the standard libraries.
What is the output of the following C++ program segment? Assume all variables are properly declared. for (j = 0; j < 8; j11){cout << j * 25 << " - ";if (j != 7)cout << (j + 1) * 25 - 1 << endl;elsecout << (j + 1) * 25 << endl;}
Write a program to solve the program exercise in chapter 2 #3. Consider the following program skeleton:
/*
Author(s):Â ..... *
Date:Â *
Title: Lab assignment 2b -- Standard IO *
Specification: *
Translate high-level instructions to C++ statements
*/
//include statement(s)
//using namespace statement
int main() {
  //variable declaration
   //executable statements
  //return statement
}
Â
Replace the commented statements in the above skeleton with the instructions below:
Write a C++ statement that includes the header file iostream.
• Write a C++ statement that allows you to use cin, cout, and endlwithout the prefix std::.
• Write C++ statement(s) that declare the following variables: num1, num2, num3, and averageof type int.
• Write C++ statements that store 125into num1, 28 into num2, and -25 into num3.
• Write a C++ statement that stores the average of num1, num2, and num3 into average.
• Write C++ statement(s) that output the values of num1, num2, num3, and average.
• Compile and…
Chapter 2 Solutions
Computer Science: A Structured Programming Approach Using C, Third Edition
Ch. 2 - The purpose of a header file, such as stdio.h, is...Ch. 2 - Prob. 2PSCh. 2 - The C standard function that receives data from...Ch. 2 - Which of the following statements about the...Ch. 2 - Which of the following statements about block...Ch. 2 - Prob. 6PSCh. 2 - Which of the following is not a data type?...Ch. 2 - The code that establishes the original value for a...Ch. 2 - Prob. 9PSCh. 2 - Prob. 10PS
Ch. 2 - To print data left justified, you would use a in...Ch. 2 - Prob. 12PSCh. 2 - One of the most common errors for new programmers...Ch. 2 - Which of the following is not a character constant...Ch. 2 - Which of the following is not an integer constant...Ch. 2 - Which of the following is not a floating-point...Ch. 2 - Prob. 17PSCh. 2 - Which of the following is not a valid identifier...Ch. 2 - What is the type of each of the following...Ch. 2 - What is the type of each of the following...Ch. 2 - Which of the following identifiers are valid and...Ch. 2 - Which of the following identifiers are valid and...Ch. 2 - What is output from the following program...Ch. 2 - Prob. 24PSCh. 2 - Find any errors in the following program....Ch. 2 - Find any errors in the following program....Ch. 2 - Prob. 27PSCh. 2 - Prob. 28PSCh. 2 - Prob. 29PSCh. 2 - Code the variable declarations for each of the...Ch. 2 - Code the variable declarations for each of the...Ch. 2 - Write a statement to print the following line....Ch. 2 - Write a program that uses four print statements to...Ch. 2 - Write a program that uses four print statements to...Ch. 2 - Write a program that uses defined constants for...Ch. 2 - Prob. 36PSCh. 2 - Prob. 37PSCh. 2 - Write a program that prompts the user to enter an...Ch. 2 - Write a C program using printf statements to print...Ch. 2 - Write a program that reads a character, an...Ch. 2 - Write a program that prompts the user to enter...Ch. 2 - Write a program that reads 10 integers and prints...Ch. 2 - Write a program that reads nine integers and...
Knowledge Booster
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
- Please use strtol and strtod. Please have the int main function first as well and write in C++. Develop a C++ program that reads an unsigned number in some base and outputs theequivalent value in a target base. The input file providing these values will be organized toallow for comment lines and blank lines along with data lines. Use only a single source file so Ican more easily script the downloading and compiling of your submissions.Your program must require a single command line argument, the name of an input file. Thisinput file will consist of any number of lines, each falling into one of three varieties:1. Comment - These lines always start with an at-symbol ('@') and should be completelyignored.2. Blank line - Used to visually organize the input file and should be completely ignored.3. Data line - These are the ones your program will process and are described below.Data lines will all have exactly 3 items separated by a single space character and end with anewline:1. an input…arrow_forwardAccording to the assignment rule, what should be the precondition in the following program segment?{precondition}x = x − 2{x = y}arrow_forwardWrite a c++ program to display a calendar for a given year. Type of Branches such as switch statements, if-else, and etc. should be used as well. No creation of functions is allowed to be used. Everything should be written in the main in one. - Ask a user to enter the year and the new year's day of the year entered: cout <<"Enter a calendar year to display?"; cout <<" what is the new year's day?"; a leap year is: IF year%4 = 0 AND year%100 != 0 OR year%400 = 0 - An example of what the program should display is in the two images attached. - Code should be written in this type of format: #include <iostream>using namespace std; int main() { /* Type your code here. */ return 0;}arrow_forward
- When the following C language function is called, will the argument x be pushed on thestack first or last?void MySub( x, y, z );arrow_forwardMy question: Is the header file #include <conio.h> and the getch() function necessary for a simple program such as the one provided below? The task for the program itself was to correct all syntax errors within it but I am on the fence as to whether or not these two items are syntax errors or not. What are your thoughts? Thank you Procided C++ code: #include<iostream>#include<conio.h> Standard namespace declarationusing namespace std; Main Functionint main(){    //Standard Ouput Statement   cout<<"Welcome to this C++ Program"<<endl;    cout<<I have corrected all errors for this program. <<endl;    // Wait For Output Screen getch()    //Main Function return Statement }arrow_forwardWhat will be the output of the following C++ code? #include <iostream>using namespace std;int main(){float num1 = 1.1;double num2 = 1.1;if (num1 == num2)cout << "stanford";elsecout << "harvard";return 0;} a) harvardb) stanfordc) compile time errord) runtime errorarrow_forward
- This is a c++ programming question. Write a header file called apple.h It should contain the following items: - a macro which gets one input parameter and return the square of the input value. - an inline function which gets two float type input parameters and returns the greater value. - a symbolic constant called M which has the value 100.arrow_forwardHi, I need help with the item below - thanks! I am trying to learn to write in C programing using Visula Studio Code but I cannot figure out how to show the $ sign in the Terminal section as shown in the attached file.  Can you help me please??arrow_forwardWrite a C99 function that includes the following sequence of statements:x = 21;int x;x = 42;Run the program and explain the results. Rewrite the same code in C++and Java and compare the results.arrow_forward
- Write a C program to swap two integers you should write a function named as swap_int and it should accept arguments as pointers then it should swap integers by dereferencing those pointers. Also put Screenshot of output...And use Ubuntu software for this program.arrow_forwardINTRODUCTION: In this assignment, you will demonstrate how to write simple programs that get input from the user, produce output, and perform simple calculations. ASSIGNMENT HEADER At the top of each of your C++ programs, you should have at least four lines of documentation: Program name (the C++ file name(s)), Author (your name), Date last updated, and Purpose (a brief description of what the program accomplishes). Here is an example: /* Program name: jbtictactoe.cpp* Author: John Doe* Date last updated: 5/1/2017* Purpose: Play the game of Tic-Tac-Toe*/ ASSIGNMENT: Ingredient Adjuster Actions  The following image shows a Python Program which is the Ingredient Adjuster. Write a CPP program by converting the Python code to CPP that produces the output displayed in the Console window:arrow_forwardI need to write a basic code on C, That completes the following taks:arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
What Are Data Types?; Author: Jabrils;https://www.youtube.com/watch?v=A37-3lflh8I;License: Standard YouTube License, CC-BY
Data Types; Author: CS50;https://www.youtube.com/watch?v=Fc9htmvVZ9U;License: Standard Youtube License