It is a good idea to think of your PC as an office. It stores files, programs, pictures. This can…
Microsoft has disclosed the first details of Windows 10 – its next operating system (OS). Microsoft announced details of the new…
Program to accept five integer values from the user and calculate the sum, product, average, highest value and lowest value.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
#include <stdio.h> int main (void) { int a, b, c, d, e, sum, prod, ave; printf("Enter five integer numbers: "); scanf("%d%d%d%d%d", &a, &b, &c, &d, &e); sum = a + b + c + d + e; printf("\n\nSum is %d\n", sum); prod = a * b * c * d * e; printf("Product is %d\n", prod); ave = (a + b + c + d + e) / 5; printf("Average is %d\n", ave); /*calculate for highest number*/ if (a > b && a > c && a > d && a > e){ printf("Highest number is %d\n", a); } else if (b > a && b > c && b > d && b > e){ printf("Highest number is %d\n", b); } else if (c > a && c > b && c > d && c > e){ printf("Highest number is %d\n", c); } else if (d > a && d > b && d > c && d > e){ printf("Highest number is %d\n", d); } else if (e > a && e > b && e > c && e > d){ printf("Highest number is %d\n", e); } else { puts ("One or more numbers are equal.\n"); } /*calculate for lowest number*/ if (a < b && a < c && a < d && a < e){ printf("Lowest number is %d\n", a); } else if (b < a && b < c && b < d && b < e){ printf("Lowest number is %d\n", b); } else if (c < a && c < b && c < d && c < e){ printf("Lowest number is %d\n", c); } else if (d < a && d < b && d < c && d < e){ printf("Lowest number is %d\n", d); } else if (e < a && e < b && e < c && e < d){ printf("Lowest number is %d\n", e); } else { puts ("One or more numbers are equal.\n"); } return 0; } |
Below…
The program below separates the digits of a five-digit number using C programming language.Question: Write a program that inputs one…
A simple C program to add two integer numbers.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#include <stdio.h> int main (void) { int x, y, z; x = 5; y = 52; z = x + y; printf("\n\nx = 5 \ny = 52 \n"); printf("z = x + y = %d", z); return 0; } |
Question: Write an application that displays a checkerboard pattern, as follows:
1 2 3 4 5 6 7 8 9 |
public class CheckerboardPatternOfAsterisks { public static void main (String [ ] args) { System.out.print("********\n ********\n********\n ********\n" + "********\n ********\n********\n ********\n"); } } |
Note that this program can also be written using eight System.out.println…
The program below separate digits in an integer using Java. It is the solution to Deitel’s Java How to Program…
Below is a simple program to compare two numbers using Java. It is the solution to Deitel’s Java How to…
Simple Java program that performs arithmetic. The program is the solution to Deitel’s Java How to Program (9th Edition) Chapter…
Simple Java GUI Calculator that performs basic mathematical calculations (addition, subtraction, multiplication and divide). In addition, it can calculate the…
Below are links to the solutions to Deitel’s Java How to Program (9th Edition) exercises that have been posted so…
The program below print numbers on the screen using Java. It is the solution to Deitel’s Java How to Program…