answersLogoWhite

0


Best Answer

#include<stdio.h> main() { int a,b,c,d; // The four integers to be asked printf("Give the first integer: "); //asks for the first integer scanf("%d",&a); // puts the user input in the address of the integer "a" printf("Give the second integer: "); //same explanations scanf("%d",&b); printf("Give the third integer: "); scanf("%d",&c); printf("Give the fourth integer: "); scanf("%d",&d); printf("1. The sum of the four integers is: %d",a+b+c+d); //prints the sum of the four integers given by the user, notice the "a+b+c+d" at the end) printf("2. The sum of the first two numbers minus the sum of the last: %d",a+b-c-d); //prints the second condition by putting the correct operations return 0; //ends the program } I never tested this program though, but i think it would work.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a C program that will ask the user for 4 integer values and then produce the following output 1 The sum of the four numbers 2 The sum of the first two numbers minus the sum of the las?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you find sum of 100 numbers using fortran programme?

The following is for F95 and later (due to the use of intrinsic SUM ): My assumptions: -Your numbers are integers -Your numbers are stored in an array -The numbers you are describing are 0-100 program findSum !I assumed integer, replace this with your data type integer, dimension(100) :: numbers integer :: sumOfNumbers !We populate an array with our numbers !Replace this with your numbers do i=1,(size(numbers)+1) numbers = i end do !We find the sum of those numbers sumOfNumbers = sum(numbers) !We write out the sum to prompt write(*,*) 'Sum is: ', sumOfNumbers end program findSum


How write a java program to generate random numbers in between 0-100 and print only the odd numbers?

Use a pseudo-random number generator to produce random integers. To determine if a given integer is odd or even, use the following functions: bool is_odd (int x) { return x%2; } bool is_even (int x) { return !is_odd (x); }


Write a program to compute the sum of first ten integer numbers in PHP?

$n = 10*(1+10)/2;


What is the code of a c program that will read in a positive integer value and determine If the integer is a prime number and If the integer is a Fibonacci number?

see the program


Write a program to subtract integer y from integer x?

x -=y;


What happens when java program attempts to divide one integer by another?

In that case, unless you specifically convert ("cast") at least one of the numbers to a double or float, the result will also be an integer. Example: 1 / 3 = 0


write simple program to solve the following problems : add the following numbers = 10,222,99,999,74,532?

A+(B+C**3) (A-(+D+B/A+B)


Is -5 a integer?

1 hour ago my c program said no, but now I know 5 actually is an integer!


Write a C program that prompts the user for three decimal numbers and prints them trimmed as integer values. For example, if the user informs the values 13.2, 12.5, 102.231, the program prints out 13, 12, 102?

Here's a simple C program that prompts the user for three decimal numbers, converts them to integers, and prints the trimmed integer values: c Copy code #include int main() { double num1, num2, num3; // Prompt the user for three decimal numbers printf(&quot;Enter three decimal numbers: &quot;); scanf(&quot;%lf %lf %lf&quot;, &amp;num1, &amp;num2, &amp;num3); // Convert and print the trimmed integer values int intNum1 = (int)num1; int intNum2 = (int)num2; int intNum3 = (int)num3; printf(&quot;Trimmed integer values: %d, %d, %d\n&quot;, intNum1, intNum2, intNum3); return 0; } In this program: We declare three variables num1, num2, and num3 to store the decimal numbers entered by the user. We use printf to prompt the user to enter three decimal numbers. We use scanf to read and store the user's input in the variables num1, num2, and num3. We then convert these decimal numbers to integers by casting them using (int) and store them in intNum1, intNum2, and intNum3. Finally, we use printf again to print the trimmed integer values. Compile and run the program, and it will prompt you for three decimal numbers and print their trimmed integer values as requested.


What is the program to find sum of n natural numbers in c plus plus?

Initialise an unsigned integer to zero. As each number is input, increment the running total accordingly. When all numbers are input, display the total.


How to draw Raptor flow chart for prime number?

Raptor is a program used for script writing and can be used to make flowcharts. Creating a flow chart for determining prime numbers can be done by writing a code that outlines the rules of prime numbers such as dividing by any integer other than the number itself and 1 to get an integer with a remainder.


How do you sort numbers in Java program?

Here's simple example to sort numbers in Java using a List: import java.util.ArrayList; import java.util.Collections; import java.util.List; public class SortTest { public static void main (String[] args) { List&lt;Integer&gt; list = new ArrayList&lt;Integer&gt;(); list.add(100); list.add(1); list.add(24); list.add(3); System.out.println(list); Collections.sort(list); System.out.println(list); } } Running it generates the following output: [100, 1, 24, 3] [1, 3, 24, 100]