Design an algorithm to accept an array of 5 positive integers. The algorithm must then find the smallest positive integer in the array which cannot be formed from the sum of 2 numbers in the array. For Example - If the input elements are: 5, 3, 2, 6, and 4 Method 1 (look at different methods to solve): 6 can be formed by 2 + 4 (both elements from the array) 5 can be formed by 3 +2 (both elements from the array) 4 cannot be formed by adding 2 elements in the array 3 cannot be formed by adding 2 elements in the array 2 cannot be formed by adding 2 elements in the array The answer is 2 because it is the smallest integer which cannot be formed.
#include int main() { int a,b,c; char ch; do { printf("Enter the 1st No."); scanf("%d",&a); printf("Enter the 2nd No."); scanf("%d",&b); c=a+b; printf(" Sum is =%d",c); printf(" Are you want to continue(y/n)"); scanf("%c",&ch); fflush(stdin); }while(ch=='y'); } My code is not continue. Where is the problem sir?
Love your videos it has helped me a lot in my coding subjects
Really really thank you!!!dude I spent a night to understand this loop,but still not get it ,but after your video,I understand more!! Thanks buddy😭😭
Really happy to know that the video helped you. I wish you a MASSIVE success with your learning. Cheers 👍
Thank you sir, good and clear explanation
Because of this I could use y/n in do while loop.or else their was the same error,thanks man👍
Slove this program .
if I want to input Y or y for continue, it’s will be like this?
}while(C == ‘y’ || C == ‘Y’);
anybody answer me, plz.
yes
can you do it with a basic calculator?
mine stops at (y/n) and when i enter y it says dash 2 y not found
Design an algorithm to accept an array of 5 positive integers.
The algorithm must then find the smallest positive integer in the array which cannot be formed from
the sum of 2 numbers in the array.
For Example -
If the input elements are:
5, 3, 2, 6, and 4
Method 1 (look at different methods to solve):
6 can be formed by 2 + 4 (both elements from the array)
5 can be formed by 3 +2 (both elements from the array)
4 cannot be formed by adding 2 elements in the array
3 cannot be formed by adding 2 elements in the array
2 cannot be formed by adding 2 elements in the array
The answer is 2 because it is the smallest integer which cannot be formed.
Why you are not responding 😭😥😥
Hi Praveen, I'll give it a try when we're teaching arrays. We'll come to arrays shortly. Stay subscribed. Thank you for your patience.
Thank you sir
#include
int main()
{
int a,b,c;
char ch;
do
{
printf("Enter the 1st No.");
scanf("%d",&a);
printf("Enter the 2nd No.");
scanf("%d",&b);
c=a+b;
printf("
Sum is =%d",c);
printf("
Are you want to continue(y/n)");
scanf("%c",&ch);
fflush(stdin);
}while(ch=='y');
}
My code is not continue. Where is the problem sir?