Anonymous
ok, do you know a place where I can
100$ website
check if the array is not empty
its not, i tried replacing array too. maybe d stands for something?
Distac_221
paste a return 1; after the printf
sorry does (enter) key included as an input?
Anonymous
 I am trying to return true if a sub-array exists at given index (idx), false otherwise. For example: if idx = -1, return false since data[-1] is out of bounds * if idx = 0, return true since data[0] refers to the first sub-array * if idx = 1, return true since data[1] refers to the second sub-array * ... * if idx = data.length - 1, return true since data[data.length - 1] refers to the last sub-array * if idx = data.length, return false since data[data.length] is out of bounds */
Distac_221
ooh thank you everyone, now i find the solution. instead of if(strlen(str) == 0) its work with if(strlen(str) < 2) because enter was still input after all 😅 thank you @coalio @freakyLuffy @K11M1
Anonymous
O(n)?
Anonymous
determine the time function T(n) of the program then you can find the function complexity
Pavel
what's the purpose of empty templates? template<> int myfunction() { return 10; } i can't seem to find any good explanation online
If I'm not mistaken it's a full template specialization, basically you define a specialization for the specific types and it will be compiled as a normal function in a sense (compiled for a translation unit and then linked) https://en.cppreference.com/w/cpp/language/template_specialization
Anonymous
you need to count the total time your program would take in terms of the input. So if input is larger the time is larger. You don't use seconds for time tho since its different on each machine, instead you use a constant c ( you suppose each statement in your program takes constant amount of time call it c) for example for( i=0;i<n;i++){ count<<i;} count<<i; is one statement and it takes C as time but since there is a for loop so its gonna be repeated n times ( the input number) when n is larger the time taken is larger so your function T(n) = Cn. now you can find the function complexity , complexity is applied on functions not programs . there is a constant g so that g.T(n) upperbounds T(n) since for any function of order n you can always find a constant such that that constant times the function upperbounds your original function and O(n) is the class of functions that are upperbounded by some multiple of n and other functions that upperbound it for all constants >0 so for example 0.00001 n^2 will upperbound 1000n+2 eventually when n gets large
Anonymous
@mtermu
Anonymous
you can graph 0.00001 n^2 and 1000n+2 and see that 0.00001 n^2 will eventually upperbound it
Anonymous
yeah about what
Anonymous
I have 3 problems that i am not able to solve
Anonymous
Can someone help me with them?
Harsh
Hash code hints do
Harsh
Plsz
Anonymous
I have 3 problems that i am not able to solve
They are my practice problems that we are given
Anonymous
I tried solving them but not able to get the correct output
Harsh
Source code*
Distac_221
bwoah, now its segmentation fault. need your help bro pastebin.com/SvWyqThj
Anonymous
Does anyone have c++ notes that he made?
Michel
Are class and struct only different in the default visibility? Or are there more differences?
Pavel
Are class and struct only different in the default visibility? Or are there more differences?
technically only that and also when inheriting from structs, it's public inheritance by default However programmers often use structs to denote bunches of related data and in contrast classes as S.O.L.I.D. OOP classes
Sarfaraz Stark
Can anyone explain what the benefits of operator Overloading and how it work
Kevin
I have a problem with a very large two-dimensional matrix, and segmentation faults (core dumped), they told me that it is possible to solve it by dynamically allocating the memory, with malloc, I have found various solutions on StackOverflow but to no avail. Would anyone know how to help me?
Kevin
We are talking about 25 / 30mbyte
\Device\NUL
bwoah, now its segmentation fault. need your help bro pastebin.com/SvWyqThj
malloc is allocating uninitialized memory, but you pass it into strlen, an UB has occurred. I think you should use calloc since calloc is also initialize all the memory into zero
coal
and the op is using it for C++
Anonymous
A dynamic array is an array whose size is only known during the runtime of a program. You can use the following two functions, malloc() or calloc() to define dynamic arrays. A strict sawtooth array is an array where the values of the sequence of elements should follow the up-down principle. The successive elements of the array should not be the same. The suc- cessive differences across the array should follow alternate +ve and -ve values. For example (1,4,2,5,4,8,6,10,9) and (-10,-15,0,-2,6,3) are strict sawtooth arrays of size 9 and 6, respectively, but (1,5,7,3,6) and (34,23,23,44) are not strict sawtooth arrays. In this program you have to use the concept of dynamic arrays to perform the following tasks with respect to sawtooth arrays. • Prompt the user to enter the size of the array as ‘n’. Declare a dynamic integer array of the same size. • Take input ‘n’ different integers into the array from the keyboard. • Check if the array is a sawtooth array or not. Use the function int isSawtooth(int *) that takes as argument a pointer to the array and returns 1 if the array is sawtooth, otherwise it returns 0. Print the appropriate message on the console. • If the array is NOT a sawtooth array, then find out the first position in the array where the sawtooth condition is violated. Use the function void position(int *, int *) which takes in two pointer arguments, first one is the pointer to the array and the second one a pointer to another integer variable declared in main. The position where the sawtooth condition is violated is written into the variable pointed by the second argument (Note that this function should NOT return the position). Also this function should be called only if the array is not sawtooth. 1 • The program then frees the dynamic array created. It asks whether the user wants to continue again or not. It prompts the user to input ‘Y’ (for Yes) or ‘N’ (for No) to continue the program. If ‘Y’ is entered, then the steps are repeated again and if ‘N’ is entered, the program exits. The array has to be dynamically allocated each time the program runs.
Anonymous
help me with this problem
Anonymous
in this I am not able to find the position function
\Device\NUL
gcc compiles both C and C++
gcc and g++ are diffrent i think. Maybe the OP compile C++ using gcc but he/she forgor to give -lstdc++ parameter
Hussein
I am trying to solve my assignment but it is too hard please can you solve it the assignment is to input a number between 100 and 999 using c++ Thank you😍
Hussein
Why
\Device\NUL
Why
Because it's easy
Hussein
First time learning c++
Hussein
I only know if and else
Hussein
They said to me to use loop 😟
klimi
your request doesn't sound that you want to learn. it seems that you just want us to make the work instead of you
Hussein
No bro
\Device\NUL
but if i could just made with static memory since i just need 10 character input
Yeah you can, but don't forgot to initialize the array to zero type arr[x] = {0} The first until the end of the array are initialized to zero
Prometheus
They said to me to use loop 😟
Have you tried googling it?
\Device\NUL
Loop is in basic programming
Hussein
Loop is in basic programming
First time learning about language
coal
First time learning about language
prioritize learning in documents and in google instead of asking people to solve your problems
coal
if you have questions because you tried to solve it but you have an error, then you can ask
coal
but you also have to engineer the function by yourself, especially in something so simple that you could find it in google in 10 minutes
Nana
pls what frame work is good gor c++ GUI
klimi
gtk, qt, imgui
coal
lol
Nana
Okay, thank you guys
Nomid Íkorni-Sciurus
Hi. I'm trying to use SDL2 as a dependency in Meson, but linking fails because it can't find SDL2.lib.
Nomid Íkorni-Sciurus
at the end of compilation, it says LINK : fatal error LNK1181: can't open input file 'subprojects\SDL2-2.0.18\sdl2.lib'
SCouT9
Is there anyone who can help me with this problem 😐 Suppose😷 you have a cubic shaped container full of water and the height of that container is h. You accidentally dropped a metallic ball that has a radius of r (where r<h) and v volume of water overflowed from the container. Write a C program that takes h and r as input and displays the volume of water that overflowed. Sample input: 10 5 Sample output: 607.30
SCouT9
Am just a biginner Thanks in advance
klimi
Am just a biginner Thanks in advance
you have just posted your assigment, but not your problem
SCouT9
you have just posted your assigment, but not your problem
Can u help me with that😢 Or where I can find this types of problems+solution to Practice??
klimi
Can u help me with that😢 Or where I can find this types of problems+solution to Practice??
problems and solutions? hm... maybe some book or sites like leetcode? maybe? idk i haven't needed solutions
klimi
if i needed some snippet of code i used google
100$ website
i have written a code, to convert digit into words to 1-100 i wanna make it infinity like if user input 3000, 4560? also when i write 30 it return 30 d
100$ website
#include<iostream> using namespace std; int main() { int number,a1,a2; char array1[][10]={"one","two","three","four","five","six","seven","eight","nine","ten"}; char array2[][10]={"eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"}; char array3[][10]={"twenty","thirty","fourty","fifty","sixty","seventy","eighty","ninty","hundred"}; cin>>number; { if(number<0) cout<<"the number is negative number"; else if(number>0 && number<=10) cout<<"the number is "<<array1[number-1]; else if(number>10 && number<20) cout<<"the number is "<<array2[number-11]; else if(number>=20 && number<=100) a1=number/10; a2=number%10; cout<<"the number is "<<array3[a1-2]<<" "<<array1[a2-1]; } return 1; }
100$ website
can someone help me here?
coal
i have written a code, to convert digit into words to 1-100 i wanna make it infinity like if user input 3000, 4560? also when i write 30 it return 30 d
parse it as an int and convert to string using itoa (edit: this was a quick glance, i just read your code and i see that's not what you meant)