Ashish
Or send me the pdf from where i can learn it
Lava
Just see a course on udacity or coursera , edx etc
Ashish
Sry for that
Gulshan
Why did you took cs if you want to cheat in exam ?
Gulshan
You may have selected another stream of your liking... Why to waste parents hard earned money
Xudoyberdi
su
Not all students wished to enter a university on their own😂
Responsive child do not fuck with chat, actually
olli
Not all students wished to enter a university on their own😂
fair enough, but once you're applying for a job and are in an interview you wish you would have paid attention. So try to do your assignments and learn, your future self will appreciate it.
Rifat
Write a program using while loop that ask the user about how many number he/she wants to enter. Your task is to take input those many number and calculate their sum. » #include <stdio.h> int main () { int n,i,sum = 0; scanf("%d",&n); i=1; while (i<=n) { sum +=i*10; ++i; } printf("%d\n",sum); return 0; }
Rifat
can anyone let me know what's wrong with that? I am not getting expected answer
Rifat
you missed acually reading integer numbers
if you don't mind can you just show the starting? I am really depressed with this code :( I was doing fight more than 2 hours against it :(
Rifat
Apk
you don't need to store actually
Apk
in the while loop, you can take input and add it to the sum, without any need to store the input
Apk
But if you really want to store, use an array
ברני
#include <stdio.h> int main() { int n, i, sum = 0; printf("Enter a positive integer: "); scanf("%d", &n); i = 1; while (i <= n) { sum += i; ++i; } printf("Sum = %d", sum); return 0; }
ברני
I have tried that at the very begining. But it's not giving actual result
This is how you check sum of a positive number in a while loop. Any question that you have, Google has the answer. Don't rush to arrays if you don't know using printf scanf yet.
ברני
And don't send pics, the admins will warn you
Lava
Idk c ,but in c++ logically I would put a variable that takes the number the user enters and the value of that variable is being added to sum on each loop run . The loop would run till the 'n' number of numbers user wants to enter
Lava
I see that you only took in / scanned the n value but not the numbers the user wants the sum of .
Anonymous
how do i split stereo to mono and recombine
ברני
Hey, I have a task on C that I didn't understand well Question 2 - to run Write a function that takes a set of two-dimensional NXN squares and its size (number of rows / number of columns) and updates the main diagonal members in the value of the maximum member in the row. You must write and use an auxiliary function which receives a one-dimensional array and its size and returns the maximum limb in it. **************************************** why do I need single array function? for the calculation?
Alex
could you suggest c++ code analyzer for linux?
Gulshan
Btw which distro?
Alex
ubuntu. should I add cppcheck to CMakefile?
Alex
what is the usual approach?
Gulshan
what is the usual approach?
There's a gui version available
Alex
I don`t like gui. Ok probably, I will add it as Emacs shortcut
Alex
apt install cppcheck
I mean how to call it, not install
Gulshan
Then man cppcheck
Alex
should I use build system or integrate it to IDE
Andrey
why many people write code like this: while((*s++ = *t++) != '\0') ; isnt better to write this version? while((*s++ = *t++) != '\0');
ברני
That the semicolon is a line down?
ברני
yes
Yes you right, it is better
ברני
You know what is better then that? for loops 😏
olli
why many people write code like this: while((*s++ = *t++) != '\0') ; isnt better to write this version? while((*s++ = *t++) != '\0');
For readability reasons, using a semicolon in a new line makes it more obvious that the loop body is empty.
Anonymous
Hi, how do I list all files of an entire drive in a text file? I have been able to list files of only one directory at a time with WinAPIs. Can anyone suggest me something?
Alex
Hi, how do I list all files of an entire drive in a text file? I have been able to list files of only one directory at a time with WinAPIs. Can anyone suggest me something?
you have function for one directory to list all files. lets call it get_files(const string &path) this func should call get_files(dir_path) for all directories are found in the dir
Alex
what details do you need?
Anonymous
What functions should I use I have got FindFirstFile, dirent struct and C++17 recursive_directory_iterator?
Anonymous
Age???
Dima
wtf
Ali
#include <stdio.h> #include <string.h> #include <math.h> #include <float.h> int main() { char machine_a[4]; char machine_b[4]; char machine_c[4]; char extra_var; printf("enter the name for first machine.\n"); fgets(machine_a , 4, stdin); extra_var = getchar(); printf("enter the name for second machine\n"); fgets(machine_b , 4, stdin); extra_var = getchar(); printf("enter the name for third machine.\n"); fgets(machine_c , 4, stdin); extra_var = getchar(); float a = 0.0, b = 0.0, c = 0.0; float x; float total_production; float max_production = -1; float min_production=flt_max; char max_machine[4]; char min_machine[4]; printf("enter the 2 productions of machine %s:\n", machine_a); scanf("%f", &x); a = a + x; scanf("%f", &x); a = a + x; if(a > max_production) { max_production = a; strcpy(max_machine,machine_a); } if(a < min_production) { min_production = a; strcpy(min_machine , machine_a); } printf("enter the 2 productions of machine %s:\n", machine_b); scanf("%f", &x); b = b + x; scanf("%f", &x); b = b + x; if(b > max_production) { max_production = b; strcpy(max_machine , machine_b); } if(b < min_production) { min_production = b; strcpy(min_machine , machine_b); } printf("enter the 2 productions of machine %s:\n", machine_c); scanf("%f", &x); c = c + x; scanf("%f", &x); c = c + x; if(c > max_production) { max_production = c; strcpy(max_machine , machine_c); } if(c < min_production) { min_production = c; strcpy(min_machine , machine_c); } total_production = a + b + c; float avg_production = total_production / 3; printf("total production: %0.1f\n", total_production); printf("average production: %0.1f\n", avg_production); printf("machine with maximum production: %s\n", max_machine); printf("machine with minimum production: %s\n", min_machine); return 0; }
Ali
Any one can debug
Dima
#include <stdio.h> #include <string.h> #include <math.h> #include <float.h> int main() { char machine_a[4]; char machine_b[4]; char machine_c[4]; char extra_var; printf("enter the name for first machine.\n"); fgets(machine_a , 4, stdin); extra_var = getchar(); printf("enter the name for second machine\n"); fgets(machine_b , 4, stdin); extra_var = getchar(); printf("enter the name for third machine.\n"); fgets(machine_c , 4, stdin); extra_var = getchar(); float a = 0.0, b = 0.0, c = 0.0; float x; float total_production; float max_production = -1; float min_production=flt_max; char max_machine[4]; char min_machine[4]; printf("enter the 2 productions of machine %s:\n", machine_a); scanf("%f", &x); a = a + x; scanf("%f", &x); a = a + x; if(a > max_production) { max_production = a; strcpy(max_machine,machine_a); } if(a < min_production) { min_production = a; strcpy(min_machine , machine_a); } printf("enter the 2 productions of machine %s:\n", machine_b); scanf("%f", &x); b = b + x; scanf("%f", &x); b = b + x; if(b > max_production) { max_production = b; strcpy(max_machine , machine_b); } if(b < min_production) { min_production = b; strcpy(min_machine , machine_b); } printf("enter the 2 productions of machine %s:\n", machine_c); scanf("%f", &x); c = c + x; scanf("%f", &x); c = c + x; if(c > max_production) { max_production = c; strcpy(max_machine , machine_c); } if(c < min_production) { min_production = c; strcpy(min_machine , machine_c); } total_production = a + b + c; float avg_production = total_production / 3; printf("total production: %0.1f\n", total_production); printf("average production: %0.1f\n", avg_production); printf("machine with maximum production: %s\n", max_machine); printf("machine with minimum production: %s\n", min_machine); return 0; }
/warn read the rules
Dima
BRUH
Anonymous
BRUH
What ma'am
Anonymous
Help me with c
Hadaward 'Solly'
Help me with c
that was incredibly specific.
Артём
How does std::initializer_list's ctor work under the hood? In other words, how can I work with braced-init-list without using std::initializer_list?
Артём
I'm sorry but all my google results refer to use of std::initializer_list, but I need not to deal with STL.
Roxifλsz 🇱🇹
Help me with c
/warn PM without asking
Lava
Can we use void functions as int functions by just getting them to return a garbage value ? Will it effect the output ?
Lava
So if I do int display( int num ) { cout<< num ; return 0; } It won't compile ?
Roshan
So if I do int display( int num ) { cout<< num ; return 0; } It won't compile ?
Why return 0 if no need to return anything. Void will work....🤔
Lava
Not in habit of writing void 😅
Hadaward 'Solly'
well
Hadaward 'Solly'
there's always a first time
Lava
It will only return 0... where is the "void"?
This would be preferred void display( int num ) { cout<< num ; return ; }
Talula
This would be preferred void display( int num ) { cout<< num ; return ; }
Yes but when you say something like int a = display(10); Compiler will give you error...
Lava
Ok , I will try to get used to void then . Thank you all .