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 7842905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:25:43+00:00 2026-06-02T16:25:43+00:00

I have a C program and I need to test it using a file

  • 0

I have a C program and I need to test it using a file containing some test data and output the results automatically. How can I do this? Should I modify the program or should I write another program using C or something else like Python? Which is easier?

Here is my C program:

int main()
{
    double wh,sh,salary;
    int num = 0;
    int valid = 1;
    printf("Please input two non-negative numbers as a employee's working hours in one week and salary per hour.\n");
    printf("Notice that the salary per hour can't be greater than 1000\nAlso you can't input more than 10 sets of data\n");
    printf("Input them like this:\n20,34\nthen enter the Enter key\n");
    while(scanf("%lf,%lf",&wh,&sh) == 2 && num < 10)
    {
        if(sh <0 || wh <0)
        {
            printf("Salary per hour or salary per hour can't be negative!\n");
        }
        else if(wh > 168)
        {
            printf("Working hours in one week can't be more than 168!\n");
        }
        else if(sh > 1000)
        {
            printf("Salary can't be greater than 1000!\n");
        }
        else
        {
            num ++;
            if(wh <= 40)
            {
                if(sh <= 1000)
                {
                    salary = wh * sh;
                }
                else if(sh > 1000 )
                {
                    salary = wh * 1000;
                }
            }
            else if(wh > 40 && wh <= 50)
            {
                if(sh*1.5 < 1000)
                {
                    salary = 40*sh + (wh-40)*1.5*sh;
                }
                else if(sh*1.5 > 1000 && sh < 1000)
                {
                    salary = 40*sh + (wh-40)*1000;
                }
                else if(sh > 1000)
                {
                    salary = wh * 1000;
                }
            }
            else if(wh > 50)
            {
                if(sh*3 < 1000)
                {
                    salary = 40*sh + 10*1.5*sh + (wh-50)*3*sh;
                }
                else if(sh*1.5 < 1000 && sh*3 >=1000)
                {
                    salary = 40*sh + 10*1.5*sh + (wh-50)*1000;
                }
                else if(sh*1.5 >= 1000 && sh <= 1000)
                {
                    salary = 40*sh + (wh-40)*1000;
                }
                else if(sh > 1000)
                {
                    salary = wh*1000;
                }
            }
            printf("The total working hours is %lf, and salary per hour is %lf, salary is %lf\n",wh,sh,salary);
        }
    }
    return 0;
}

For this moment please ignore these literals floating around.

I suppose the file containing test data is like this:

1,2
34,34
67,43
...

I really have no idea how this test automation works,please help!

  • 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-06-02T16:25:44+00:00Added an answer on June 2, 2026 at 4:25 pm

    in cmd prompt

    enter

    c:\>myprog.exe < input.txt > output.txt

    put all ur testcases in input.txt

    ur output will print in the output.txt file

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

Sidebar

Related Questions

I have a 200 MB text file. But, I need to test my program
I have a test.bak file in my local machine. I need to restore this
I have a program that I need to be able to search a file
I have a program (temptrack) where I need to download weather data every x
I have a program that looks like this. I need to consistently write something
I have a large file, with 1.8 million rows of data, that I need
Need some help for creating a File and String search engine. The program needs
I have a test .dll file using C# with the following details Name :
I have a program for a C class I need to write. The program
I have a program in which I need to store a Class object into

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.