Question:
Write a program that prompts the user to enter two values and display the total value of numbers like output sample.
Output Sample:
Input | Output |
3 | |
1 1 5 3 9 3 | Total is: 0.00 Total is: 8.00 Total is: 216.00 |
Source Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
#include<stdio.h> #include<math.h> main() { int i, n; float a, b, result; scanf("%d", &n); for(i=1; i<=n; i++) { scanf("%f %f", &a, &b); result = pow(a,3)-3*(a*a)*b+3*a*(b*b)-pow(b,3); printf("Total is: %.2f\n",result); } return 0; } |
List of C Exercises:
- Sum of two integer numbers
- Arithmatic calculation
- Average calculation
- Square root of a number
- Celsius to Fahrenheit convert
- Centimter to feet convert
- Square, Cube solution
- Reverse your number
- Find out bigger number
- Find Factorial of a Number
- Integer Number count
- !1+!2+!3+!4+!5…..!n Factorial sum
- Positive or Negative number
- Generate Multiplication Table
- Even or Odd number
- Calculate Power of a Number
- Grading Marks using Switch Case
- Basic Calculator using if-else
- Basic Calculator using Switch Case
- Count your day using switch case
- Leap year counting
- Print Half pyramid using star
- Print half pyramid using numbers
- Print Inverted Half pyramid using star
- Print Inverted Half pyramid using numbers
- Print full pyramid using star
- Print Inverted full pyramid using star
- Print Floyd’s Triangle pyramid
- Print hollow square star pattern
- Print rhombus star pattern
- Print hollow pyramid using star
- Check Vowel or consonant character
- Uppercase and Lowercase English Alphabets prints
- Check Palindrome number
- Fibonacci Sequence display