Anonymous
hello. can anyone suggest me how i could improve my coding skills in c/cpp? i want to work on projects but i have zero experience. problem solving like hackerrack gets boring
You could start with some existing github repositories. Check out the code and understand them and try making modifications or improvements. If you feel like you have done a good job, let the owner know and see if he/she would be willing to pull in your changes. If she doesnt, she will tell you why. Use the feedback and repeat.
Lenin
oo thanks for your input
Dumb
hello. can anyone suggest me how i could improve my coding skills in c/cpp? i want to work on projects but i have zero experience. problem solving like hackerrack gets boring
you could try making something by yourself. Tiny projects to improve not only problem solving skills but also coding and efficiency. With little steps you'll reach great goals
Anonymous
oo thanks for your input
https://github.com/fffaraz/awesome-cpp Here are some C++ repositories. Pick 1 that you like. But be aware that these repositories are starred heavily and hence there will be multiple committers. Unless the change you offer is very enticing, it is highly likely that your code will be rejected. Dont let that disappoint you.
𝙰𝚖𝚖𝚊𝚛
Hello everyone, could anyone tell me what is the best source to learn Dynamic programming (DP)
Anonymous
Hello everyone, could anyone tell me what is the best source to learn Dynamic programming (DP)
https://m.youtube.com/playlist?list=PLcDimPvbmfT8qAxD6JH_kmXiQwTNcoK78
𝙰𝚖𝚖𝚊𝚛
Anonymous
Thank you, is it for beginners?
Dynamic programming doesnt require you to know other techniques like Greedy and Divide and Conquer. It wont hurt if you know them but. You must know how to calculate complexity of algorithms but.
𝙰𝚖𝚖𝚊𝚛
Not really.
Ok thanks, is there any free books about it ?
Anonymous
I see, but don't it need a special requirements?
Dynamic programming is an approach, resting in logical thinking. You form the recurrence, and use memoization, that's top down approach. You use an iterative method using 2D (if there are 2 states that are getting changed) and so on, that's bottom up approach.
Anonymous
23.Write program in c++ find the position of min and max element in one dimension array
Anonymous
https://github.com/mgood7123/prebuilder
Hanz
Hello members,help me to develop a game for kids using c++
Try Godot Native, its a C++ interface for Godot game engine https://godotengine.org/
•‿•
can someone suggest me where to practice c programming questions as a beginner ?
•‿•
Hanz
np
Anonymous
"The strategy behind the usual arithmetic conversions is to convert operands to the “narrowest” type that will safely accommodate both values. (Roughly speaking, one type is narrower than another if it requires fewer bytes to store)" "Among the most common promotions are the integral promotions, which convert a character or short integer to type int" These two lines are from a book I'm reading. How can those two go together, given that char or short always occupy less memory than int?
Anonymous
.Write program in c++ find the position of min and max element in one dimension array.
Ravi
iterate over the array, and track the current minimum and maximum element at each point. Thats the logic, write the program by yourself it is not hard if you try.
Tute
/get cppbookguide
Anonymous
https://dpaste.org/8ZGw NOT SHOWING ANY ERROR BUT IN VOID PLAY SECTION AFTER I PRESS ANY KEY THEN ENTER THE PROGRAM STOPS
Ravi
in show function second last line
Ravi
thirdt last*
Anonymous
#include<stdio.h> #include<stdlib.h> int main() { int apple=50,banana =60, mixture=0; printf("Number of apples in the bucket: %d\n",apple); apple--; printf ("Number of fresh apples remaining after one rotten apple threwn out: %d\n",apple); printf("Number of bananas in the bucket: %d\n",banana); ++banana; printf("Number of bananas in the bucket after adding one into it: %d\n",banana); mixture=apple+banana; printf("total number of apple and banana: %d\n",mixture); apple=12; banana=15; mixture=(apple++)*(++banana); printf("turnover is the product of banana and apple: %d\n",mixture); mixture = (float)banana/(float)apple; printf("loss is the quotient of apple and banana: %f\n",mixture); float loss; loss=(float)banana/(float)apple; printf("loss is the quotient of apple and banana: %f\n",loss); return 0; }
Anonymous
In the above case, why quotient value is not getting updated into the mixture variable ? But if I replace the 'mixture' into some other variable like in the above case I had written 'loss' then the exact function will work.
Anonymous
In the above case, why quotient value is not getting updated into the mixture variable ? But if I replace the 'mixture' into some other variable like in the above case I had written 'loss' then the exact function will work.
mixture is an int variable. So if you store a floating point in it, the values after the decimal point get truncated. Also when printing an int, dont use %f. It leads to UB. When you use %f, usually (it is UB but this is what happens most of the times) the int value in memory will be interpreted as a float and according to IEEE specifications the int value 1 is a denormalized floating point with value very close to 0.0. It is infact the smallest possible representation of a floating point number just bigger than 0. Use %d and you will see that mixture has the value 1 You dont have this problem with loss because it is a float.
Thomas shelby
1st #include<stdio.h> void printTwoOdd(int arr[], int size) {   int xor2 = arr[0];   int set_bit_no;    int i;   int x = 0, y = 0;   for(i = 1; i < size; i++)     xor2 = xor2 ^ arr[i];   set_bit_no = xor2 & ~(xor2-1);   for(i = 0; i < size; i++)   {      /* XOR of first set is finally going to hold one odd        occurring number x */     if(arr[i] & set_bit_no)       x = x ^ arr[i];     else       y = y ^ arr[i];   }     printf("\n The two ODD elements are %d & %d ", x, y); } int main() {   int arr[] = {4, 2, 4, 5, 2, 3, 3, 1};   int arr_size = sizeof(arr)/sizeof(arr[0]);   printTwoOdd(arr, arr_size);   getchar();   return 0; } 2nd #include<stdio.h> void print2odd(int arr[], int size) { int xor2 = arr[0], set, i, x = 0, y = 0; for(i = 0; i < size; i++) xor2 = xor2 ^ arr[i]; set = xor2 &~(xor2 - 1 ); for(i = 0; i < size; i++) { if(arr[i] & set) x = x ^ arr[i]; else y = y ^ arr[i]; } printf("%d & %d", x, y); } int main() { int arr[] = {4, 2, 4, 5, 2, 3, 3, 1}; int arrsize = sizeof(arr) / sizeof(arr[0]); print2odd(arr, arrsize); getchar(); return 0; }
Thomas shelby
1st #include<stdio.h> void printTwoOdd(int arr[], int size) {   int xor2 = arr[0];   int set_bit_no;    int i;   int x = 0, y = 0;   for(i = 1; i < size; i++)     xor2 = xor2 ^ arr[i];   set_bit_no = xor2 & ~(xor2-1);   for(i = 0; i < size; i++)   {      /* XOR of first set is finally going to hold one odd        occurring number x */     if(arr[i] & set_bit_no)       x = x ^ arr[i];     else       y = y ^ arr[i];   }     printf("\n The two ODD elements are %d & %d ", x, y); } int main() {   int arr[] = {4, 2, 4, 5, 2, 3, 3, 1};   int arr_size = sizeof(arr)/sizeof(arr[0]);   printTwoOdd(arr, arr_size);   getchar();   return 0; } 2nd #include<stdio.h> void print2odd(int arr[], int size) { int xor2 = arr[0], set, i, x = 0, y = 0; for(i = 0; i < size; i++) xor2 = xor2 ^ arr[i]; set = xor2 &~(xor2 - 1 ); for(i = 0; i < size; i++) { if(arr[i] & set) x = x ^ arr[i]; else y = y ^ arr[i]; } printf("%d & %d", x, y); } int main() { int arr[] = {4, 2, 4, 5, 2, 3, 3, 1}; int arrsize = sizeof(arr) / sizeof(arr[0]); print2odd(arr, arrsize); getchar(); return 0; }
Can anyone tell the difference between these 2 codes Am getting different outputs
Anonymous
Can anyone tell the difference between these 2 codes Am getting different outputs
Probably not the right answer since i dont think I fully understand what's the code purpose, but is it intentional you start first for cycle of print2odd with i = 0? The other version sets it to 1
Anonymous
Ok. Outside of that I cant tell what's the difference between the two codes, they are basically the same except for that
hossein sharifi
Hi
hossein sharifi
Pleas help me
Anonymous
I Waaaana find the odd occurance of 2 numbers in a arry
Yup. The second code is wrong. The initial value of i should be 1. By the way, you can use set_bit_no=xor2&(-xor2) instead of set_bit_no=xor2&~(xor2-1). They have same effect, but the former is better.
hossein sharifi
Write a program that takes the elements of an array from the input, calculates the factorial of each of them, and finds and prints the largest number of calculated values. (Specify the number of array elements by the user.
Ravi
Write a program that takes the elements of an array from the input, calculates the factorial of each of them, and finds and prints the largest number of calculated values. (Specify the number of array elements by the user.
Write a factorial function, take the input array, for each element print the factorial of that element, and store the larger result in a variable. Thats it. Try by yourself
Anonymous
Is opencv the best way to work with a webcam on Windows using C?
Thomas shelby
Opencv and pythons would be better
Pradevel (Pratyush)
Opencv and pythons would be better
I don't think this is a python group 😅
Thomas shelby
Anonymous
Opencv and pythons would be better
I understand. I thought about making a C program which recognize a face and put an image on, like a mask. A simple image, when you move your face the image follows you
Anonymous
No fancy effects
Thomas shelby
Okay
Pradevel (Pratyush)
Is opencv the best way to work with a webcam on Windows using C?
I don't know if its the best but it would definitely work
@𝑺𝒐𝒃𝒌𝒂
#ide
Anonymous
Anonymous
I don't know about c, but using c++ you can work with qt&opencv
Thanks for suggestion, I am learning C more deeply and I thought of making this filter like program soon or later, using opencv for face tracking and sdl for a simple ui and image output. Just for fun
Anonymous
C++ is better if you are serious I get it
Shourya
Are system V semaphores still used ? One of my seniors today raised a MR and I commented not to use them as they are heavy and not POSIX complaint ?Had a heated argument...Anyways ...Anyone has more to add why not to use them?
Anonymous
What are some ways to check execution time of my C++ program? I mainly need it for Competitive Programming purpose - I tried some online solutions, and each time I run it, it gives a different result (of execution time) :/
Anonymous
https://github.com/sharkdp/hyperfine
I don't want a terminal based one, because I usually create a Sublime snippet and I wanna put a piece of code to get it while running it
Anonymous
Analysing time complexity
...yeah but i want a precision based one lol
Anonymous
That is precision based
hein, you ain't getting me i want a display of time spent - like in seconds
Anonymous
auto start = chrono::high_resolution_clock::now(); //---------- solve(); //------------- auto end = chrono::high_resolution_clock::now(); double time_taken = chrono::duration_cast<chrono::nanoseconds>(end - start).count(); time_taken *= 1e-9; cout << "Time: " << fixed << time_taken << setprecision(9); cout << " sec" << endl; I was using this
Apk
hein, you ain't getting me i want a display of time spent - like in seconds
I understand that but that doesn't really help anyway
Apk
Might help me
Fine...go ahead...do tell if it helps.
Anonymous
Fine...go ahead...do tell if it helps.
Sure I know TC I wanna see differences when using recursion, and DP same goes for any other flush-ing
Anonymous
Altho it's not compulsory, I was experimenting