Thread: I want to plus largest number and smallest number

  1. #1
    Registered User
    Join Date
    Oct 2019
    Posts
    3

    I want to plus largest number and smallest number

    Hello ı want to plus it largest and lowest number this software.

    I want to software like this;
    1.Enter number like 25
    2.Enter number like 40
    3.Enter number like 5

    40+5=45

    ı want to plus it 40 + 5
    I'm finding largest and lowest number but i cant plus it.
    I need help thanks.


    Code:
    #include <stdio.h>#include <conio.h>
    #include <stdlib.h>
    
    
    main()
    {
        int a, b, c, plus;
        printf("1. Enter Number: "); scanf("%d", &a);
        printf("2. Enter Number: "); scanf("%d", &b);
        printf("3. Enter Number: "); scanf("%d", &c);
        if ((a>b) && (a>c)) printf("largest number: %d", a);
        else if (b>c) printf("largest number: %d", b);
        else printf("largest number: %d", c);
    
    
        if ((a<b) && (a<c)) printf("\nlowest number: %d", a);
        else if (b<c) printf("\nlowest number: %d", b);
        else printf("\nlowest number: %d", c);
        getch();
    
    
    
    
    }

  2. #2
    Registered User
    Join Date
    Aug 2019
    Location
    inside a singularity
    Posts
    308
    Hello ı want to plus it largest and lowest number this software.

    I want to software like this;
    1.Enter number like 25
    2.Enter number like 40
    3.Enter number like 5

    40+5=45

    ı want to plus it 40 + 5
    I'm finding largest and lowest number but i cant plus it.
    I need help thanks.


    Well, you've done it yourself already... All you need to do is add your Largest and Lowest numbers and store it in a variable, say Sum, and print it. 'if' statements can contain more than one line of code if you write something like so

    Code:
    if ( /* Test Condition */ )
    {
         // Code
    }

  3. #3
    Registered User
    Join Date
    Oct 2019
    Posts
    3
    I'm added this string:
    Code:
    
    
        plus = a + c;
        printf("\n a+c = %d\n", plus);
        return 0;
    and software plus true if software like this:
    1
    2
    3

    3+1 =4 it's true but if

    numbers like this:
    5
    4
    9

    true plus: 9+4=13
    but software plus it: 9+5 software wasn't plus it lowest and highest number software always plus 1. and 3. number

  4. #4
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    It is not enough to just print the numbers that are the largest and smallest. The computer is not going to remember which variable it is, so you need to also assign the largest number to a, and the smallest number to c, if you want plus = a + c to always work.

  5. #5
    Registered User
    Join Date
    Oct 2019
    Posts
    3
    I was fixed problem thank you all guys.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. The typical Largest smallest number printing
    By jannr in forum C Programming
    Replies: 21
    Last Post: 06-22-2011, 08:26 AM
  2. Extracting largest and smallest number
    By .C-Man. in forum C++ Programming
    Replies: 2
    Last Post: 02-18-2011, 06:29 AM
  3. smallest largest number
    By manzoor in forum C++ Programming
    Replies: 10
    Last Post: 05-12-2008, 07:56 AM
  4. largest and smallest number
    By wise_ron in forum C Programming
    Replies: 11
    Last Post: 10-05-2006, 03:25 PM
  5. Find the Largest and Smallest Number
    By Nightsky in forum C Programming
    Replies: 27
    Last Post: 09-04-2006, 03:40 PM

Tags for this Thread