Question

C programming 1. Create a file function.c that contains a function called printNumbers() that prints the...

C programming

1. Create a file function.c that contains a function called

printNumbers() that prints the numbers 1 to 15.

2. Create a file function.h that contains the prototype for the printNumbers()

function.

3. Create a file main.c that contains a main function that calls the

printNumbers() function. You will need to be sure to include the header file.

4. Use gcc to compile the entire program (all files) without warnings.

5. Run the program and make sure that it prints the numbers 1 to 15.

Homework Answers

Answer #1

/* function.h */

#ifndef MY_FUN
#define MY_FUN

/*function declarations*/
void printNumbers();

#endif

/* function.c */

#include"function.h"
void printNumbers(){
   int i;
   for(i = 1; i <=15 ; i++){
       printf("%d\n",i);
   }
}

/* main.c */

#include <stdio.h>
#include <stdlib.h>
#include"function.h"
int main(int argc, char *argv[]) {
   printNumbers();
   return 0;
}

/* OUTPUT */

/* PLEASE UPVOTE */

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
Create a program that generates a file of random numbers, and then prints them in neat...
Create a program that generates a file of random numbers, and then prints them in neat fashion to another file, and also saves to that file the average and standard deviation of those numbers. I) First, you would need to generate a file of random numbers that consists of N random numbers (100 < N < 1000). Each random digit should be a real number (type double) between 0 and 50. This file and its digits would now serve as...
Using C programming Create a function called printMenu( ) with the following properties: Has no function...
Using C programming Create a function called printMenu( ) with the following properties: Has no function inputs or output. Prints the following menu to the screen: 1. Enter user name. 2. Enter scores. 3. Display average score. 4. Display summary. 5. Quit Create a function called printLine( ) with the following properties: Takes as input a char Takes as input an integer corresponding to the number of times to print the character Has no function output. For example, if we...
C++ programming Write a program that reads a comma-separated file (CSV) with integer values and prints...
C++ programming Write a program that reads a comma-separated file (CSV) with integer values and prints the number of integer values in the file. Your program's input will be a string with the name of the file. If the file does not exist, then the program must print: Error opening the file For example, given the following CSV file input1.csv: 1,10,20,30,40 The output of your program must be: 5 You can safely assume that the input file will be a...
Write C++ code to: Create a function called “ReadFile” that: Accepts a filename as input Opens...
Write C++ code to: Create a function called “ReadFile” that: Accepts a filename as input Opens the file for reading Reads an integer from the file and returns it. Create a main function that Asks the user to input a file Passes that file to the “ReadFile” function Prints the returned integer to the screen
C++ create a program that: in main: -opens the file provided for input (this file is...
C++ create a program that: in main: -opens the file provided for input (this file is titled 'Lab_HW10_Input.txt' and simply has 1-10, with each number on a new line for 10 lines total) -calls a function to determine how many lines are in the file -creates an array of the proper size -calls a function to read the file and populate the array -calls a function to write out the contents of the array in reverse order *output file should...
JavaScript Programming Assignment PLEASE NOTE:  You must create and call a main function, and if instructed include...
JavaScript Programming Assignment PLEASE NOTE:  You must create and call a main function, and if instructed include additional functions called by the main. Make sure to use ES6 style of keywords => instead of the older function and for local scope variables use the keyword let and not a keyword var. Make sure to follow the requirements and recheck before submitting. PROJECT GOAL: Write a program that is required to use nested loops to generate a triangle as shown in the...
Create a C Program called Summer_Heat that meets the following criteria: Lines 1,2: Identifies the name...
Create a C Program called Summer_Heat that meets the following criteria: Lines 1,2: Identifies the name of Program that the Programmer Lines 4,5: Includes the header files to allow input and output and use the system commands Line 7: Includes Declarations comment Line 8: Declares counter as an integer with an initial value of 0 Line 9: Initializes a double array called temperature using a single statement and the following 10 values 78.6 82.1 79.5 75.0 75.4 71.8 73.3 69.5...
My assignment is listed below. I already have the code complete, but I cannot figure out...
My assignment is listed below. I already have the code complete, but I cannot figure out how to complete this portion: You must create a makefile to compile and build your program. I can't figure out if I need to create a makefile, and if I do, what commands do I use for that? Create a  ContactInfo class that contains the following member variables: name age phoneNumber The ContactInfo class should have a default constructor that sets name = "", phoneNumber...
Write C++ code to: Create a function called “ReadFile” that: Accepts a filename as input Opens...
Write C++ code to: Create a function called “ReadFile” that: Accepts a filename as input Opens the file for reading Reads an integer from the file and returns it. Create a main function that Asks the user to input a file Passes that file to the “ReadFile” function Prints the returned integer to the screen Extra Credit: Set a default argument of “intfile.txt” for the “ReadFile” function Write an overloaded function of “ReadFile” that accepts two filenames and reads an...
c# please Create a “Main” program which reads a text file called “collectionOfWords.txt”. Include exception handling...
c# please Create a “Main” program which reads a text file called “collectionOfWords.txt”. Include exception handling to check if the file exists before attempting to open it. Read and print each string to the console. Next modify each word such at the first letter in each word is uppercase and all other letters are lowercase. Display the modified word on the console. Creating a text file: Open up Notepad and type in the following words. Save the file as collectionOfWords.txt...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT
Active Questions
  • For Parts #1 through #9, consider the following information: The superintendent’s office for the Jersey Dunes...
    asked 2 minutes ago
  • 1. Find the intersections and unions below, and give a proof for each. (a) ∩r∈(0,∞)[−r,r]. (b)...
    asked 12 minutes ago
  • Using the South University Online Library or the Internet, research a health issue in the world....
    asked 13 minutes ago
  • Complete the java program. /* Note: Do not add any additional methods, attributes. Do not modify...
    asked 38 minutes ago
  • Find a commercial, product, or advertisement and fill in the conditioning procedure. Unconditioned Stimulus → Unconditioned...
    asked 38 minutes ago
  • In a conversation with someone who you feel may have faced discrimination. Examples include someone with...
    asked 45 minutes ago
  • One measure of the meat quality of pigs is backfat thickness. Suppose two researchers, Jones and...
    asked 58 minutes ago
  • Polychlorinated biphenyls (PCBs), used in the manufacture of large electrical transformers and capacitors, are extremely hazardous...
    asked 58 minutes ago
  • 3. (10 marks) Describe a recursive algorithm for finding the maximum element in a array A...
    asked 1 hour ago
  • Three identical very small 50-kg masses are held at the corners of an equilateral triangle, 0,30m...
    asked 1 hour ago
  • C programming 1. Create a file function.c that contains a function called printNumbers() that prints the...
    asked 1 hour ago
  • You visit a local Starbucks to buy a Mocha Frappuccino. The barista explains that this blended...
    asked 1 hour ago