Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, I need to submit it so, I want to know the correct code in the visual studio for output and also want to know

Hello,

I need to submit it so, I want to know the correct code in the visual studio for output

and also want to know w8p1.c and w8p1.h answers as well!

Thank you so much for helping^_^

main1.c

/* ================================================== Workshop #8 (Part-1): ==================================================

+------------------------------------------------+ IMPORTANT ========= *** DO NOT MODIFY THIS FILE *** +------------------------------------------------+ */

#include

#include "w8p1.h"

#define TEST_NEG -1 #define TEST_ZERO 0 #define TEST_INT 24 #define TEST_DBL 82.5

// --------------------------------------- // Function prototypes // --------------------------------------- int testIntFunction(void); int testDoubleFunction(void);

// --------------------------------------- // Main entry-point to the program // --------------------------------------- int main(void) { int preTestFailed = 0;

printf("============================ "); printf("Pre-testing Helper Functions "); printf("============================ ");

preTestFailed += testIntFunction(); preTestFailed += testDoubleFunction();

if (preTestFailed) { printf("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX "); printf(" Pretesting revealed ERRORS in the helper functions. "); printf(" Review where the tests failed and fix these errors "); printf(" before continuing. "); printf("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX "); } else { printf("=========================== "); printf("Starting Main Program Logic "); printf("=========================== ");

// Entry-point to program logic start(); }

return 0; }

// --------------------------------------- // Function definitions // --------------------------------------- int testIntFunction(void) { int intA = 0, intB = 0, fail = 0;

printf("------------------------ "); printf("Function: getIntPositive "); printf("------------------------ "); printf("For each of these tests, enter the following "); printf("three values (space delimited): %d %d %d ", TEST_NEG, TEST_ZERO, TEST_INT);

//----------------------------------- // Test-1: argument and return value printf("TEST-1: "); intB = getIntPositive(&intA); if (intA == intB && intA == TEST_INT) { printf(" "); } else { printf(" "); fail++; }

//----------------------------------- // Test-2: return value only intA = intB = 0; printf("TEST-2: "); intA = getIntPositive(NULL); if (intA == TEST_INT) { printf(" "); } else { printf(" "); fail++; }

//----------------------------------- // Test-3: argument only intA = intB = 0; printf("TEST-3: "); getIntPositive(&intA); if (intA == TEST_INT) { printf(" "); } else { printf(" "); fail++; }

return fail; }

int testDoubleFunction(void) { double dblA = 0.0, dblB = 0.0; int fail = 0;

printf("--------------------------- "); printf("Function: getDoublePositive "); printf("--------------------------- "); printf("For each of these tests, enter the following "); printf("three values (space delimited): %d %d %.1lf ", TEST_NEG, TEST_ZERO, TEST_DBL);

//----------------------------------- // Test-1: argument and return value printf("TEST-1: "); dblB = getDoublePositive(&dblA); if (dblA == dblB && dblA == TEST_DBL) { printf(" "); } else { printf(" "); fail++; }

//----------------------------------- // Test-2: return value only dblA = dblB = 0.0; printf("TEST-2: "); dblA = getDoublePositive(NULL); if (dblA == TEST_DBL) { printf(" "); } else { printf(" "); fail++; }

//----------------------------------- // Test-3: argument only dblA = dblB = 0.0; printf("TEST-3: "); getDoublePositive(&dblA); if (dblA == TEST_DBL) { printf(" "); } else { printf(" "); fail++; }

return fail; }

w8p1.c

#define _CRT_SECURE_NO_WARNINGS

// System Libraries

// User Libraries

// 1. Get user input of int type and validate for a positive non-zero number // (return the number while also assigning it to the pointer argument)

// 2. Get user input of double type and validate for a positive non-zero number // (return the number while also assigning it to the pointer argument)

// 3. Opening Message (include the number of products that need entering)

// 4. Get user input for the details of cat food product

// 5. Display the formatted table header void displayCatFoodHeader(void) { printf("SKU $Price Bag-lbs Cal/Serv "); printf("------- ---------- ---------- -------- "); }

// 6. Display a formatted record of cat food data

// 7. Logic entry point

w8p1.h

// ---------------------------------------------------------------------------- // structures

// ---------------------------------------------------------------------------- // function prototypes

// 1. Get user input of int type and validate for a positive non-zero number // (return the number while also assigning it to the pointer argument)

// 2. Get user input of double type and validate for a positive non-zero number // (return the number while also assigning it to the pointer argument)

// 3. Opening Message (include the number of products that need entering)

// 4. Get user input for the details of cat food product

// 5. Display the formatted table header

// 6. Display a formatted record of cat food data

// 7. Logic entry point

#pragma once

I must be showing this output in the visual studio and the putty!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions

Question

3 What is routine problem solving?

Answered: 1 week ago