1. Read the 3 nos a,b,c
2. Let larget = a
3. if b > largest then largest = b
4. if c > largest then largest = c.....
If you have to process more nos, read all of them in an array. Assume the first element be largest, do comparison through all elements of the array....
Similar algorithm can be developed for finding the lowest also.
/*lab practice 2 damithguruge question 4 */
#include<stdio.h>
int main()
{
int num1,num2,num3,num4;
int smallest;
printf("Please enter a number1");
scanf("%d%*c", &num1);
printf("Please enter a number2");
scanf("%d%*c" ,&num2);
printf("Please enter a number3");
scanf("%d%*c", &num3);
Printf("Please enter a numbe4r");
scanf("%d%*c", &num4);
/* num1 set as the smallest */
smallest=num1;
if(smallest > num2) then
smallest=num2;
else
if smallest >num3 then
smallest=num3;
else
if smallest>num4 then
smallest=num4;
printf("smallest number:%d\n,smallest");
return(0);
endif
endif
endif
}
please give me an algorithm and a corresponding flow chart that displays list of numbers from 1 to 20.
1. Design an algorithm to compute sum of the squares of n numbers?
An algorithm is a stepwise sequence of operations that can be performed to solve a problem. The operations are expected to be 'simple', so they can be performed mechanically.A simple example algorithm is "how to find the largest number in a list of numbers":- look at the first number and write it down as the largest-so-far- for each remaining number in the list:- - replace largest-so-far with this number if this number is larger- when you have compared all the numbers, largest-so-far is the largest number in the listA less trivial algorithm is the one people learn in school for multiplying multi-digit numbers, called "long multiplication" or "grade-school multiplication". It becomes rather long if you write down all the steps (as you would need to for an algorithmic description), but it involves multiplying each digit in the first number with each digit in the second number and summing the partial results.Here the simple operation is multiplying two single digits, which you are expected to know how to do, and by using the algorithm you can extend the knowledge of how to multiply single digits to multiply numbers with any number of digits.See related links.
jgfujtf
Perhaps you mean an automorphic number? Loop through a series of numbers - for example, all numbers from 1 to 10,000 - and check each of the numbers, whether the condition applies. The condition in this case is that if you square the number, the last digits represent the original number.
You can write out this algorithm. This will then be programmed into the device to make determining prime numbers easier.
Max = 0For K = 1 to NIf Number(K) > Max then Max = Number(K)Next KPrint Max
1.Start Algorithm 2.Enter first number 3.Enter second number 4.Enter third number 5.Enter fourth number 6.Enter fifth number 7.Add five number 8.display five number / 2 9.Display result 10.End Algorithm
maybe
please give me an algorithm and a corresponding flow chart that displays list of numbers from 1 to 20.
1. Design an algorithm to compute sum of the squares of n numbers?
An algorithm is a stepwise sequence of operations that can be performed to solve a problem. The operations are expected to be 'simple', so they can be performed mechanically.A simple example algorithm is "how to find the largest number in a list of numbers":- look at the first number and write it down as the largest-so-far- for each remaining number in the list:- - replace largest-so-far with this number if this number is larger- when you have compared all the numbers, largest-so-far is the largest number in the listA less trivial algorithm is the one people learn in school for multiplying multi-digit numbers, called "long multiplication" or "grade-school multiplication". It becomes rather long if you write down all the steps (as you would need to for an algorithmic description), but it involves multiplying each digit in the first number with each digit in the second number and summing the partial results.Here the simple operation is multiplying two single digits, which you are expected to know how to do, and by using the algorithm you can extend the knowledge of how to multiply single digits to multiply numbers with any number of digits.See related links.
Step1- Read a,b,c. Step2-if a>b continue step 5. Step3- b>c then print “b is the largest " and continue step 7. Step4- continue step 6 Step5-if a>c then print “a is the largest " then continue step7. Step6- print “z is largest". Step7- end.
874321 is the largest number made from all these digits.
jgfujtf
Read 2 numbers. If first is larger than second, display second, else display first. That's for the smallest. For the largest reverse the two. For each of the other two, it's easier to just create a variable, call it largest. Initialize it to a very small number, say -1. As you read each number, compare it to largest. If the number is larger than largest, set largest equal to the number. When you finish each list of numbers, then print largest. Best answer Read 2 numbers. If first is larger than second, display second, else display first. That's for the smallest. For the largest reverse the two. For each of the other two, it's easier to just create a variable, call it largest. Initialize it to a very small number, say -1. As you read each number, compare it to largest. If the number is larger than largest, set largest equal to the number. When you finish each list of numbers, then print largest.
Perhaps you mean an automorphic number? Loop through a series of numbers - for example, all numbers from 1 to 10,000 - and check each of the numbers, whether the condition applies. The condition in this case is that if you square the number, the last digits represent the original number.