Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

How can I modify the code if the two numbers are the same?

Salem

New Coder
HI every one .
1644325584597.png

1644325593605.png
1644325835239.png
1644325607220.png

Here is my code

C:
#include <stdio.h>



int main() {
 

  int a,b,c ;
    printf("Enter  the three values\n");
    scanf("%d %d %d",&a,&b,&c);
    if(a>b){
         if(a>c){
            printf("a is the biggest value",a);

         }
         else{
            printf("c is the biggest value",c);
         }
         if ("b>c"){
            printf("b is the biggest value",b);
         }
         else
         {
             printf("c is the biggest value",c);
         }
       }


  return 0;

    }

I want to modify it , if the person gibt two number the same
like , A= 3 , B=4 , C=5 so thprogram will show tha c is the biggest number , but that is not true, so I want to solve this problem
 

Attachments

  • 1644325599503.png
    1644325599503.png
    69.5 KB · Views: 4
Last edited by a moderator:
Please do not post screenshots of your code. Post your code in proper code tags. I'm sure this is explained somewhere in the Forum Rules and/or FAQ.

Now what on earth are these quotes doing here ?
if ("b>c") {
This does not compare b and c, but just evaluates to true, because the value of the string "b>c" is non-zero. This is how C works, read up on it if needed. Your statement can cause B being flagged the biggest number even if it isn't.

But, you are printing the name of the variable instead of the value which the assignment asked for.
Change your output lines to printf("%d is the biggest value", a); and so forth.
Then your output would have been correct. i.e. 3 is the biggest value. I think modern C compilers would give an error or warning on your printf's.

In the last screenshot you get a compiler error. What exactly is unclear about that, given you inserted an extra opening bracket on line 7 ? If I can give you one good advice: line up your opening and closing brackets so you will SEE when they do not match. To hell with that modern fad of putting the opening bracket at the end of the if line. Whoever invented that should be, well.... paintballed at least.

Next, there seems to be a single quote dangling in mid-air on line 25. That will probably be your next compile error.

Lastly, given that you need the value and not the name, it's silly to have 4 printf's for this. Find out what the largest value is and print it once after the logic is done.
 
Dedicated software development teams https://mlsdev.com/blog/how-to-build-a-social-network-website-from-scratch can also help you save money. A dedicated team will be more expensive than an extended team, but they will be more efficient and more likely to deliver the results you're looking for. Developing a software team from scratch is a time-consuming and expensive process. Outsourcing is a better option if you don't have the resources to hire a full-time team. The best teams will provide you with the same high quality software as an in-house developer.
Your post has been reported as spam.
 

Buy us a coffee!

Buy me a coffee.
Back
Top Bottom