Maksim
i cannot write "no2: "
try scanf(" %d", &key);
as
scanf("%d ") is working
as
but it write no2 after fgets
Levi
fputs(string,sizeof(string),stdout);
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 << "81"; return binarySearch(array, key, /*s*/ getPivote, /*e*/ size-1); } else { cout << "08"; /* 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; }
Shuhash
Is it possible to create function using switch case ?
\Device\NUL
Is this considered as a spam ? @admin
\Device\NUL
fputs(string,sizeof(string),stdout);
Isn't fputs expect two argument ? char * and FILE *stream ?
\Device\NUL
scanf("%d ", &key); fflush(stdin);
Standard C or C++ doesn't define fflush if it's used for flushing stdin
\Device\NUL
#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; }
input with scanf will leave remaining newline in the inpu stream if you input it with enter or EOF if you end it with EOF signal. place getchar() after scanf. Btw, fgets() will read newline if you input it with enter. Consider using max field width in the scanf, That's another safe way to input string without using fgets Ex : scanf("%len[^\n]", str)
\Device\NUL
puts and fputs are different
But you pass three arguments
\Device\NUL
fputs(string,sizeof(string),stdout);
> fputs(string, sizeof(string), stdout)
Anonymous
What about youth c plus plus to do mit lab
Raj
🔥
Nisim
https://pcapplusplus.github.io/docs/install/build-source/vs
AboagyeOkyere
Please who can help me with this
Joo
Please I need an explaination on containers and their real life applications in C++
I use Arch
Please I need an explaination on containers and their real life applications in C++
STL containers? Well, imagine a task management (todo) application. It needs to have an ability to create tasks, delete ones etc. And there are containers! You can just use std::vector (or something that is more convenient in your situation) and it will let you easily do the things. For being more laconic - every application that uses count-changable data uses STL containers. And it's almost all the applications
I use Arch
🥺 I don't understand every Word in this
Tell me what you don't understand and I'll try to explain
Joo
I now understand it but my problem is with the various containers
Joo
When is it good to use each container
I use Arch
When is it good to use each container
Different containers implemented in different ways. For example, vector is unbroken sequence of bytes while list is a bunch of elements linked to each other by pointers (if I remember correctly and I can mistake). There is the link that will help you to decide what container is better to use. https://embeddedartistry.com/blog/2017/08/23/choosing-the-right-stl-container-general-rules-of-thumb Actually, you can just use Internet with a "difference between STL containers" query.
Nisim
How can help me to install this package on vs 2019 PcapPlusPlus
HaiNahi
How do I get a job?
Shuhash
Wdym ?
Is it possible to use switch case inside af unction ?
Shuhash
If i use switch case for addition subtraction and divide is it possible to create and call a single function for all these 3 operations
Nisim
help?
Anonymous
Hi everyone is there a WhatsApp group for programming students?
yasmine
the best for everyone
// write a function to make Square and rectangle with living room and kitchen #include <stdio.h> void drow_rect(int length , int width ) ( k, j ; length /=2; width/ =4; to// to minimize the actual size of it for (j=1, j<=width,j++) { printf("n\n\"); for(k=1, k<=length,k++) printf("\ xDB"); // from the hexedecemil printf("\n"); } ) int main () { printf("\n living room"); drow_rect(22,5); printf("\n closet\n"); drow_rect(4,5); printf("\n kitchen\n"); drow_rect(16,5); printf("\n bedroom\n"); drow_rect(12,12);' }
the best for everyone
could I know what is the mistake here ?
\Device\NUL
// write a function to make Square and rectangle with living room and kitchen #include <stdio.h> void drow_rect(int length , int width ) ( k, j ; length /=2; width/ =4; to// to minimize the actual size of it for (j=1, j<=width,j++) { printf("n\n\"); for(k=1, k<=length,k++) printf("\ xDB"); // from the hexedecemil printf("\n"); } ) int main () { printf("\n living room"); drow_rect(22,5); printf("\n closet\n"); drow_rect(4,5); printf("\n kitchen\n"); drow_rect(16,5); printf("\n bedroom\n"); drow_rect(12,12);' }
Have you notice the compiler message ? It's hurt you know if you warn or talk to somebody, but he/she doesn't notice it Why would you need to minimize the actual size ? I don't know, you want to find the area or draw the square/rectangle This is how to draw it. for (int i = 0; i < len; i++) putchar('*'); putchar('\n'); for (int i = 0, n = wid - 2, k = len - 2; i < n; i++) { putchar('*'); for (int j = 0; j < k; j++) putchar(' '); puts("*"); } for (int i = 0; i < len; i++) putchar('*'); putchar('\n');
Shuhash
Yes
Will you share any example or any snippet of code
\Device\NUL
Will you share any example or any snippet of code
main function with switch case inside is the example
Muhammed Ashik
int i; for(i=10;i<16;i++){cout<<"\n",i;} return 0; Need output 10 11 12 13 14 15 But not working...plz correct
shriman_deepak
int i; for(i=10;i<16;i++){cout<<i<<endl;} return 0; Need output 10 11 12 13 14 15 But not working...plz correct
Shuhash
main function with switch case inside is the example
Single function that should be called in the cases 1,2,3 that single function should do operation like add,sub,div , seperately for each cases
Morax
Hi guys, need some advice. I am having a little difficulty in making star patterns in C. Basic triangle or square are easy.. But some advanced patterns are taking time and my code is usually very long, whereas there are shorter codes possible. Is there any way I could improve this?
Morax
* * * * * * * * * *
Morax
These kinda patterns ...
Morax
Actually I'm a beginner, and this is for practicing nested loops.
Anonymous
* * * * * * * * * *
#include <stdio.h> int main() { int row,patternNum,column; printf("Enter Dimension for Pattern : "); scanf("%d",&patternNum); for(row=1;row<=patternNum;row++) { for(column=1;column<=row;column++) { printf("*"); } printf("\n"); } return 0; }
Morax
I am talking about some more complicated ones..
Anonymous
I am talking about some more complicated ones..
i m also a beginner And for complicated pattern programs I try to do that on paper first like - on which condition i have to print space and on which any other character
Morax
* * * * * * * * * * * * * * * * *
Morax
Patterns like these ones..
kherlepha
Hi everyone
\Device\NUL
* * * * * * * * * * * * * * * * *
You should give input and output example
\Device\NUL
i want to draw the square and rectangle
Already wrote it, check the message
\Device\NUL
Edit as you need
Ludovic 'Archivist'
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)
Include files are an issue in compilation of very very large program. A company I know has compile times of around 40 minutes for their application, this means that changing a header implies recompiling the entire 40 minutes worth of potential changes. Modules would make that mostly unnecessary Header files have been an issue/downside of C++ for the past 20 years so modules are a more than welcome fix
the best for everyone
why did you write All these loops
\Device\NUL
why did you write All these loops
What part you don't understand ?
the best for everyone
What part you don't understand ?
for (int i = 0, n = wid - 2, k = len - 2; i < n; i++)
\Device\NUL
for (int i = 0, n = wid - 2, k = len - 2; i < n; i++)
Okay, simple answer from me, have you tried it ?