Anonymous
No you don't
Ludovic 'Archivist'
Should I warn him?
Probably, you are the admin, not me (I rejected that responsibility long ago)
Ludovic 'Archivist'
He at least needed a bit of public shaming
Merry
hey, i have a bit long code (but specific problem) and prefer not to put it in one of the sites suggested in the rules, if someone can help me on private chat or something i would love that 😊 btw - the program is in c code :)
ברני
DGB is a good site
ברני
For sharing
Anonymous
How we can print shapes using loops in c++? Anyone can explain Concept/logic?
Anonymous
I am confused to understand the logic/concept.
Roshan
Yes.
In case of a normal asterisk pattern like half pyramid. The first loop ends line and the inside loop prints it. The loop inside will print 1 * if it's row 1, 2 * if it's row 2 and so on...
Anonymous
In case of a normal asterisk pattern like half pyramid. The first loop ends line and the inside loop prints it. The loop inside will print 1 * if it's row 1, 2 * if it's row 2 and so on...
Ok. Now I am writing code to print be like following ********** ********** ********** ********** I am writing the code and if it will never print the given i'll share my code. Then Kindly help me.
HaiNahi
You can i=size For i to 1 decrease by one i=j For j to 1 decrease by one Print star one time Print new line
Anonymous
#include <iostream> using namespace std; int main() { for (int row = 0; row < 5; row++) { for (int star = 0; star < 20; star++) { cout << '*'; } cout << endl; } system("pause"); }
Anonymous
Can you tell me how can I change this one into which print half pyramid?
HaiNahi
No take the copy of variable from upper loop and then iterate it in the inside one
Roshan
Make star var go upto row. I.e, star < row (in your case)
HaiNahi
https://www.programiz.com/c-programming/examples/pyramid-pattern cheat from net and do ur hw ;)
HaiNahi
I would suggest you not to copy from here
If you can't understand loop then how will u code bigger programs
HaiNahi
You should simply understand by intution
Roshan
If you can't understand loop then how will u code bigger programs
What you have provided is not about understanding loops. Even in captions you have mentioned go cheat and Jot!
Roshan
I thought that he is lazy
Never provide the code bluntly...
Anonymous
If you can't understand loop then how will u code bigger programs
I am a beginner, Still I work and give time to programming. I think work hard will make me professional.
Anonymous
I never asked the code, I asked the concept and logic.
HaiNahi
I never asked the code, I asked the concept and logic.
But aren't you getting intution? You can even start with while loops if u don't know the syntax of for loop
Anonymous
I got admission in an institute but I can't understand my teacher. I asked this Question again and again and he tells me again and again but I can't understand. Because he tell me the code but I want to learn logic. If he tell me the logic and then I'll solve write the code for pyramid and other shapes like diamond etc.
Anonymous
I want to learn the logic not to read/write the code. If I learn the logic then i'll write the code using my mind.
Anonymous
Ok
Makgato
Hello guys i need , i on how can i code program that have sockets for clients and server? I tried to check it via YouTube but i didn't find
Makgato
I need to know it in C++
Roshan
https://youtu.be/2hNdkYInj4g
Roshan
Maybe this has it. *I've not watched
Anonymous
👍
Makgato
👍
Thanks i will go through it
ברני
Hey... I made an easy code on c and I got a small problem that I dont get... the first symbole don't count and I don't understand why...
ברני
https://onlinegdb.com/SJ13suiiv
Roshan
https://onlinegdb.com/SJ13suiiv
You've used scanf() twice, remove the outer scanf() (outside while loop)
Roshan
Get it?
ברני
I tried it already, the code won't work if iill remove the outside or the inside
Merry
hey, trying to build matrix-rotate function but i don't understand how to do that. Even tried to look it up on YouTube but i found only one and didn't understood it (the rest were about rotate the matrix in 90 degrees, which i don't need) Any help?
Roshan
I tried it already, the code won't work if iill remove the outside or the inside
While loop is doing some nonsense. Try to run it after you remove while
Apk
Hey... I made an easy code on c and I got a small problem that I dont get... the first symbole don't count and I don't understand why...
After you check that the entered character is not Q, you again take input which discards the previous input and takes new one
Igor🇺🇦
I tried it already, the code won't work if iill remove the outside or the inside
I think you should use do while instead of while and remove the scanf outside of the loop.
ברני
It works when I remove the out side scanf on other compilers but not on VS
Apk
It works when I remove the out side scanf on other compilers but not on VS
On other compilers, does the Q+enter feature works too?
Roshan
It works when I remove the out side scanf on other compilers but not on VS
#include <iostream> #include <stdio.h> using namespace std; int main() { char symbols = 'f'; int a = 0; while (symbols != 'Q') { cin >> symbols; switch (symbols) { case '+': a++; break; case '-': a++; break; case ':': a++; break; case '.': a++; break; case '*': a++; break; default: printf("\nWrong symbols"); break; } } cout<<a; }
Roshan
Maybe it's some problem with C, IDK
Roshan
It always prints "Wrong symbol" at least once tho, so it's not exactly the same
I simplified it until I get the desired results. Barney had incorrect code...
Roshan
olli
Your solution is fine, it works! (Just wanted to point out that it always prints "Wrong symbol" before exiting, that you could fix by adding a case 'Q': break;) I would probably do it like this while(1) { scanf(" %d", &symbol); if (symbol == 'Q') { break; } switch (symbol) { // ...
Roshan
Question, when you writing while(1) It means while loop number 1?
1 means true so while(true) is infinite loop
Кто-то
Hello. i have an assignment. Could somebody help where i made a mistake? I wrote my solution but it isn't right. But for examples it fit.
B
Can someone help me with entering data from the user in file in c++?
Roshan
ברני
Hey again.. How do I devide 2 numbers by using minus only?
Blue
Hey again.. How do I devide 2 numbers by using minus only?
repeated subtraction of the divisor from the dividend
Vitalii
double calc(int arr[], int len) { if(len>=0) { return 1.0/(arr[len-1]+calc(arr, len-1)); } else { return 1; } } Sorry, can anyone explain what I do wrong when I calculate expression 1/(b1+1 /(b2+1/(b3+1/(b4+...+1 /(bn−1+1/bn)...)))), using recursion?
Vitalii
arr - my array with numbers entered from keywords, len - size of array
Alex
arr - my array with numbers entered from keywords, len - size of array
arr[len] —> arr[len-1] if (len >= 1) —> if (len >= 0)