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");
}
#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;
}
#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;
}
x -=y;
#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.
token
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"&even end if
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
k
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
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
int findSmallest(int *list, int listsize) { int i; int smallest = list[0]; for(i = 1; i < listsize; i++) { if(list[i] < smallest) smallest = list[i]; } return smallest; }
$n = 10*(1+10)/2;
see the program
x -=y;
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
1 hour ago my c program said no, but now I know 5 actually is an integer!
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("Enter three decimal numbers: "); scanf("%lf %lf %lf", &num1, &num2, &num3); // Convert and print the trimmed integer values int intNum1 = (int)num1; int intNum2 = (int)num2; int intNum3 = (int)num3; printf("Trimmed integer values: %d, %d, %d\n", 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.
Initialise an unsigned integer to zero. As each number is input, increment the running total accordingly. When all numbers are input, display the total.
smallest individual units of a program