Great teaching method by Neso academy for real learners. Please note preprocessing is done before compiling the code, therefore to get the current time and date by use of __TIME__ and__DATE__ we need to build and run the code each time instead of just running it. Please correct if I am wrong.
Tips 1. Don't add semicolon at the end ; ❌ 2. USE CAPITAL LETTERS 3. We can use functions 4. There are predefined macros like ___TIME___ and ___DATE___ edit: had to add one more _ because TH-cam makes text cursive if you use two __ at the beginning and at the end of a word
For those getting an error for if and else program try this : #include # define max(x,y) if(x>y) \ printf("%d is greater than %d", x,y);\ else\ printf("%d is less than %d",x,y) int main(){ max(5,6); return 0; }
Comment to myself: Review preprocessors. Define constants thru #define or const keyword. Like so, #define NAME value. NAME is also called Macro. We can use Macros like functions. We can use \ for multiple lines. With macros used as functions they expand explicitly, meaning they are injected in the code and then implemented. Macros like functions don't evaluate within itself. There are default macros like __DATE__ and __TIME__
there is an error in #define greater(x,y) if(x>y) \ printf();\else\printf();......................it would be like..#define greater(x.y) if(x>y) printf();\else\printf();
I have a doubt , when you wrote #define add(x, y) x+y , the pre processor is going to replace x+y wherever add(x, y) is written , but when yo wrote add(5, 6) , why did it replaced it to 5+6 , how did it know x,y were variables?
%.5f means it will round off value or you can say that it consider a value up to 5 decimal places after the point for example value of pi = 3.14159265358979323846 if we print using printf("%.5f",pi); then out put will be 3.14159
@@aditisharma5192 %d is a placeholder for variables having integer values, %f is a placeholder for variables having float/decimal values, similarly %s is for strings etc etc check out the prev videos in this playlist for the whole list of placeholders
#include #define ADD(x,y) x+y #define G(u,v) if(u>v)\ printf("%d is greater than %d ",u,v);\ else \ printf("%d is greater than %d ",v,u); #define E(m,n,p) m-n*p #define F(l,m,n) (l-m*n) int main() { printf("addition of two numbers: %d ",ADD(4,3)); G(4,5); G(5,6); printf("result of expression a*b-c*d is :%d and not :%d",5*E(2,3,6),5*F(2,3,6)); //expand expression as is defined by macro ... //...and follow order of precedence to evaluate expression return 0; }
i have combined last two three # concepts in single program.Check it's o/p by compiling & running it on IDE.Mark the difference between expression E and F both will give different output (why?).Can we Use same argument x and y for other macros instead of assigning other variables u,v,m,n,l,p etc.
There is an error in his explanation regarding macro expansion. #define add(x, y) (x + y) is the macro that is defined and then he mentions that the result of printf("result of expression a*b + c is: %d", 5*add(4, 3)) is 23 (because it is 5*4 + 3). This is incorrect as the above macro expands to add(argument1, argument2) = argument1 + argument2 So in the printf statement it becomes 5*add(4, 3) = 5*(4 + 3) = 5*4 + 5*3 = 20 + 15 = 35. Which is consistent with the BODMAS rule. Please keep this in mind.
It's #define add(x,y) x+y Here add(x,y) is name of constant and x+y is its value so add(x,y) is replaced with just x+y not (x+y) So the substituted expression looks like- 5*4+3 so the answer is 23.
Truly speaking... You won't find anything better than this.. 👍
Great teaching method by Neso academy for real learners. Please note preprocessing is done before compiling the code, therefore to get the current time and date by use of __TIME__ and__DATE__ we need to build and run the code each time instead of just running it. Please correct if I am wrong.
The best content one can ever find for c programming... Thanks a ton for the priceless content!
I saw a lot of videos about c language .But this channel deserves that place
your explanation way is so clear, good,understandable
Wow, had no idea you could define functions like that.
Your lectures are really very helpful ...thank you for your efforts
Brilliantly organized!! Thank you to you!
the best lecture on youtube......
I regret I missed your videos 😢
❤ from 🇵🇰
0:12
0:21
2:16
3:01
4:25
5:03
5:36
6:30
8:02
8:23
Best explanation
information overload..idk why we pay so much to colleges.Thankyou sir!!!!!!
excellent information about macros
#include
#define ADD(x,y) x+y
int main() {
int var=3;
printf("addition of two numbers %d
", ADD(3,4));
return 0;
}
sir, I don't know English, but I understand it easily.
Best explanation 💥
Tips
1. Don't add semicolon at the end ; ❌
2. USE CAPITAL LETTERS
3. We can use functions
4. There are predefined macros like ___TIME___ and ___DATE___
edit: had to add one more _ because TH-cam makes text cursive if you use two __ at the beginning and at the end of a word
You can add multiple lines by /
Awesome video sir
Just awesome teaching 👍👍👍
For those getting an error for if and else program try this :
#include
# define max(x,y) if(x>y) \
printf("%d is greater than %d", x,y);\
else\
printf("%d is less than %d",x,y)
int main(){
max(5,6);
return 0;
}
u have used max two times with same letters plzz use capital at any of that one then it will get
Bro at the final of the else statement / is missing and semi colan is also missing
superb! thankyou
Play games..Nahhhh
Watch NESO academy lectures... Yayyyyyy
thanks legend
Super 👌👌
Mass bro
Sir in the first example %5f means after decimal 5 digits will be given as out puts
Sir pls upload array, pointers
+1
Comment to myself: Review preprocessors. Define constants thru #define or const keyword. Like so, #define NAME value. NAME is also called Macro. We can use Macros like functions. We can use \ for multiple lines. With macros used as functions they expand explicitly, meaning they are injected in the code and then implemented. Macros like functions don't evaluate within itself. There are default macros like __DATE__ and __TIME__
thanks
to write mulitple lines, it's not slash but back slash actually. (not the same ^-^)
Your explanations are clear and understandable for a beginner like me . May I know the background music at the end of the video,Sir?
Gold
Sir u r the bestttt
How it is solved?
# define add(s,y) s+y/ s-y
int main(){
printf("%d",5*add(3,7));
can we return values from macro functions...?
What is actually our university doing? They should suggest neso academy and sleep.
thx
Sir what about prefixes and suffixes
dope explanation👌
Thank u
Last lo time date progarm printf lo ℅s anduku icharu time date lo integers kuda vunai kadha
Sir, can't we use that constant value in variables?
date;- 15 july 2023 reached on constant
Nice
Sir while using \ output becomes error .Here in main() printf is not used.
there is an error in #define greater(x,y) if(x>y) \ printf();\else\printf();......................it would be like..#define greater(x.y) if(x>y) printf();\else\printf();
@Nadeem Afzal did t work again
@@sandeshadhikari2889 YES I have also tried
can I get notes for this?
why PI is a float type variable??
I have a doubt , when you wrote #define add(x, y) x+y , the pre processor is going to replace x+y wherever add(x, y) is written , but when yo wrote add(5, 6) , why did it replaced it to 5+6 , how did it know x,y were variables?
x and y are not variables. They are substitution names. Moreover, it should be #define add(x, y) (x+y)
why we need %s to print the current time and current date.what does %s indicates ?is it string specifier or other else
%s indicates that the value is a string of characters
@@manasgoel7351 so why we are not putting string headerfile?
can we place two underscore at a time
Yeah
Why did u use "%s" in predefined macros while the result is decimal
That is %5f which means 5 numbers after point
Sir please provide notes
Why do we use %s at the last program where we use predefined macros
date and time was showing wrong
How Programm knows which data type is defined in macro? we don't mention data type in it: #define PI 3,14...
1:59 does anybody know why it says printf("%.5f", PI) instead of just saying printf("%f", PI)? I mean what's the difference??
%.5f means it will round off value or you can say that it consider a value up to 5 decimal places after the point for example value of pi = 3.14159265358979323846
if we print using printf("%.5f",pi); then out put will be 3.14159
@@dhruvrajkotiya alright, thank you very much!
it means that pi value should be printed 5 decimal values after decimal point
Why he use f instead d like before section he use everywhere %d why here he use f instead of that please answer
@@aditisharma5192 %d is a placeholder for variables having integer values, %f is a placeholder for variables having float/decimal values, similarly %s is for strings etc etc check out the prev videos in this playlist for the whole list of placeholders
How can I define a file?
Sir when you printed the value of PI why did we get a white space after it,you didn't add any
!??
is used for printing the statment in next line
the code at the end doesnot compile on Vs
8:19 my time output is not right , is there away like to modify timezones in c?
Time and date are coming wrong for me🤔
Hlo sir
Multiple lines code is not working in #define it's showing error
Bro i tried in but the out put comes with null
#include
#define ADD(x,y) x+y
#define G(u,v) if(u>v)\
printf("%d is greater than %d
",u,v);\
else \
printf("%d is greater than %d
",v,u);
#define E(m,n,p) m-n*p
#define F(l,m,n) (l-m*n)
int main()
{
printf("addition of two numbers: %d
",ADD(4,3));
G(4,5);
G(5,6);
printf("result of expression a*b-c*d is :%d and not :%d",5*E(2,3,6),5*F(2,3,6));
//expand expression as is defined by macro ...
//...and follow order of precedence to evaluate expression
return 0;
}
i have combined last two three # concepts in single program.Check it's o/p by compiling & running it on IDE.Mark the difference between expression E and F both will give different output (why?).Can we Use same argument x and y for other macros instead of assigning other variables u,v,m,n,l,p etc.
Greater program giving error
Condition is always false
There is an error in his explanation regarding macro expansion. #define add(x, y) (x + y) is the macro that is defined and then he mentions that the result of printf("result of expression a*b + c is: %d", 5*add(4, 3)) is 23 (because it is 5*4 + 3).
This is incorrect as the above macro expands to add(argument1, argument2) = argument1 + argument2
So in the printf statement it becomes 5*add(4, 3) = 5*(4 + 3) = 5*4 + 5*3 = 20 + 15 = 35. Which is consistent with the BODMAS rule.
Please keep this in mind.
It's #define add(x,y) x+y
Here add(x,y) is name of constant and x+y is its value so add(x,y) is replaced with just x+y not (x+y)
So the substituted expression looks like- 5*4+3 so the answer is 23.
Addition programm getting error
When we are getting subtitles , half of the code is can't see.
#define max(x) x*x
please explain printf("%d", max(2+3));
error
as you are not writing 'max' micro correctly in printf(" ").
@@shubhampathak7926 its correct.
I figured out the answer.
its 2+3*2+3 =11.
“Lesser than” is grammatically wrong. Use “less than”.
views = 167500 and likes = 2700 ,,
therefore /// views - likes = 164537
hence 164537 people will go to hell if they doestn't like this video