Φ ☭
/get cppbookguide
Hanz
Guys, what is this thing called, its so weird: [](args...) { /* body */ }
Hanz
looks like lambda
Isnt lambda keyword is python?
Hanz
I mean, what is it exactly?
Anonymous
closure is what its called
Hanz
Hanz
I see that this passed as argument, how is it possible too 😂
Anonymous
there are some functions in std::algorithms that use closures
Andrew
I see that this passed as argument, how is it possible too 😂
You can read about it https://en.cppreference.com/w/cpp/language/lambda
Jen
WTF are you doing?
You mean the actual program? If not then it was a silly mistake. Sorry.
Jen
I have a book thanks. It's not like I didn't knew the rules. I don't know how but I made a stupid mistake and my mind couldn't catch it.
Talula
Homework?
Talula
Read the rules and delete before you getting a warning.
Henry
Which book do u suggest best for C language
Anonymous
The c programming language
Henry
Author??
Anonymous
Brian W. Kerninghan
Adarsh
#include<bits/stdc++.h> using namespace std; int table[256]; void initialize() { table[0]=0; for(int i=0;i<256;i++)table[i]=(i&1)+table[i/2];// can anyone explain this line } int count(int n) { int res=table[n&0xff]; n=n>>8; res=res+table[n&0xff]; n=n>>8; res=res+table[n&0xff]; n=n>>8; res=res+table[n&0xff]; return res; } int main() { initialize(); cout<<count(40); return 0; }
Anonymous
fun(){ int n; scanf("%d", &n); for(int i=0; i<10^6; i++) printf("hello"); } what is rate of growth and time complexity for above block of code...?
Anonymous
Constant
u mean O(1) or O(10^6) ?
Anonymous
They are same
yeah they both are constant...so bot the answer is correct?
Apk
yeah they both are constant...so bot the answer is correct?
No, constant complexity is symbolized only by O(1)
Apk
Just ask the question
Anonymous
Anonymous
/rules
Anonymous
/rules
Anonymous
2n-2 n is the number of nodes...
Anonymous
yes...
Andrew
just ask
Emmanuel
Thanks
Anonymous
for cerr u can read the below article at https://www.geeksforgeeks.org/cerr-standard-error-stream-object-in-cpp/
Anonymous
to answer x==first, I will hv to see the code what I have understood, I think first is the head node of any linked list and x is the newly created node...
Anonymous
okay I hv not idea about it, so I can't ans right now bro...
Yuichi
whaaattt
Dan
/get cbook
Anonymous
Okay so it is function to delete any node from a linked list except the head node... 'x' is a pointer pointing to a node which is to be deleted... And 'first' is a pointer pointing to the head node of linked list... We are checking if 'x' is pointing to the head node or not by comparing with 'first' i.e [ if(x==first) ]... If 'x' is pointing to head node then, 'x' and 'first' pointers will have same address and then the message 'deletion of head node is not allowed' will be outputted and if 'x' is not pointing to head node then that node will be deleted...
Anonymous
AR
/get ide
AKILA
Yeah, I can help u
AKILA
🤔
Anonymous
Show code
barungh
What is the problem ?
AKILA
Is learning c worth?
AKILA
👍
AKILA
No
Why
Anonymous
Why
You should not be writing any new code in C
Anonymous
Then?
Legacy codebases can benefit from some knowledge of C
Anonymous
In that case just delete that part of the code which you're updating
Anonymous
And rewrite it in something sane if it is possible
The Shadow Monarch
using namespace std; #include <iostream> #include <math.h> int funct_bmi(int w, float h) { return w / (h * h); } class BMIweight { public: int weight; void set_weight(int w) { weight = w; } void put_weight() { cout << "Weight= " << weight << endl; } }; class BMIheight { public: float height; void get_height(float h) { height = h; } void put_height() { cout << "Height= " << height << endl; } }; class BMI : public BMIheight, public BMIweight { public: void put_BMI() { int BMI; BMI = funct_bmi(weight, height); cout << "Your BMI is: " << BMI << endl; } }; int main() { BMI a; cout << "Put weight(in kgs): "; cin >> a.weight; cout << "\nPut height(in meters): "; cin >> a.height; cout << "\n"; a.put_weight(); a.put_height(); a.put_BMI(); if (BMI > 25) { cout << "You are fat"; } else if (BMI < 15) { cout << "You are skinny af"; } else { cout << "You are fit"; } return 0; }
Anonymous
yes because BMI is the name of the class
Anonymous
you cannot just compare it to a number like that
Benjamin
/rules
Benjamin
Found this question online while practicing, tried coding and still finding challenges. Anyone to help, here's the Scenario... ZIT primary School is designing a student information system to keep records of their pupils. The information they wish to keep about each pupil  Pupil ID  First name  Surname  Age  Grade  Guardian phone number. The expected users of the system will include the head teacher, deputy head teacher and two teachers. The privileges of editing, adding and deleting records will only be handled by the head teacher and the deputy head teacher. Teachers will only be allowed to search or view records of students. Your group has been hired to design a demo program that uses arrays, files, loops and selection structures in C++ to meet the needs of ZIT primary school. For testing purposes, assume that there are only two Grades (1 & 2) and each grade has only 5 pupils. Your program must meet the following additional requirements a) Allow only authorised users (i.e whose credentials are stored in the text file) to logon b) After the user has logged on, the program should display the menu below 1. Add New Pupil 2. Delete Pupil 3. Search for Pupil 4. Edit Pupil Record 5. Display All Pupils by Grade 6. Exit c) All records should persist between program executions (i.e information must be save to the file when the user exits and reloaded from the file when the program is executed)
Francis
I have included in both but I get an error of multiple declaration
Hope you included pragma once or the guards in your .h file, prefer guards though
john
#include <stdio.h> int main() { char Name[20]; char lname[20;] float Math; float English; float Science; FILE *fp; fp = fopen ("Student.txt","a"); printf("Enter \"exit\" as First Name to stop reading user input."); fprintf(fp," Name"); fprintf(fp," Math "); fprintf(fp," English "); fprintf(fp," Science"); fprintf(fp," Average \n"); while (1) { printf("\nStudent First Name: "); scanf ("%s",Name); if (strcmp(Name, "exit") == 0) exit(1); printf("\nStudent Last Name: "); scanf ("%s",lname); printf("Math marks: "); scanf ("%f", &Math); printf("English mark : "); scanf ("%f", &English); printf("Science Marks : "); scanf ("%f", &Science); float sum=Math+English+Science; float Avg=sum/3 ; fprintf(fp," %s %s ",Name,lname); fprintf(fp," %f ",Math); fprintf(fp," %f ",English); fprintf(fp," %f ",Science); fprintf(fp," %f \n",Avg); } fclose(fp); FILE *fp; fp = fopen ("Student.txt","r"); return 0; }
john
how do i read only the average
The Shadow Monarch
john
Talula
can someone help me
What do you mean by "read only the average"?
mayway
Anyone can give link of friends reunion
Aditi
/get
Talula
Anyone can give link of friends reunion
Are you sure that "anyone" can give you that link?
Ehsan
/notes
Ehsan
#best-book
Talula
In Hindi tone of your voice changes statement, answer or question... the sentence remains the same.
Ehsan
#noendl
Ehsan
#c++_isnt_c_with_classes