Soham
https://pastebin.com/wJq302Gd
i also tried using paste bin.. but it's restricting me .. idk why
klimi
i know why
klimi
and it is your link
DaySandBox
Item added: pastebin.com
klimi
you should be able to paste it now
Soham
👍
Soham
Is there a difference between char a[n][m] & char a[][m]? Also why it is not printing garbage when I provide m > my column values like in the second case? Any specific reason? Here 👇 https://pastebin.com/wJq302Gd
Soham
Anyone??
Ammar
Is there a difference between char a[n][m] & char a[][m]? Also why it is not printing garbage when I provide m > my column values like in the second case? Any specific reason? Here 👇 https://pastebin.com/wJq302Gd
a[][m] (the empty size on the front will be filled with exactly how many members you initialize the array). a[n][m] you explicitly mention the size. —————————— The first one prints garbage because you don't have NUL terminated C string, so it will prints everything beyond the array until it finds a NUL char. However the second one, you have a NUL char by implicitly gives a[][6]. See the size 6, if you initialize 5 of it, the rest will be initialized with zero (it's a NUL char). So, another example: char my_str[3] = {'a', 'b', 'c'}; my_str[3] will be unspecified, can be a garbage. But char my_str[100] = {'a', 'b', 'c'}; my_str[3] to my_str[99] will be zero. Conclusion: If you initialize an array partially, the rest will be initialized with zero.
Soham
Thanks..
Soham
i am just curious.. like how to implement such bots on telegram??
Sivaprabu
#REGEX 3 alpha + 3 number must = totally 6 How to validate ?
'''''''
'Write a program to validate a given date and find the next date.' For the above question, is there no better approach than using multiple if-else statements?
'''''''
Sample input: Enter the date 12 Enter the month 12 Enter the year 2000 Sample Output: Date is valid & next date is: 13/12/2000 Sample input: Enter the date 1 Enter the month 13 Enter the year 2000 Sample Output: Month is invalid
'''''''
Multiple if else is fine I think
yeah but its too lengthy
Pavel
yeah but its too lengthy
You can put it into a function to check one day/month/year combination.
Anonymous
#REGEX 3 alpha + 3 number must = totally 6 How to validate ?
should it be in the specific order like, abc123 ?
'''''''
You can put it into a function to check one day/month/year combination.
anyways we would be giving just one input each time but since there r so many conditions to be checked and to be printed, I asked
Pavel
i think at some point you will use if statements, e.g to check if month input <= 12
Is it C or C++? Are you allowed to use standard libraries?
Sivaprabu
should it be in the specific order like, abc123 ?
No random , but three numeric is must ab!123 123qwe a1s2d3 !12@3# #REGEX
Pavel
ask the op.
Oops, missed the target message
'''''''
i think at some point you will use if statements, e.g to check if month input <= 12
not some but all, like u have to check if its a leap year then check if its February or those 30day months or 31 day moths then do the same for no leap years then print what's invalid, then also print the next date, again if the date's already the last date of month, I would have to use if-else statement to add a month so
'''''''
Is it C or C++? Are you allowed to use standard libraries?
C and I'm not sure if we can use libraries but pls suggest some if u know
Pavel
C and I'm not sure if we can use libraries but pls suggest some if u know
There's time.c, but I don't know the details of this library (not a C programmer).
'''''''
What you can do not to check for each specific month is to have array of 12 elements, each element containing days of the month, then you will need only check for February and leap year
Ohh we haven't been taught arrays still and they ask us to do with whatever knowledge we have, anyways I will try the 2 approaches u suggested, thnx
Eturnus
#include<iostream> using namespace std; class complex { float x,y; public: complex(); complex(float a){x=y=a;} complex(float real,float imag) {x=real;y=imag;} friend complex sum(complex,complex); friend void show(complex); }; complex sum(complex c1,complex c2) { complex c3; c3.x=c1.x+c2.x; c3.y=c1.y+c2.y; return(c3); } void show(complex c) { cout<<c.x<<"+"<<c.y<<"i\n"; } int main() { complex A(2.7,3.5); complex B(1.6); complex c; c=sum(A,B); cout<<"A=";show(A); cout<<"B=";show(B); cout<<"c=";show(c); return 0; }
Eturnus
please help
Amy
Have any error or compile fail?
Eturnus
[ERROR] ID 1 returned 1 exit status
kaka
Anyone who can help with coding?
Anonymous
Anyone who can help with coding?
read the rules, after that ask your question and explain where you're stuck..also show your code.
kaka
Ok wait
Aditi s
#include<iostream> using namespace std; class sample { int x; } int main() { sample obj; obj.x=100; cout<<"x="<<obj.x<<endl; }
Aditi s
can anyone explain the output of this above program
Aditi s
and why that output
Ammar
Does that even compile?
Aditi s
no but what function would it do
Pavel
#include<iostream> using namespace std; class sample { int x; } int main() { sample obj; obj.x=100; cout<<"x="<<obj.x<<endl; }
Your x is private, either make it public explicitly, or replace class with struct (to make it public by default)
Pavel
without changing the program,what output might i get? thanks
You can't get output from a program that can't be compiled.
Pavel
If we imagine that we live in a universe where this code is valid, and assuming that the differences with our current universe are not big enough, I would guess the output would be x=100
Aditi s
#include<iostream> int main() { int i=2500,j=3000; cout>>"i+j=">>(i+j)>>endl; return 0; }
Aditi s
Please tell me what errors are there in this
Apk
Please tell me what errors are there in this
Which quiz are you attempting?
z
Please tell me what errors are there in this
- cout is located at namespace std. - Wrong bitwise operator direction. I suggest you before asking this trivial question, try to compile it yourself. I think your compiler is good enough to tell you what is wrong with this code.
Talula
#include<iostream> int main() { int i=2500,j=3000; std::cout<<"i+j="<<(i+j)<<std::endl; return 0; } You don't have a namespace so you need to use std::
Amy
Anonymous
Lol
Aditi s
/get cppbookguide
Anonymous
Maybe someone knows ? Where is error? I would be very grateful 😢
Anonymous
seems all things are correct here :/ but shows on 17line 😩
バレンタインがいない柴(食用不可)
Pavel
Oh, there are soo many things that are not good, like a collection of bad practices. The error itself seem to be in an incorrect struct declaration. But that's not the most interesting thing. It is C++ right? Why do you write it as old-school C? Don't use defines for constants, use constants, compilers are smart enough these days to optimize them. using namespace std; is not a good thing in global namespace. typedef struct METADATA just why? Typedef creates a type alias (it's not used anymore btw, using is used instead), you say that you want METADATA to be alias for struct? struct Metadata(char* username, char* value) did you try to declare a struct or a function? If a function, then struct should not be a return type. You wanted void? Are you sure you want to deal with C-style strings? Why not use std::string?
Pavel
Is it intended to be C code?
Pavel
I noticed using namespace std and assumed it is C++
Pavel
OK, then nevermind the std::string part and the part about using. They are from C++ world
Anonymous
Hi everybody