นะวู
Does anyone knows how to use loop and nested loop on c programming?
นะวู
Seriously?
How to differentiate loop & nested loop from how they used?
Talula
How to differentiate loop & nested loop from how they used?
Nested loop simply means loop within a loop... like if you have a loop that is changing the value of some array and you want to check it with other array, you use nested loop.
Talula
Loops could be "for" or "while"... people can use goto loop in C but it is not used much or almost at all.
i
How to differentiate loop & nested loop from how they used?
generally nested loops are not so encouraged.As Tazz explained, unless you want to change value and require to keep track with.
i
https://quickref.me/
Pavel
generally nested loops are not so encouraged.As Tazz explained, unless you want to change value and require to keep track with.
Not sure what you mean by "not encouraged", they increase complexity but some algorithms require them
i
Not sure what you mean by "not encouraged", they increase complexity but some algorithms require them
yes I too meant along the lines of complexity. Like in context of time complexity.i concur some context definitely needs nested loops.
Unknown man
Can someone explain what does this question means
Unknown man
Define a function to input variable length string and store it in an array without memory wastage.
Pavel
Define a function to input variable length string and store it in an array without memory wastage.
"input variable length string" probably means that a user should type a string and your program should read it. Without memory wastage means that you need to use no more memory than required to store the string (length + 1). So you can't just allocate a buffer of 10000 chars and store the string in that buffer.
Unknown man
Btw this question come under DMA can u suggest how to solve this because i have just started dma
Void
7 3 1 2 3 4 5 6 7
Void
I wonder how to input this
Jonathan
7 3 1 2 3 4 5 6 7
read by line or read by char and skip space and \n
Void
read by line or read by char and skip space and \n
int x,y,a[10],i; scanf("%d",&x); scanf("%d",&y); for(i=0;i<10;i++) { scanf("%d",&a[i])!=EOF; } can i write like this
Void
But it doesn't seem to work
Void
https://onlinegdb.com/eBPdFwrHj
Void
Guys can you see whats wrong with my code🥲
Pavel
Guys can you see whats wrong with my code🥲
First of all, it doesn't compile, crashes, or produces wrong result?
Pavel
Or formatted incorrectly, or not perforant enough, or...?
Void
just not output correct answer
Pavel
just not output correct answer
Ok, what is data that you provide to it, expected answer, and what does it output instead?
Void
Ok, what is data that you provide to it, expected answer, and what does it output instead?
Like when i input 2021 11 11 it should output 4,but it's 5
Void
I don't know what part is wrong
Talula
Void
Can't edit it.
Clicking on fork this in the top left corner might help?
Talula
Clicking on fork this in the top left corner might help?
Thank... cool... didn't know that...
Pavel
https://onlinegdb.com/eBPdFwrHj
You set m[2] = 29; if at least one of the years from 2000 to the given year passed the condition for the leap year? Is that correct? In this condition you divide month index by 400 if (((year % 4 == 0 && year % 100 != 0) || (i % 400 == 0)) then you account for the leap year one more time the next line these three things don't feel correct
İbn
Print the contents of the iostream library using pointers ?
N
If you're doing in cmd line then knowing any TUI library would help in creating an UI with cooler interfaces.
Could you tell me more about tui or ui it's my first time hearing those terminology
MᏫᎻᎯᎷᎷᎬᎠ
How this code does not produce UB? Value is destructed before Ref which holds a reference to it But it still prints in Ref destructor struct Value{ int value; Value(int value) : value{value}{} ~Value(){ std::cout << "Value: " << value << " Out\n"; } }; struct Ref{ Ref(Value& r) : my_ref{r}{} Value& my_ref; ~Ref(){ std::cout << "Ref: " << my_ref.value << " Out\n"; } }; struct S{ Ref ref{value}; Value value{10}; }; int main(){ S s; return 0; }
İbn
Whot
Can you do it ?
İbn
The solution
\Device\NUL
Huh ?
İbn
Huh ?
Contents
\Device\NUL
*Confused nickyoung
Jonathan
u wish to get pointer that wrapped by iostream and manipulation the raw data?
İbn
u wish to get pointer that wrapped by iostream and manipulation the raw data?
I wanna contents the (iostream) Library using pointers !
Евгений
Guys, who has a book about masm64 with C++, please share. Sometimes it's better to use C++ with masm64.
DaviChan
when it runs,the result is undefined
Yes undefined by the standard. On an actual machine, with a concrete compiler, the result is deterministic
DaviChan
or deterministic is the wrong word I think... to put it simply: you can know what the result will be on an actual machine
MᏫᎻᎯᎷᎷᎬᎠ
MᏫᎻᎯᎷᎷᎬᎠ
Undefined behavior means it is not defined it the standard. It doesnt mean it wont compile or run
I know But isn't supposed to be a reference dangling there? The destruction starts in reverse order of member fields
Anonymous
I know But it prints the value in Ref destructor which is 10
The value that ref refers to will still exist in the stack since main is the only function executing. The stack is not clobbered. So the reference to this value may still print 10 as the value 10 is still in the stack. It is Undefined Behavior nevertheless.
Anonymous
or deterministic is the wrong word I think... to put it simply: you can know what the result will be on an actual machine
No. That is not what Undefined Behavior means. There is no way for you to predict the output of a program that exhibits Undefined Behavior. It may exhibit the same behavior sometimes and could behave totally unpredictably at other times.
Anonymous
nt checkIncreasing(int * array, int arrayLength) { // todo int i; for(i = 0; i < arrayLength - 1; i++){ if(array[i - 1] >= array[i + 1]){ return 1; } else if(array[i - 1] < array[i + 1]) return 0; }
Resul
struct Word *words[size]; addStruct(){ words[counter++] = createWord(isims...); } emptyStruct{ //In this method, I want to empty this struct(words). } In C, How can I get memory space for this Struct(words) in emptyStruct method.
Anonymous
do you see anything wrong here? and why isn't i starting by 0?
so i want to compare an element in the array with the one in the previous position but when i started with if(array[i] >= array[i + 1], the function didn't start by 0.
Anonymous
when i =0,array[i-1] out of bound
yes but i is not equal to 0 because it worked like that. and that's the question, why isn't it 0 and out of bound?
Jonathan
How?
sorry i'm wrong. in empty method,u can use counter to make a for loop,each time u can use word[index] to delete data
DaviChan
No. That is not what Undefined Behavior means. There is no way for you to predict the output of a program that exhibits Undefined Behavior. It may exhibit the same behavior sometimes and could behave totally unpredictably at other times.
That is what it means when we tall about the standard. But in practice you can almost always predict the outcome of a program when you know the exact compiler/architecture and how the program executed last time. But sure, sometimes you are right. Especially when it comes to multithreded code and using memory after it has been freed the behavior can be really hard to predict at times. But not all undefined behavior is like that. Unfortunately i dont have an example here right now. But often undefined behavior jusz means that the comittee didnt define what should happen, but if you know your compiler does it always a certain way, you can know what the code will do even if it is undefined behavior :p
buğra
goodnight, is there any open-source C project that i can contribute on github? any suggestion would be great
Null
Dark ?