answersLogoWhite

0


Best Answer

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

int a,b,c,d,g=0,s=0;

a=Integer.parseInt(jTextField1.getText());

b=Integer.parseInt(jTextField2.getText());

c=Integer.parseInt(jTextField3.getText());

d=Integer.parseInt(jTextField3.getText());

if(a>b){

if(b>c){g=a;s=c;}

else{g=a;s=b;}

}

else if(b>c){

if(c>a){g=b;s=a;}

else{g=b;s=c;}

}

else if(c>a){

if(b>a){g=c;s=a;}

else {g=c;s=c;}

}

switch(d){

case 1:JOptionPane.showMessageDialog(this, "the greates no. is"+g);

break;

case 2:JOptionPane.showMessageDialog(this, "the smallest no. is"+s);

break;

default:JoptionPane.showMessageDialog(this," please enter the choice"+"correctly 1 for greatest and 2 for smallest");

}

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;

int main()

{

vector<int> x;

int y;

cout << "Enter 3 numbers: " << endl;

for(int i = 0; i < 3; i++)

{

cin >> y;

x.push_back(y);

sort(x.begin(), x.end());

}

cout << x[0] << " was the lowest number entered!" << endl;

return 0;

}

This answer is:
User Avatar

User Avatar

Wiki User

6y ago

#include<iosys.h>

// return smallest of two numbers

int min (int a, int b) {

return a<b?a:b;

}

// return smallest of three numbers

int min3 (int a, int b, int c) {

return min (min (a, b), c);

}

int main () {

int a, b, c;printf ("Enter 3 numbers:\n");

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

printf ("Smallest number is %d\n", min3 (a, b, c));

return 0;

}

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write c plus plus program that compare 3 integer numbers and print out the smallest one among them?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Write a program to subtract integer y from integer x?

x -=y;


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?

#include&lt;stdio.h&gt; main() { int a,b,c,d; // The four integers to be asked printf("Give the first integer: "); //asks for the first integer scanf("%d",&amp;a); // puts the user input in the address of the integer "a" printf("Give the second integer: "); //same explanations scanf("%d",&amp;b); printf("Give the third integer: "); scanf("%d",&amp;c); printf("Give the fourth integer: "); scanf("%d",&amp;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.


In java What is a smallest individual unit in a program?

token


Write a VB script program to calculate the sum of first 20 even numbers?

dim a(20) as integer dim i as integer dim n as integer private sub command_click() for i 1 to 20 Next i a(i) = inputbox ("enter any no.""no.""0") Next i for i = 1 to 20 print a(i) n=n/i if n mod 2 = 0 then Next i end if msgbox "even numbe"&amp;even end if


Write a program in c that prompt user with following lines add two integers test an integer for odd or even and quit?

write a program in C that prompts the user with the following lines: a) Add two integers c) Compare two integers for the larger t) Test an integers for odd or even q) Quit

Related questions

Write a Shell program to find the smallest number from a set of numbers?

k


Write program that read an integer and display all its smallest factors?

All the smallest factors of a number must be its smallest factor, which for any number is 1, so: loop loop loop print "Enter an integer number: ": input n until num(n) do print "Please enter a number" repeat until n = int(n) do print "Please enter an integer" repeat print "Smallest factor of ":n:" is 1" repeat


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


C program to find only smallest numbers in the given list?

int findSmallest(int *list, int listsize) { int i; int smallest = list[0]; for(i = 1; i &lt; listsize; i++) { if(list[i] &lt; smallest) smallest = list[i]; } return smallest; }


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


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.


What is a token in the context of a C program?

smallest individual units of a program