Roxifλsz 🇱🇹
/warn *bonk*
Hariyana Grande
for(i=0; i<size; i++) { if(arr[i] == toSearch) { found = 1; break; } }
Hariyana Grande
what break statement doing here i mean its use?
Hanz
what break statement doing here i mean its use?
it will break the loop immediately
Hariyana Grande
and what about value of i ?
Hanz
wdym?
Hariyana Grande
if say 3==toSearch true will i update its value to 3 even outside of for loop
Hanz
if say 3==toSearch true will i update its value to 3 even outside of for loop
i havent experiment with that but if variable i declared outside of the for loop, you could use its latest value
Rohan
if say 3==toSearch true will i update its value to 3 even outside of for loop
Its value is already became 3, that's why it broke the loop
Hariyana Grande
if i do - printf("%d", i); right after loops end will i =3 ?
Hariyana Grande
Yes
but when i tried without break i is giving different value why is it so?
Rohan
Actually no, I didn't noticed it is post increment
Rohan
It's value has become 4 now
Rohan
Yes
Sorry my mistake
Hariyana Grande
np thanks for help
Rohan
👍
Hanz
but when i tried without break i is giving different value why is it so?
when you remove the break keyword, the for loop keep adding value to variable i
Hariyana Grande
#include<stdio.h> int main(){ int i; int j; for(int i = 0; i < 10; i++){ } printf("j: %d, i: %d \n", j,i); return 0; }
Hariyana Grande
output- j:50 i:0
Hariyana Grande
why j is 50 ? without initialization
Hariyana Grande
is that a garbage value
Hanz
in my machine: j: 0, i: 32767
Hariyana Grande
in my machine: j: 0, i: 32767
so its undefine behaviour
Hanz
so its undefine behaviour
im not that advance yet 😂
Rohan
output- j:50 i:0
J must be garbage value but why I is 0? It should be 11,right?
Hariyana Grande
im not that advance yet 😂
np will learn together
Hanz
J must be garbage value but why I is 0? It should be 11,right?
how about removing the int i = 0 declaration? Like so: for(i = 0; i < 10; i++){
Hariyana Grande
J must be garbage value but why I is 0? It should be 11,right?
yes that is what i was hoping but i dont know
Hanz
oops false reply
Hariyana Grande
J must be garbage value but why I is 0? It should be 11,right?
#include<stdio.h> int main(){ int i; // int j=5; for( i = 0; i < 5; i++){ printf("%d", i); } printf("%d", i); return 0; }
Hariyana Grande
now it gives i=5
Rohan
now it gives i=5
Yeah it is right
Hanz
gret
Hariyana Grande
Yeah it is right
so conclustion -if you initiatilize int i in for loop has its own scope you cant access it outside
Rohan
It's just the post increment operator
Hariyana Grande
no you can check by urself try to print the same program
Hariyana Grande
post increment operator - may be
Hariyana Grande
let me check that too
Rohan
no you can check by urself try to print the same program
You were right bro, all the variable initialised inside for loop have scope in the for loop only not outside it
Hariyana Grande
You were right bro, all the variable initialised inside for loop have scope in the for loop only not outside it
i tried pre and post increment no effect on output so its all about initilization
Rohan
Yes
Anonymous
Can someone help my c programming exam?
ɴꙩᴍᴀᴅ
Well it depends
ɴꙩᴍᴀᴅ
Can someone help my c programming exam?
How much are you willing to pay?
Anonymous
How much are you willing to pay?
30 dollar if u can do over 85 points
Anonymous
Can someone help my c programming exam?
Why not... I'll try in free
Engineer
How can we help you with an exam? I haven't passed my exam yet. What are you going to do once you pass your exam? Ask someone to do your work for you?
Anonymous
I think helping someone is not illegal
Aura
I think helping someone is not illegal
I think you should opt for that exam yourself and ask doubts later
Anonymous
#include<stdio.h> int main(){ int i; // int j=5; for( i = 0; i < 5; i++){ printf("%d", i); } printf("%d", i); return 0; }
It gives 5 because the increment part in for loop execute after completion of each time off all the statements... So when i=4 and it execute all statement in loop then it goes to increment part where it become 5 then then it check condition where it find (i<5) so condition is false therefore it exit. In simple word understand if loop condition is (i<5) then after execution of for loop i will be 5 and If (i<=5) then in last i will be 6
Aura
Anyone having simplest approach on finding first non repetitive element in a word/string. Time complexity doesn't matter.
Aura
?
Aura
It is working using hashmap, but is there any simpler approach?
Engineer
Nick
🚲
Jason
🤔since l am asking for help in a game card in C++ here but no one is responding 😐
Rohan
🤔since l am asking for help in a game card in C++ here but no one is responding 😐
I am not that advanced in c, but you can share your problem with me, hope I can help in anyway
Rohan
What is the problem?
Jason
What is the problem?
To create repository in a directory
Anonymous
Anyone having simplest approach on finding first non repetitive element in a word/string. Time complexity doesn't matter.
Create an array of size 26 of character counts (assuming english alphabets). Iterate through the string once and set the character counts accordingly. Iterate through the string again and choose the first character in the given string that has a count of 1.
Anonymous
To create repository in a directory
What do you mean by a repository? A source code repository? If yes, then which version control software are you using? If GIT, then a simple "git init" would do the job.
.
Hola alguien habla español?
.
Some programmer to help me
.
?
.
Can you help me make a code with an options menu that contains bubble sorting, insertion, binary search, invented search