Sir I understood all the previous topics in this Playlist but only this topic is difficult to understand. Please explain sum and carry variables and which value is exactly stored in them.
Actually Half Adder is a concept of digital electronics, so you'll have to be somewhat familiar with it, you must know what are binary digits and how they are added inside the computer because as you know the computer understands binary digits (0,1) only and in Digital Electronics we deal with bits.
@@ezhilv4358 #include #include int main() { int n,num; int large1=0,large2=0; clrscr(); printf("Enter no. of numbers: "); scanf("%d",&n); printf("Enter %d numbers, one by one: ",n); while(n>=1) { scanf("%d",&num); if(num > large1) { large1=num; } if(num > large2 && num < large1) { large2=num; } n--; } printf(" The largest number entered is %d",large1); printf(" and the second largest one is %d",large2); getch(); return 0; }
The left shift and right shift operators should not be used for negative numbersIf any of the operands is a negative number, it results in undefined . Sir can you please clear this point when you entered the negative numbers how it is giving the correct answer.
See 2,s complement representation of numbers. Subtracting a number is same as adding 2's complement of the number. Therefore, it works for negative numbers also.
int main() { int n,a; printf("Enter two number "); scanf("%d%d",&n,&a); int sum=n; for(int i=1;i=0) sum++; else sum--; } printf("The sum of %d and %d is : %d",n,a,sum); return 0; } This does the same.
/*This is my version of the program */ //Adding two integers without the + sign : #include int main() { printf("Give a and b "); int a, b,i; scanf("%d %d",&a,&b); if (b>=0) { for (i=0; i
Idea is Take a number like 2*3.so what we have to do is add a=2 ,b=3 times 2+2+2 the answer will be six That means we have to add the same number to itself upto b=3 times
4:20 I guess those equations wont give proper ans everytime Bec, When you do 5+10 in binary, the ans is 15 in which sum is 15 while carry is 0 But, When you do 7+2 in binary, the ans is 9, but the sum you get using Xor is 5 while the Carry you get using Bitwise And is 2, and lets say even if you add that 5 with 2 also, still you get the Sum using Xor as 7 and Carry using Bitwise And as 0, and now you aren't left with any further carries found using Bitwise And in order to add it up with the Sum we found using Xor i.e. 7!!!
if you give b=0 then the program will give you garbage value . Solution-----inspite of printing value of sum if we print value of a then this posibilty of garbage value will be solved as a=sum and also if b=0 then sum=a. Explanation----if we give b=0 then the controll will not enter in while loop as 0!=0 is false. so if we print value of sum it will give you garbage as sum is not initialized .
You can also use 'do-while' loop... for y=0, do-while loop will execute at least once and you can write the printf statement as printf("The sum is :%d",sum); Hope it will help...
Sir, I am currently learning C programming from your lectures. May I ask you about a problem in the half adder code? The code works totally fine in all situations accept one case: when b is 0(it produces result 0 whatever a is). I think the bug can be fixed by using the variable "a" in printf(And not "sum"). Thank you, sir. I hope it might help.
I did like this 👇 #include int main() { //adding two values without using "+"" operator int x, y; printf("Enter any two numbers: "); scanf("%d %d",&x, &y); for (int i=0; x!=0; i++) { if(x
a-(-b) krlo guru bina + ke kara doonga. Thanks garry shashank for this wonderful explaination
Thank u brother for making me understand in a simple way
Very neat clean vivid explanation with step by step solution programming made easy!
Bro I want to know the code for finding 2nd highest no. In a given integer..example 56879 in this value we have to find the 2nd highest no.
After the loop, assign sum = a; before printf just incase b = 0;
Sir I understood all the previous topics in this Playlist but only this topic is difficult to understand. Please explain sum and carry variables and which value is exactly stored in them.
Actually Half Adder is a concept of digital electronics, so you'll have to be somewhat familiar with it,
you must know what are binary digits and how they are added inside the computer because as you know the computer understands binary digits (0,1) only and in Digital Electronics we deal with bits.
If you learn binary addition and subtraction and then watch this video again, I'm sure you'll understand the concept given here.
Your lectures are very helpful for my classes. Thank you very much!!!
I think there's an error. If you enter b = 0, it'll print garbage value as the output. You didn't consider that possibility?
yes inspite of printing value of sum if we print value of a then this posibilty of garbage value will be solved
@@ProgrammingwithArijit
Super
Why everyone here is happy? I didn't understand anything from this lesson. It's extremely hard!
Mast Sir, Vedios so helpful for us,we all proud of you sir😘😘😘
Bro I want to know the code for finding 2nd highest no. In a given integer..example 56879 in this value we have to find the 2nd highest no.
@@ezhilv4358
#include
#include
int main()
{
int n,num;
int large1=0,large2=0;
clrscr();
printf("Enter no. of numbers: ");
scanf("%d",&n);
printf("Enter %d numbers, one by one: ",n);
while(n>=1)
{
scanf("%d",&num);
if(num > large1)
{
large1=num;
}
if(num > large2 && num < large1)
{
large2=num;
}
n--;
}
printf("
The largest number entered is %d",large1);
printf(" and the second largest one is %d",large2);
getch();
return 0;
}
The left shift and right shift operators should not be used for negative numbersIf any of the operands is a negative number, it results in undefined .
Sir can you please clear this point when you entered the negative numbers how it is giving the correct answer.
See 2,s complement representation of numbers. Subtracting a number is same as adding 2's complement of the number. Therefore, it works for negative numbers also.
Thank you so such detailed explanation
Sir make one video please minus numbers. how to write binary.
This program you write only positive binary number. Thank you sir
i lub ur videos...clear explanation
why you are not using a-(-b), this is the very simple logic
That's y they are not using bro;)
@@vijayclasher6876 🤣
Too simple to be thought about 😂
thanks sir
int main()
{ int n,a;
printf("Enter two number
");
scanf("%d%d",&n,&a);
int sum=n;
for(int i=1;i=0)
sum++;
else
sum--;
}
printf("The sum of %d and %d is : %d",n,a,sum);
return 0;
}
This does the same.
Super explanation.
Bro I want to know the code for finding 2nd highest no. In a given integer..example 56879 in this value we have to find the 2nd highest no.
/*This is my version of the program */
//Adding two integers without the + sign :
#include
int main()
{
printf("Give a and b
");
int a, b,i;
scanf("%d %d",&a,&b);
if (b>=0) {
for (i=0; i
Awesome explaination..👏👏👏
Sir also add some topics on Power System Analysis and Control System
Sir please explain logic for multiplication operations with using *operator
Idea is
Take a number like 2*3.so what we have to do is add a=2 ,b=3 times
2+2+2 the answer will be six
That means we have to add the same number to itself upto b=3 times
previous program can add negative integers also
Sir we can write one while loop for addition of two no. In that while we can we if .else
nice
What about a = b - (0-c)?
You can use this one instead a = b - (-c)
Without the 0
given numbers in decimal format,then why we do not convert these numbers in binary format
You should have explained the logic of the program by using -ve values too.
4:20
I guess those equations wont give proper ans everytime
Bec,
When you do 5+10 in binary, the ans is 15 in which sum is 15 while carry is 0
But,
When you do 7+2 in binary, the ans is 9, but the sum you get using Xor is 5 while the Carry you get using Bitwise And is 2, and lets say even if you add that 5 with 2 also, still you get the Sum using Xor as 7 and Carry using Bitwise And as 0, and now you aren't left with any further carries found using Bitwise And in order to add it up with the Sum we found using Xor i.e. 7!!!
Bro I want to know the code for finding 2nd highest no. In a given integer..example 56879 in this value we have to find the 2nd highest no.
convert the int to string and then loop it all to get whatever value you want. I can also give you the code if u ask.
@@shishankrawat2105 can you send the code?
What to do if i am unable to understand
AWESOME
if you give b=0 then the program will give you garbage value .
Solution-----inspite of printing value of sum if we print value of a then this posibilty of garbage value will be solved as a=sum and also if b=0 then sum=a.
Explanation----if we give b=0 then the controll will not enter in while loop as 0!=0 is false.
so if we print value of sum it will give you garbage as sum is not initialized .
You can also use 'do-while' loop... for y=0, do-while loop will execute at least once and you can write the printf statement as
printf("The sum is :%d",sum);
Hope it will help...
If we enter b=0 in half adder program, it prints garbage values
Nope it doesn't, I tried
Sir, I am currently learning C programming from your lectures. May I ask you about a problem in the half adder code?
The code works totally fine in all situations accept one case: when b is 0(it produces result 0 whatever a is).
I think the bug can be fixed by using the variable "a" in printf(And not "sum").
Thank you, sir. I hope it might help.
How to add -5 and -6 ??
while(m!=0){
if(m>0){
n++;
m--;
}
if(m
//Adding two integers without the + sign :
#include
int main()
{
printf("Give a and b
");
int a, b,i;
scanf("%d %d",&a,&b);
if (b>=0) {
for (i=0; i
without using +
uses 2 + lmaooo
What's the use of this concept in real world?
Who the fuck disliking these exiting educational videos 😡😡😡
x -= -y; 😂 without + operator
wow, I actually got carried away with the course and forgot that it can be this simple.
I did like this 👇
#include
int main()
{
//adding two values without using "+"" operator
int x, y;
printf("Enter any two numbers: ");
scanf("%d
%d",&x, &y);
for (int i=0; x!=0; i++)
{
if(x
Thank u