Question
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("
//----------------------------------- // Test-2: return value only intA = intB = 0; printf("TEST-2: "); intA = getIntPositive(NULL); if (intA == TEST_INT) { printf("
//----------------------------------- // Test-3: argument only intA = intB = 0; printf("TEST-3: "); getIntPositive(&intA); if (intA == TEST_INT) { printf("
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("
//----------------------------------- // Test-2: return value only dblA = dblB = 0.0; printf("TEST-2: "); dblA = getDoublePositive(NULL); if (dblA == TEST_DBL) { printf("
//----------------------------------- // Test-3: argument only dblA = dblB = 0.0; printf("TEST-3: "); getDoublePositive(&dblA); if (dblA == TEST_DBL) { printf("
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!