coal
but if you're doing something like image processing, which does not really require "bruteforcing" the solutions, then Python is great due to its large support
coal
in the end though, it all reduces to what you feel most comfortable with
Anonymous
From what you wrote, the only advantage is order of inclusions of module does not matter… this means that if a module has a dependency, that dependency can be imported after the module is imported? However this is really solving a problem that should not happened in the first place (my opinion)
No. You have not understood what I said. I had not listed the advantages of modules in my previous post. I had listed how modules address the disadvantages of header files. And I did not list just one but quite a few. Please read my post again. And if a module has a depedency, the module itself makes that clear through an import and the source file does not have to find out a module's dependencies and spell them out. When I mentioned "order does not matter", I meant that modules address the problem of ordering which is present in the header files. Header files are processed by a preprocessor while modules are processed by the compiler. So if header file has a #define A and header file B also has a #define A then the order in which you include header file A and B matters. Modules don't allow preprocessor macro exports.
Melbgm
ch = getchar(); if (ch ==1)
Melbgm
what was the syntax when i write it with numbers guys ?
Felix
use %d
\Device\NUL
what was the syntax when i write it with numbers guys ?
C/C++ use ASCII char (Though you can still use unicode char16_t char32_t or wide wchar_t characters) ASCII char has own values (see ASCII table or man ascii) getchar() return int value that represented ascii char from the input. cmiiw So if you compare it with 1, it won't be true since 1 is number for SOH(start of heading) character But...., this is different '1' with 1 is different '1' will turn into ASCII char value which is 49. I think, you want to compare with ASCII value directly rather than comparing with character, so it would be if (ch == 49)
hossein sharifi
☹️☹️
Guruphem
Write a C and Python program that will transform an arithmetic expression into postfix and prefix expression. - Algorithms - Flowchart - Source Code
Guruphem
My SIWES project, is there anyone that can help? 😭😭😭
Hanz
My SIWES project, is there anyone that can help? 😭😭😭
Anyone can help you, but have you tried it yet?
Brown
My string variable contains = "[2,162552, {"customData": "Xyz", "Iccid": 0009877}]" How can I convert it into an array of strings?
ARYA
Hello, can anyone write this code? Write a program that takes n input from the user Then make a presentation from 1 to n And then print all the subsets of this presentation in the following order Like N = 4 Array = [1.2.3.4] Cout: { } {1} {1.2} {1.3} {1.4} {1.2.3} {1.2.4} {1.3.4} {1.2.3.4} {2} {2.3} {2.4} {2.3.4} {3} {3.4} {4}
the best for everyone
// 4.question of the exam // write there functions // 1 String length takes the string (Array of char ) as a prarameter and return the length of the string as int // 2 strReverse takes 2 parameters, the strig (Array of the char ) //and the length of the string that came form strlength function . this function will resereve the string // 3 the (main function) reads the string and call the strlength //to find its lengththen call the strReverse to reverse the string After that print the lenngth of the string and the reversed string in the main #include<stdio.h> char funtion_string_length(char s[] ) { int k=0; // contut character until teminator the character while (s[k]!="\0";k++ ) priuntf("Array length: %d\n",k); return 0; } void strReverse (char s[] ; temp){ int i, n; /* until terminator character */ // for(n=0; s[n] != '\0'; n++); for( i = temp - 1; i >= 0; i--){ printf("%s", s[i]); } /* for(i=0; i</2; i++){ temp = s[n-i-1]; s[n-i-1] = s[i]; s[i] = temp; } printf("Reverse : %s\n", s); */ } int main(){ funfuntion_string_length (s); strReverse(); }
the best for everyone
what are the mistakes in this code ?
Gaurav (a.k.a Avenger)
#include <stdio.h> int main() { int a,b,j; char ch; do{ /*Even odd program*/ printf ("\n Enter no. check weather it's even or odd= \n"); scanf ("%d",&a); if(a%2==0) printf ("Number is even \n"); else printf ("Number is odd \n"); /*Even odd program ends*/ /*Display last digit program*/ b=a%10; printf("Last digit: %d \n",b); /*Display last digit program ends*/ /*Display all positive no below the number program*/ j=a; for (;j>0;j--) { printf ("\n %d \n",j); } /*Display all positive no below the number program ends*/ /*While Statement*/ printf ("Do you want to continue: y/n"); ch = getchar(); getchar(); } while(ch=='y'); }
Pavel
Code is not going in loop
So, it does the first iteration, but if you type "y" it finishes the program instead of doing the next iteration? Or is it something else?
Marcin
what is the best design pattern for informing "creator" about events. My problem is: there is a server which creates sessions objects. I want to make that every session is able inform server about events (for example session clossgin etc.)
Joo
Can someone explain containers to me and their applications in C++
\Device\NUL
'\0' is different with "\0" "\0" are array of char {'\0', '\0'} Typo on priuntf I dont't think you need variable beside for iterating since you have the length from stringlength function It would be for (size_t i = len - 1; i >= 0; i--) putchar(s[i])
\Device\NUL
Sheesh, how hard to read any message from compiler before asking in the group
shriman_deepak
// Find the lowest frequency character in a string. #include<stdio.h> int strleng(char str[]) { int i = 0; while (str[i] != '\0') { i++; } return i; } int main() { char str[100]; gets(str); int n = strleng(str); int max = n; char ch; for (int i = 0; i < n; i++) { int cnt = 1; for (int j = i+1; j < n ; j++) { if (str[i] == str[j]) { cnt = cnt + 1; } } if (cnt <= max) { max = cnt; ch = str[i]; } } printf("%c",ch); return 0; }
shriman_deepak
can anyone tell me what's wrong in this code ?
Prince Of Persia
can anyone tell me what's wrong in this code ?
This question is like, you go to doctor then without anything else say: "what's wrong with my body"
Lieutenant
can anyone tell me what's wrong in this code ?
Atleast tell what your code is trying to achieve
shriman_deepak
if a person don't feel well doctor do some checkups
Prince Of Persia
Yes because this code is not working fine
What's the exact problem? Compile time Runtime error Wrong answer(if yes the by which input?)
shriman_deepak
shriman_deepak
yes
Prince Of Persia
it always printing 1st character of the string
Not first It prints the last char
shriman_deepak
Prince Of Persia
Prince Of Persia
Then tell me what's the output
shriman_deepak
a
Anonymous
I would ask if they are free sources code for html and css projects without javascript??
Prince Of Persia
a
are you sure? mine shows c
Prince Of Persia
I have tested that
shriman_deepak
are you sure? mine shows c
if u are checking the same code as mine then yes it returns a
shriman_deepak
#include<stdio.h> int strleng(char str[]) { int i = 0; while (str[i] != '\0') { i++; } return i; } int main() { char str[100]; gets(str); int n = strleng(str); int max = n; char ch; for (int i = 0; i < n; i++) { int cnt = 1; for (int j = i+1; j < n ; j++) { if (str[i] == str[j]) { cnt = cnt + 1; } } if (cnt < max) { max = cnt; ch = str[i]; } } printf("%c",ch); return 0; }
shriman_deepak
ah yes
shriman_deepak
= sign
shriman_deepak
But still this solution is not giving the correct output
Prince Of Persia
But still this solution is not giving the correct output
you have to know which chars you have proceeded (you are reprocessing them)
Prince Of Persia
you have to know which chars you have proceeded (you are reprocessing them)
or another way (not recommended for real projects) is to process all string by each char(to know what is the char's frequency)
Anonymous
#Question I have a class like this: Matrix Matrix :: operator * (double lambda) { ... return Matrix (aux_data, number_lines, number_columns); } The Matrix class also has a move constructor as follows: Matrix :: Matrix (const Matrix && rhs) { number_columns = rhs.number_columns; number_lines = rhs.number_lines; data = rhs.data; } My question is, because I put the output of the * function in the Matrix, after moving and creating a new object, an extra copy happens so that the object reaches the caller? I mean, should I not set the output type of the function * to type & Matrix?
Anonymous
Hello friends, what is the problem with the following code?👇👇👇 #include <iostream> using namespace std; int main() { int n; cin >> n; long sum = 0; int a; long f = 1; for (int i = 0; i < n; i++) { cin >> a; f = 1; for (int j = 2; j <= a; j++) { f *= j; } sum += f; } cout << sum; return 0; }
Pavel
Yeah after typing y it finishes the program
Not sure but it might be that something left from scanf (a newline character) and you read this first. Here are some examples what you can try https://stackoverflow.com/questions/12653884/getchar-does-not-stop-when-using-scanf Also, you can print the value of ch to the console (e.g. in quotation marks, something like "\"%c\"") at the end of the loop to see what is in there. Or better yet use a proper debugger tool to break into/execute the code line by line and investigate the values.
Anonymous
Hello
Anonymous
2pm wipro help text m
NagaRaju
Hello everyone, I am trying to insert data into database using specific variables(like user given values). This is my code : #include <iostream> #include <mariadb/mysql.h> #include <cstring> #include <sstream> using namespace std; void signUp (MYSQL* con, string name, string email, string password, int age, int weight) { int id = 3; stringstream ss; ss << "INSERT INTO Users(User_id, Name, Email, Password, Age, Weight) VALUES ('"+id+"', '"+name+"', '"+email+"', '"+password+"', '"+age+"', '"+weight+"');"; string queryBuffer = ss.str(); const char* query = queryBuffer.c_str(); if (mysql_query (con, query)) { cout << "SQL QUERY ERROR : " << mysql_error (con) << endl; } else { cout << endl << endl << " YOUR DETAILS ARE SUCCESSFULLY STORED INTO DATABASE!" << endl; cout << " Kindly login to experience the Application" << endl; } } int main () { MYSQL* con; con = mysql_init (NULL); // On success mysql_real_connect () returns ==> 1 if (!(mysql_real_connect(con, "localhost", "u0_a259", "", "Diet_db", 0, NULL, 0))) { cout << "SQL Connection Error: " << mysql_error (con) << endl; } signUp (con, "Govind", "govind@gmail.com", "pass", 19, 54); return 0; } I am getting error while inserting into table in my database $ clang++ signup.cpp -o a -L/../usr/include/mariadb/mysql -lmysqlclient && ./a ERROR : warning: adding 'int' to a string does not append to the string [-Wstring-plus-int] ss << "INSERT INTO Users(User_id, Name, Email, Password, Age, Weight) VALUES ('"+id+"', '"+name+"', '"+email+"', '"+password+"', '"+age+"', '"+weight+"');"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ signup.cpp:22:85: note: use array indexing to silence this warning ss << "INSERT INTO Users(User_id, Name, Email, Password, Age, Weight) VALUES ('"+id+"', '"+name+"', '"+email+"', '"+password+"', '"+age+"', '"+weight+"');"; ^ & [ ] signup.cpp:22:88: error: invalid operands to binary expression ('const char *' and 'const char [5]') ss << "INSERT INTO Users(User_id, Name, Email, Password, Age, Weight) VALUES ('"+id+"', '"+name+"', '"+email+"', '"+password+"', '"+age+"', '"+weight+"');"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
amran
Hii hello. I'm new in this group. I wanted to ask. I want to create an app. But I don't have any knowledge about the programming. So than I need to hire app developer to create the app. Full stack developer or front end developer?. And how much it will cost me. Please guys do give advice. I will be really2 appreciate it
moni
// Please help why its not working // Question is search element in rotated array #include <iostream> using namespace std; int pivotElement(int array[], int size) { int s = 0, e = size - 1, mid; while (s < e) { mid = (s + e) / 2; if (array[0] <= array[mid]) { s = mid + 1; } else { e = mid; } } return s; } int binarySearch(int arr[], int key, int start, int end) { int s = start, e = end; int mid; while (s <= e) { mid = (s + e) / 2; if (key == arr[mid]) { return mid; } else if (key < arr[mid]) { e = mid - 1; } else if (key > mid) { s = mid + 1; } } return -1; } int searchInArray(int array[], int size, int key) { int getPivote = pivotElement(array, size); if (key >= array[getPivote] && key <= array[size-1]) { cout << "hi"; return binarySearch(array, key, /*s*/ getPivote, /*e*/ size-1); } else { cout << "byy"; /* code will write aftre some time*/ } } int main() { int array[5] = {7, 9, 1, 2, 3}; int key = 3; cout << searchInArray(array, 5, key); return 0; }
moni
// Please help why its not working // Question is search element in rotated array #include <iostream> using namespace std; int pivotElement(int array[], int size) { int s = 0, e = size - 1, mid; while (s < e) { mid = (s + e) / 2; if (array[0] <= array[mid]) { s = mid + 1; } else { e = mid; } } return s; } int binarySearch(int arr[], int key, int start, int end) { int s = start, e = end; int mid; while (s <= e) { mid = (s + e) / 2; if (key == arr[mid]) { return mid; } else if (key < arr[mid]) { e = mid - 1; } else if (key > mid) { s = mid + 1; } } return -1; } int searchInArray(int array[], int size, int key) { int getPivote = pivotElement(array, size); if (key >= array[getPivote] && key <= array[size-1]) { cout << "hi"; return binarySearch(array, key, /*s*/ getPivote, /*e*/ size-1); } else { cout << "byy"; /* code will write aftre some time*/ } } int main() { int array[5] = {7, 9, 1, 2, 3}; int key = 3; cout << searchInArray(array, 5, key); return 0; }
Anonymous
opengl #include <GLFW/glfw3.h> if (!glfwInit()) fprintf(stderr,"Error \n"); compile success runtime : fprintf output hardware ryzen os ubuntu wsl
moni
what
as
#include <stdio.h> #include <string.h> int main() { int key; printf("no: "); scanf("%d ", &key); printf("no2: "); char string[20]; fgets(string, 20, stdin); printf("The String is %s\n", string); return 0; }
as
what is wrong?
Maksim
what do you want?
as
i cannot write "no2: "