Nomid Íkorni-Sciurus
Here is the documentation to that
Anonymous
int arr[] = {2,3,5}; //Modifying for( auto &num: arr) num = 5; //Printing for(auto const &num: arr) cout << num; This is someone's code. I'm a little confused at the printing part He could have just use a normal range base for loop for the printing without referencing but he didn't? What's the benefit of using reference and const over using general for range based for to print the nums
\Device\NUL
With const part we can sure that the value wouldn't change
Eric Czeladka 🇫🇷
Hi, New in C I am trying to write "Il y a 15% de reussite" I have : printf ("il y a %d de reussite. \n",res); But i don't know how to put the % symbol without having warnings and bad results. I searched on the web but you only find HOW tu use % 🤣 but not how to neutralise it... Any help ? Tks
Khadija
Hi please I have a question : why we choose the highest time complexity ? For example if we have : n+n^2 = why we choose o(n^2 ) ? ✨ I need to understand the reason please 😔 thank you
Eric Czeladka 🇫🇷
Int
Talula
Int
Then you shouldn't get any warnings for this... if it is possible put the whole code.
Eric Czeladka 🇫🇷
int main() { // préparation de variables : déclaration et initialisation int x,note,pct,res; x=0; note = 0; pct=0; res=0; fflush(stdin); printf ("Veuillez saisir 10 notes suivies de Enter a chaque fois \n"); for (x=1; x<11; x=x+1) { scanf("%d",&note); if (note>10) { pct=pct+1; } } res=(pct*100/10); printf ("il y a %d pct de notes superieures a 10. \n",res); return 0; }
Eric Czeladka 🇫🇷
il y a 15 pct de notes...
Eric Czeladka 🇫🇷
il y a 15% de notes... i dlike to escape the %
Eric Czeladka 🇫🇷
Found it...
Eric Czeladka 🇫🇷
printf ("il y a %d %% de notes superieures a 10. \n",res);
Talula
Oh you wanted to print %? God!!!
Talula
😂 Couldn't understand, sorry.
Eric Czeladka 🇫🇷
printf is special... can't escape with\
Eric Czeladka 🇫🇷
tks anymay your question made me have another idea
Eric Czeladka 🇫🇷
with printf we have to double % to have one :-)
anubhav
how we can make a alexa sir type programme through c++
anubhav
*siri
Vladimir
Here you are connoisseurs of the C language, the so-called sishniks, tell me or answer this question is it worth it for a low-level specialist to learn the Fort programming language🤗
Vladimir
I see my question was difficult for you!🤭
hello
Does anyone know how you can use variables and files from file pointers from one c file in another c file?
Pavel
Does anyone know how you can use variables and files from file pointers from one c file in another c file?
Can you give an example of what you're trying to do? I don't really understand the question
Anonymous
Does obfuscating code help me to avoid plagiarism? I mean if we need the same output, but a different code. So, can I avoid plagiarism with obfuscating? Thank you in advance.
hello
http://pastie.org/p/2nPUaVHQKinbM7bC8aptYN
hello
in this code "c" is a variable i put a value to in another file and code is a name of a file pointer i made in a different c file
Anonymous
Ok. Thank you
Anonymous
Pls who knows how to create a telegram bot
klimi
Pls who knows how to create a telegram bot
I wouldn't recommend c or c++ for telegram bot, try python or something like that
n
php
klimi
why not c or c++? because of libraries?
well... you will have to deal with low level stuff, if you are fine what then you can use even assembler or what not... but you will spend more time thinking about the programming language rather than what you want to program
#
Anyone help me
#
Why my code not running and show like this in vs code
#
Klimi ding dong leni hai
Anonymous
Hey
Anonymous
dont ask to ask
Fatih
What do you need?
Dm
Please check rules and use pastebin or whatever And please highlight what exactly wrong (compilation? Different behaviour?)
Null
why is dark>?
Anonymous
Is there a way we share our small program to someone and not as an output but as a program (like an apk)?
klimi
Is there a way we share our small program to someone and not as an output but as a program (like an apk)?
well you can share compiled executables if you wanted... or as the source code
Anonymous
I want to share the program like if my program is ex - Enter number : 2 Enter number again : 2 And then it scans and give the answer 4
Anonymous
So that they can see our program
Pavel
I want to share the program like if my program is ex - Enter number : 2 Enter number again : 2 And then it scans and give the answer 4
Build the executable (what kind of executable depends on the platform, on windows it's *.exe) and share it
Pavel
Just build it with release settings (depends on how you build it)
Anonymous
Are you trying to say that save your code in a file and then rename file to .apk or .exe?
Pavel
Are you trying to say that save your code in a file and then rename file to .apk or .exe?
No, when you run your code, what usually happens is that the compiler and linker build an executable, save it somewhere and run it. You just need either to find where it built to and copy it, or make it build to the location you want. How, depends on what IDE you use. If you use online IDE for example you can't do that, because the executable is stored on the server side.
Pavel
Ohh no
You need to install a compiler to your machine, if you don't have it
Pavel
Yes dude i have it but i use online ide
Then build your code from the online IDE with your local compiler
Pavel
Just copy your code to a file, name it something like yourprogram.cpp and run the command that TheAcelot mentioned above (assuming your compiler is mingw)
M
Hello guys I want to Find the minimum number of coins that make a given value Using (dynamic programming with memoization) Here is the code 👇🏻 in a bottom-up manner. Who can help me writing the code in a top-down manner (memoization)🥲?
M
// A Dynamic Programming based C++ program to find minimum // of coins to make a given change V #include <bits/stdc++.h> using namespace std; // m is size of coins array (number of different coins) int minCoins(int coins[], int m, int V) { // table[i] will be storing the minimum number of coins // required for i value. So table[V] will have result int table[V + 1]; // Base case (If given value V is 0) table[0] = 0; // Initialize all table values as Infinite for (int i = 1; i <= V; i++) table[i] = INT_MAX; // Compute minimum coins required for all // values from 1 to V for (int i = 1; i <= V; i++) { // Go through all coins smaller than i for (int j = 0; j < m; j++) if (coins[j] <= i) { int sub_res = table[i - coins[j]]; if (sub_res != INT_MAX && sub_res + 1 < table[i]) table[i] = sub_res + 1; } } if (table[V] == INT_MAX) return -1; return table[V]; } // Driver program to test above function int main() { int coins[] = { 9, 6, 5, 1 }; int m = sizeof(coins) / sizeof(coins[0]); int V = 11; cout << "Minimum coins required is " << minCoins(coins, m, V); return 0; }
Deepak Chaurasia
Hello guys i was writing some codes and i am bit confused how 1%10 equal to 1 isn't its should 0
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Hi, I'm reading stuff from a file using fgets: while(fgets(buff, sizeof(buff), fp)){ fprintf(stdout, "this is buff %s and this is lenght %ld\n", buff, strlen(line)); // Remove the \n at the end: buff[strlen(buff) - 1])= 0; fprintf(stdout, "This is buff without new_line: %s and this is lenght: %ld\n", buff, strlen(line)); } So this is the problem. I know the string he reads is 10 char long (there's no doubt about it). Since strlen does not count NULL terminating carachter, I expected, at first print, lenght= 11, instead it prints lenght= 12. After I remove the \n, the lenght is 11. But now I'm confused, as I don't understand what the last carachter is. If it's not \0 and not \n, since I got rid of it, what is it? Could you please help? Thanks! Inside the file I've got written: 1a2b3c4e5d And in another file I've got written the same thing: const char *ESCAPE= "1a2b3c4e5d"; The endgoal would be to do if(strcmp(buff, ESCAPE)==0), but it's never true, as ESCAPE has lenght 10 and there's something more in buff that makes its lenght 11
Pavel
Hello guys i was writing some codes and i am bit confused how 1%10 equal to 1 isn't its should 0
% is a reminder from integral division (also called mod or modulo operation https://en.m.wikipedia.org/wiki/Modulo_operation) 1/10 = 0 1%10 = 1 10/3 = 3 10%3 = 1
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Yes, it was the \r. Thank you very much!
Pavel
You can use types for templates, but it depends on what you're trying to achieve with it.
#
How to learn faster c
#
Any YouTube channle ya websites
Dm
Does someone know how to compile qr quick app on windows for Linux (Ubuntu)?
Pavel
Is it guaranteed that capacity() of a vector will be equal to the value passed to reserve() when reserve called on a freshly created empty vector?
Eric Czeladka 🇫🇷
Tks i managed to find it by myself... Printf is another matter to escape %
Eric Czeladka 🇫🇷
Tks anyway.
Eric Czeladka 🇫🇷
Tks anyway, it will help me next time to search questions in Google.
Anonymous
Is it guaranteed that capacity() of a vector will be equal to the value passed to reserve() when reserve called on a freshly created empty vector?
No. If the call was successful, then the only thing guaranteed is that capacity will be greater than or equal to the value requested by reserve.
Anonymous
You can create a struct like this: template <typename T> struct ClassType{ using Type = T; }; and use it to encapsulate typenames.
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Hi, is it possible to create your own signals in C? Like, usually you write signal(SIGINT, SIGINT_HANDLER) so whenever the user presses CTRL+C the actual routine will pass the control to a subroutine which is the handler that will do stuff before returning the control to the upper routine. I need to do something like, but I need to create my own signal. Like, when the user presses CTRL+SHIFT+R, the signal function shall recognize this as a signal and therefore call a handler. Is it possible to do so?