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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:14:04+00:00 2026-05-30T00:14:04+00:00

when i try to run the code am having problem in the output. when

  • 0

when i try to run the code am having problem in the output.

when the inputs s= 1, m=1 then am able to output i.e. solar and mains contactors result.

when both inputs are 0 i.e. s =0 and m = 0, then it is giving “There is no power”.(correct output)

when s = 1, m = 0 it should say “There is no power”. and am able to get the correct output.

when s=0, m=1, it should say “There is no power”, but instead its continuing to the solar contactors information(not the correct output).

So what could be the problem can anyone explain me?

#include<stdio.h>
#include<stdbool.h>
#define TRUE  1
#define FALSE 0

int main()
{
    bool s, m; //input parameters
    bool a, b; 
    bool p, q; 
    bool t;    //output parameters          

    printf("Enter the value of solar VMD : \n");  //scanning vmd values of solar 
    scanf("%d", &s);
    printf("Enter the value of Mains VMD : \n");  //scanning vmd values of Mains
    scanf("%d", &m);      

    if(s == 1,m == 1)               
    {                
        printf("Scan solar contactor : \n");  //scanning solar contactor 
        scanf("%d", &a);
        printf("Scan Mains contactor : \n");  //scanning mains contactor
        scanf("%d", &b);

        if(a == 1, b == 1)  //when solar & mains contactor are close
        {
            q = FALSE;
            p = TRUE;
            printf("Solar contactor and Mains contactor: %d %d", p, q);
        }
        else if(a == 0, b == 1)  //when solar contctor is open and mains is closed
        { 
            q = FALSE;
            p = TRUE;
            printf("Solar contactor and Mains contactor: %d %d", p, q);
        }
        else if(a == 1, b == 0)  //when solar contactor is closed and mains is open
        {  
            q = FALSE;
            p = TRUE;
            printf("Solar contactor and Mains contactor: %d %d", p, q);
        }      
        else if(a == 0, b == 0)  //when both solar and mains are open                    
        {
            q = FALSE;
            p = TRUE;
            printf("Solar contactor and Mains contactor: %d %d", p, q);
        }
        else 
        {
            printf("Problem with contactors");
        }   
    }

    else 
    {
        printf("There is no power");
    }    

    getchar();
    getchar();
    return 0;
}
  • 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-30T00:14:07+00:00Added an answer on May 30, 2026 at 12:14 am
    if(s == 1,m == 1)
    

    This code doesn’t do what you think it does. Learn about operators of the C language, especially logical operators and the comma operator.

    Update

    The other bug is that %d would not work with bool. In fact there’s no scanf format which would. So you have to either stick to int (which is a perfectly good type for doing boolean operators), or write your own function to read bools from a stream.

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

Sidebar

Related Questions

When I try to run the following code (from the REPL) in Clojure: (dotimes
I have a little problem when I try to run my Android application. The
I am having a problem closing my Scala swing frame. Here is the code
I try to run jsf application in myeclipse using jboss web server and following
I try to run one program in myeclipse where after creating one web project
When I try to run a .NET assembly ( boo.exe ) from a network
Every time I try to run a small application that uses a Derby DB
When I try to run a particular stored procedure on my MS SQL 2005
whenever I try to run something in Java, Eclipse changes into the PHP perspective.
Whenever i try to run sqlmetal, i get this: 'sqlmetal' is not recognized as

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.