Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7092007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:15:32+00:00 2026-05-28T08:15:32+00:00

My code thus far: #include <stdio.h> main() { float p_Asphalt = 5.2, p_Concrete =

  • 0

My code thus far:

#include <stdio.h>

main() 
{
    float p_Asphalt = 5.2, p_Concrete = 4.93, p_Stones = 2.21;
    float c_Concrete = 8.88; 
    float d_Length =, d_Width;
    char typeOfPaving, c_Curbing;
    float totalCost = 0;
    float GST = 1.13, PST = 1.10;

    printf("asphalt company\n\n");
    printf("Length of Driveway: ");
        scanf("%f", &d_Length);
    printf("Width of Driveway: ");
        scanf("%f", &d_Width);
    printf("\nType of Paving:\n");
    printf(" 'A' for asphalt paving\n");
    printf(" 'C' for concrete paving\n");
    printf(" 'S' for paving stones\n\n");
    printf("Select (A,C,S): ");
        scanf("%c%c", &typeOfPaving);
    printf("%c", typeOfPaving);

    if (typeOfPaving == "A") 
    {
        totalCost = p_Asphalt * (d_Length * d_Width);
        printf("Concrete curbing? [y/n]: ");

            scanf("%c%c", c_Curbing);

            if (c_Curbing == 'y') { 
                totalCost = totalCost + (d_Length * c_Concrete);
            }
            else {
                totalCost = totalCost * GST;
                printf("Quoted Price of Paving: %f\n", totalCost);
            }
    } 
    else if (typeOfPaving == "C") 
    {
        totalCost = p_Concrete * (d_Length * d_Width);
        printf("Quoted Price of Paving: %f\n", totalCost);
    } 
    else if (typeOfPaving == "S") 
    {
        totalCost = p_Stones * (d_Length * d_Width);
        printf("Quoted Price of Paving: %f\n", totalCost);
    }
}

For some reason, when I compile, I get the following output:

:~/> cc assignment1.c ^C
:~/>
:~/> a.out
asphalt company

Length of Driveway: 123
Width of Driveway: 123

Type of Paving:
 'A' for asphalt paving
 'C' for concrete paving
 'S' for paving stones

Select (A,C,S): A

:~/>

Nothing happens. On line 22 where I have scanf("%c%c", &typeOfPaving);, I use %c%c because my professor told me that the first %c stores the new line character after inputting data into the variable d_Width on line 16: scanf("%f", &d_Width);. Problem I see now is that (I think?) that char typeOfPaving stores \nA? not just A so my if statements won’t work? Is that correct?

Can somebody please help me, not sure what to do lol, kind of frustrating

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:15:33+00:00Added an answer on May 28, 2026 at 8:15 am

    You’ve done well by forming a hypothesis that explains why your program is misbehaving. The next important step is figuring out a test that will confirm or refute the hypothesis. That is, if you are claiming that typeOfPaving stores \nA, how can you test if this is the case?

    If it is the case, what can you do to correct the problem? If it is not the case, what is your next hypothesis?

    You’ll find that practising this will lead you further than seeking an exact answer from someone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For a project I have to implement a bitset class. My code thus far
Here is my code thus far: $(document).ready(function(){ $(.KD).click(function(){ $(p).load('KD.html'); $(.video).load('KDVideo.html'); $(.synopsis-change).toggleClass(synopsis); $(.synopsis).toggleClass(synopsis-change); }); });
I installed the wxWidgets source code, compiled it and am linking the libraries thus
I want to run a Maven compilation by my Java code. Thus, I've used
Insertion of a file's tag, thus executing the file's code. Removal of the file's
When I usually use code (include headers) from 3rd party (non-standard) C++ libraries, a
I'm mainly using Ruby to do this but my plan of attack thus far
Code below does not run correctly and throws InvalidOperationExcepiton . public void Foo() {
Code: <html xmlns=http://www.w3.org/1999/xhtml> <head> <title>Unusual Array Lengths!</title> <script type=text/javascript> var arrayList = new Array();
Code I have: cell_val = CStr(Nz(fld.value, )) Dim iter As Long For iter =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.