1 like 1 dislike
494 views

Please write a simple program that performs calculation and, shows its result equals to '10'

** There is no restriction as long as the result indicates 10 from its calculation **

** However, your codes should NOT be the same as the given example **

 

Example

#include <stdio.h>
int main(){

int a, b, c, d;

scanf ("%d %d %d", &a, &b, &c);

d = a + b * c;

printf ("%d", d);

return 0;
}

Input

2 2 4

Output

2 2 4
10

Suggestion

  • Try to apply AdditionSubtraction, MultiplicationDivision in your codes
  • Be advised that 'Order of Operation' is crucial. The relative precedence levels of operators found in many C-style languages are as follows

[Exercise] Essay (Open question) - asked in Chapter 2: Syntax structure of the C language by (5.9k points)
ID: 25725 - Available when: Unlimited - Due to: Unlimited

edited by | 494 views
1 0
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
    int a, b, c, d;
    /* prompt the user
    and read input numbers */
    printf("Input three numbers separated by space: ");
    scanf("%d%d%d", &a, &b, &c);
    //computation itself
    d = a / b * c;
    //print the result
    printf("%d / %d * %d = %d", a, b, c, d);
    return 0;
}
input 2 1 5 output 2 1 5 10

15 Answers

0 like 0 dislike
Hidden content!
* ** * ** ** ** *
* * **
* * b, c,
* * ** %d *** * ** * *** * **
* = + b * ** *
* ****
100/100 answered by (244 points)
0 like 0 dislike
Hidden content!
** * * **** ***
**
*
* * * *


*** ** * ** * ** * * ** * * ****


= ( a + b ) *

* * ***** *** * * **
*
** *
100/100 answered by (449 points)
0 like 0 dislike
Hidden content!
** * *** * * *
*


* * * *


* * ** *** * *** * ** *** * * ***** *


= ** * + *


* ** *** * ** * *


**

}
100/100 answered by (283 points)
edited by
0 like 0 dislike
Hidden content!
* * * ** * * *


**** ** ***


** * ** * * ** ** * * * * *** or * ** * **** ** ** **** or * * ** *


* *** * **** ** {


** * c, d, *


* ** * * ** * **** * * *


**** *** ** %d %d ** * * ** ** *** * *** * * *


* = a + b - c * d;


* * * ** * * ** *


* * ** * ** * ** * * ** ** ** *



* *


**


** ** * 9 2


*
100/100 answered by (221 points)
0 like 0 dislike
Hidden content!
*** * * ** * * * **
* * *
* * * c, *
* *** ***** * %d ***** * **** ** *** **** *
* = a * c + *
* * * * *** **
**
}
100/100 answered by (220 points)
0 like 0 dislike
Hidden content!
* * * * ***
* * * ** *


* b, c, d;


* * ** ** * *** 3 * * * ** * ***** ** * **


** * ***** * ** * * ** * *** * *


** = a + b + *


** * * *** * * * * * ** ***** **


* **** *
*
100/100 answered by (281 points)
1 like 0 dislike
Hidden content!
***** * * **** *

int ** *


** ** a, b, c;


* * *** ** * the * * * *** ** * * * *
** * * ** ****
* **** *** * ** the * *** **** * ** **
* *** ***** ***** *
* ** * * ***** * the * * * * * ** * * ****
** ** *** ** * ********** **** **



opp = a + b * c;


* * ** *** * * ** is = *** * * **


** 0;

}
100/100 answered by (268 points)
1 like 0 dislike
Hidden content!
* *** * *
* *** ** ******* * ****** * * argc, char **** ** {
* * ***** * * * ** a, b, c, d;
** ** ******* *** ** * * the user and read * * * * * *** * *** * * **
** * * * * ** * ** **** ** three ** * * * * by * *
*** ** * * ******* ** * * **** ** *** ******* ** *
**** * ** * * * * **** * * *
** ** ** *** * = a + b * c;
* * ** * **** * ***** the *** **
** ** * ** **** * ******* ** + %d * %d = ** a, b, c, d);
** *** * ** *** * *** 0;
* ** 4 ** 4 2 10
100/100 answered by (273 points)
0 0
Good job
1 like 0 dislike
Hidden content!
**** * * * * * **
* * *** * *** *


* * * ** * ** * ** {
* **** *** a, b, c, d;
* ******** the **
** ** * * * * ** */
* * ** * * * * * * by * * * * ****
** * * * ** * * ***** * * * * * * * * **
* ***** ** * ** * *

d = a - b / c;
** ** the
** * ** * ****** * ** *
****** ** 0;

}


*** *


* 8 2


* *


* 8 2



10
100/100 answered by (290 points)
reshown by
0 0
Nicely done, keep up.
1 like 0 dislike
Hidden content!
**** **** ***
*** * * ** * ** *
*** * * *** * * * * ** {
* a, b, c;
*** *
**** * * */
** *** ** * * ** *** by ** *****
* * * ** * * * **** * *** ****
* ** **** *

c = a + b;
* ** * *
* * **** + %d = * * *
* *
*
**** ** **
* 7
** *
* **
** 7
10
100/100 answered by (269 points)
0 0
Nicely done
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.100.115
©2016-2024

No related questions found

12,783 questions
183,443 answers
172,219 comments
4,824 users