Code WHIZ
Why do some compiler uses (int main) instead of (void main )
Because for every process that an os do there is an exit code which tells how it behaved . So its good to have return code like 0 which means all went perfectly as indented.and may returns some code if an error occur on to which we can see what is problem
Gulshan
Code WHIZ
Should I use learncpp.com to start cpp i practiced in c now I want to switch to cpp ?
You will have to switch for many topics so dont just blindly follow any one. Else this fine.
@𝑺𝒐𝒃𝒌𝒂
It didn't show any error when i used void main().
It does (using GNU gcc compiler and mingw) and say: "main must return int" Which were you using?
Bharti
https://pastebin.com/dSGS1pTx even after making intersection btw two nodes . iam getting a -1 return value!! any help
Thomas shelby
#include<stdio.h> #include<stdlib.h> main () { int *p = (int*) malloc(sizeof (int)); *p=4; printf("%d", (*p)+++*p++);) } The above code prints the op 9 I can understand this operation is similar to i+++i++ But if I remove brackets from this (*p)+++*p++......ie...*p+++*p++ it prints 4 Why does this happen What's the difference between *p and (*p) Can anyone help
klimi
>*p and (*p) they are the same
Thomas shelby
Then it must print 9 for both the cases nah 1.(*P)+++*p++ 2.*P+++*p++
Thomas shelby
but in that code you have *P and *p , P and p are different variables
No it's the same variable I just made a mistake while typing here
klimi
oh okay
Ammar
>*p and (*p) they are the same
(*p)++ and *p++ are not though.
Thomas shelby
Mmm
Ammar
https://stackoverflow.com/questions/4176328/undefined-behavior-and-sequence-points
klimi
Please dont post offtopic here, if you want to casually chit chat, visit the offtopic group
Pradevel (Pratyush)
#ot
Pradevel (Pratyush)
UB ? 🤔
klimi
Undefined behaviour
Pradevel (Pratyush)
@𝑺𝒐𝒃𝒌𝒂
the same compiler in vs code
Anyway. There are only 2 different types of main signatures in the C++ standard: int main() { /* ... */ } int main(int argc, char* argv[]) {/* ... */ } Then, void return types are incorrect in terms of the C++ standard. Use int as return type of main is good practice as he says above
@𝑺𝒐𝒃𝒌𝒂
Anonymous
Hi guys Any one have cheat sheet for C++ programming languge?
Mr.AL-Aramy
A program that gives you five questions to answer and then calculates the number of correct and wrong answers #include <iostream> #include<string> using namespace std; int main() { string y="t" ,o="T"; string x="f" ,h="F"; int correct=0; int wrong=0; string a,b,c,d,e; cout<<"Does int accept a numeric variable??\n"; cout<<"Choose the answer T/F: ";cin>>a; if (a==y || a==o) { cout<<"Correct"<<endl; correct++; } else { cout<<"Wrong"<<endl; wrong++; } cout<<"\nIs it possible to divide by zero?\n"; cout<<"Choose the answer T/F: ";cin>>b; if (b==x || b==h) { cout<<"Correct"<<endl; correct++; } else { cout<<"Wrong"<<endl; wrong++; } cout<<"\nCan we use function inside function?\n"; cout<<"Choose the answer T/F: ";cin>>c; if (c==y || c==o) { cout<<"Correct"<<endl; correct++; } else { cout<<"Wrong"<<endl; wrong++; } cout<<"\nIs the first index in the array 0?\n"; cout<<"Choose the answer T/F: ";cin>>d; if(d==y || d==o) { cout<<"Correct"<<endl; correct++; } else { cout<<"Wrong"<<endl; wrong++; } cout<<"\nCan the son's class inherit from the father's class if the father's class is privet?\n"; cout<<"Choose the answer T/F: ";cin>>e; if(e==x || e==h) { cout<<"Correct"<<endl; correct++; } else { cout<<"Wrong"<<endl; wrong++; } cout<<"\nThe number of Correct awnser is: "<<correct<<endl; cout<<"The number of Wrong awnser is: "<<wrong<<endl; if (wrong==5) cout<<"Are you stupid??!!\n"; else if(correct==5) cout<<"You are so smart!!!\n"; else if(correct>wrong) cout<<"You are good. *Perfect*\n"; else cout<<"Study hard. *Good luck*\n"; }
Anonymous
Hi guys, I am learning bootloader for s32k144, anyone has any link to study that.
Golden Age Of
Oh my hella god, what a monster
Anonymous
can you 1) delete this wall of text, 2) go to godbolt.org, 3) paste the code, 4) use godbolt's code formatter to auto-format the code, 5) share a link to your code on godbolt.
Anonymous
alternatively, you can format the code on your local system and then paste it to wandbox.org and post a link to your code on wandbox
Anonymous
website for c++ practice and problems from zero till the end ?
Anonymous
website for c++ practice and problems from zero till the end ?
doesn't really exist. try the books mentioned in stackoverflow (command available in pinned post here)
Anonymous
and even then, books will only make you a master of the language itself. between that and actually being able to write/understand large programs/codebases is a huge gap.
Anonymous
so how can i practice from level zero problems till advanced step by step??
Anonymous
thx i appreciate it
zn
hello can anyone help me to solve my assigment
Adrian
hello can anyone help me to solve my assigment
https://t.me/programminginc/283193
z
*Put away your homework GIF*
Anonymous
what setprecision do in c++?
VENUJAN
#include <stdio.h> int main(){ int x = 0 ; while (x <= 10){ printf("hello \n"); x+=1; } //dcsdc while (x <= 5 ){ printf("x is %d \n",x); x++; } }
VENUJAN
i wrote this code but got only this output
VENUJAN
hello hello hello hello hello hello hello hello hello hello hello
VENUJAN
why i couldn't get the output for printing numbers?
VENUJAN
there was no any errors showing!
klimi
Say out loud what your program does
klimi
It prints 10x hello word, and then it prints 5-x times hello + number
VENUJAN
Say out loud what your program does
i can send screenshot so u can
klimi
But the x is greater that 5, so that's why it's not printed
'''''''
#include <stdio.h> int main(){ int x = 0 ; while (x <= 10){ printf("hello \n"); x+=1; } //dcsdc while (x <= 5 ){ printf("x is %d \n",x); x++; } }
The first while loop changes the value of x, and when u exit the loop, the value of x is 11, so it doesn't satisfy the second while loop condition
klimi
i can send screenshot so u can
What screenshot? You have already sent the code
VENUJAN
But the x is greater that 5, so that's why it's not printed
okok .... i got it . i wanted to put this code above
VENUJAN
thanks
klimi
Np
class Person(Skills): name = str("Ankush Bhagat")
why i couldn't get the output for printing numbers?
#include <stdio.h> int main(){ int x = 0 ; while (x <= 10){ printf("%d hello \n", x); x+=1; } }
class Person(Skills): name = str("Ankush Bhagat")
Added %d --> for 1st while loop which contains hello for 10x
class Person(Skills): name = str("Ankush Bhagat")
If want to print with 1 to 11 then edit " x=0; to x=1;
Anonymous
Mr.AL-Aramy
why i couldn't get the output for printing numbers?
#include <stdio.h> int main(){ int x = 0 ; while (x <= 10){ printf("hello \n"); x+=1; } printf("x is %d \n",x); x++; }
Mr.AL-Aramy
#include <stdio.h> int main(){ int x = 0 ; while (x <= 10){ printf("hello \n"); x+=1; } //dcsdc while (x <= 5 ){ printf("x is %d \n",x); x++; } }
The problem here that you did while loop and let the condition about the x and said while x less or equal 5 then do what is required inside brackets but in fact x not less or equal 5, after the first while loop x will be equal 11 so the condition inside second while loop will be wrong
Lunatic
Hi anybody can suggest a book for c++
Anonymous
Hi anybody can suggest a book for c++
The C++ Programming Language by Bjarne Stroustrup
Anonymous
Hello everyone. The firstly I'm Oybek, from Uzbekistan and I want to learn c programming so where i can learn it better? Could you give some advace?
Anonymous
I mean in which country
Anonymous
There are many books that you can buy to study or use the documentation (free)...