Yazidi
but i = 0 !
Yazidi
what should i do?!
Roshan
So the name counting will start from 1
Yazidi
but i want the first element of the array
Yazidi
so that i want it to be 0 in the beginning
Yazidi
is there a trick to do?
Roshan
so that i want it to be 0 in the beginning
for (int i=0 ; i<num; i++) { cout << "Enter studen's name (" << i << "): "; cin >> student[i]; cout << "Enter student's score (" << i << "): "; cin >> score[i]; cout << endl; }
Yazidi
thanks a lot
Roshan
thanks a lot
Welcome!!
Anonymous
is usleep_range accurate for 1 ms ? I used msleep before ,but is not accurate for 1ms .After using ftrace and perf tracing ,I recognized it sleep the thread 20 ms not 1 ms .So,which is the most accurate function to sleep thread 1 ms in kernel ?
Adex
I want to learn c++ who will teach me
klimi
I want to learn c++ who will teach me
I wonder if you are just naive or something else
Adex
Yj
Adex
Teach me na
klimi
i don't know what "Yj" and "na" is
Adex
I want to learn
klimi
I want to learn
Then you can learn? What is stopping you?
olli
I want to learn
https://en.cppreference.com/w/
Roshan
I want to learn
https://www.youtube.com/playlist?list=PLlrATfBNZ98dudnM48yfGUldqGD0S4FFb
Swapnil
#include <iostream> #include <string> using namespace std; class Customer { public: int cId[10]; string cName[10]; int purchasedProduct[10]; void add_customer() { for(int i = 0; i < 3; i++) { cout << "Type customer Name :"; cin >> cName[i]; cout << "Type customer id : "; cin >> cId[i]; cout << "purchased product : "; cin >> purchasedProduct[i]; } } void viewCustomer() { for (int i = 0; i < 3; i++) { cout << "Your customer Name is: " << cName[i] << "\n"; } } }; class Product: public Customer { public: int pId[10]; string pName[10]; float price[10]; void add_product() { for(int i = 0; i < 2; i++) { cout << "Type product Name :"; cin >> pName[i]; cout << "Type product id "; cin >> pId[i]; cout << "Type product price "; cin >> price[i]; } } void viewProduct() { for (int i = 0; i < 2; i++) { cout << "Your Products : " << pId[i] << "\n"; } } }; class Manager: public Product { public: int del; void deleteProduct(){ cout << "enter product id to be deleted :"; cin >> del ; for(int i=0;i<2;i++) { if(pId[i]==del) { pId[i]=0; pName[i]= "null"; price[i]=0; } } cout << " product deleted ! \n"; viewProduct(); // for(int i = 0; i < 3; i++) { // cout << "Your customer Name is: " << cName[i] << "\n"; } }; class Cart: public Product { public: int cartPid[10]; string cartProductName[]; string acessV; void addTocart(){ for(int i=0;i<2;i++) { cout << "add product to be entered in cart \n" ; cin >> acessV ; if(cartProductName[i]== acessV ) { cartPid[i]= pId[i]; cartProductName[i]= pName[i]; cout << "Your product: " << acessV << "\n"; } } } void viewCart(){ for(int i=0;i<2;i++) { cout << "Your Products : " << cartPid[i] << "\n"; cout << "Your Products : " << cartProductName[i] << "\n"; } } }; int main() { int ch; //Product myObj; Customer myCustomer; Manager myManager; Cart myCart; while(1){ cout<<"\n \t\t\t=========================\n"; cout<<"\n\t\t\tWELCOME TO UCB CLOTHING STORE \n"; cout<<"\n \t\t\t=========================\n\n"; cout<<"\n \t\t\t* * * * * * * * * * * * "; cout<<"\n\t\t\t 1.add product"; cout<<"\n\t\t\t 2.Customer details"; cout<<"\n\t\t\t 3.view customer"; cout<<"\n\t\t\t 4.add to cart"; cout<<"\n\t\t\t 5.delete product"; cout<<"\n\t\t\t 6.EXIT"; cout<<"\n\t\t\t* * * * * * * * * * * *\n"; cout<<"\n\t\t\t Enter Your choice: "; cin>>ch; switch(ch){ case 1: myManager.add_product (); break; case 2: myCustomer.add_customer(); break; case 3: myCustomer.viewCustomer(); break; case 4: myCart.addTocart(); myCart.viewCart(); break; case 5: myManager.deleteProduct(); break; case 6: exit(0); break; default: cout<<"Enter valid choice\n"; break; } } }
Swapnil
that void view cart function is not working
Swapnil
Process exited after 64.04 seconds with return value 3221225477
Swapnil
😭
olli
#include <iostream> #include <string> using namespace std; class Customer { public: int cId[10]; string cName[10]; int purchasedProduct[10]; void add_customer() { for(int i = 0; i < 3; i++) { cout << "Type customer Name :"; cin >> cName[i]; cout << "Type customer id : "; cin >> cId[i]; cout << "purchased product : "; cin >> purchasedProduct[i]; } } void viewCustomer() { for (int i = 0; i < 3; i++) { cout << "Your customer Name is: " << cName[i] << "\n"; } } }; class Product: public Customer { public: int pId[10]; string pName[10]; float price[10]; void add_product() { for(int i = 0; i < 2; i++) { cout << "Type product Name :"; cin >> pName[i]; cout << "Type product id "; cin >> pId[i]; cout << "Type product price "; cin >> price[i]; } } void viewProduct() { for (int i = 0; i < 2; i++) { cout << "Your Products : " << pId[i] << "\n"; } } }; class Manager: public Product { public: int del; void deleteProduct(){ cout << "enter product id to be deleted :"; cin >> del ; for(int i=0;i<2;i++) { if(pId[i]==del) { pId[i]=0; pName[i]= "null"; price[i]=0; } } cout << " product deleted ! \n"; viewProduct(); // for(int i = 0; i < 3; i++) { // cout << "Your customer Name is: " << cName[i] << "\n"; } }; class Cart: public Product { public: int cartPid[10]; string cartProductName[]; string acessV; void addTocart(){ for(int i=0;i<2;i++) { cout << "add product to be entered in cart \n" ; cin >> acessV ; if(cartProductName[i]== acessV ) { cartPid[i]= pId[i]; cartProductName[i]= pName[i]; cout << "Your product: " << acessV << "\n"; } } } void viewCart(){ for(int i=0;i<2;i++) { cout << "Your Products : " << cartPid[i] << "\n"; cout << "Your Products : " << cartProductName[i] << "\n"; } } }; int main() { int ch; //Product myObj; Customer myCustomer; Manager myManager; Cart myCart; while(1){ cout<<"\n \t\t\t=========================\n"; cout<<"\n\t\t\tWELCOME TO UCB CLOTHING STORE \n"; cout<<"\n \t\t\t=========================\n\n"; cout<<"\n \t\t\t* * * * * * * * * * * * "; cout<<"\n\t\t\t 1.add product"; cout<<"\n\t\t\t 2.Customer details"; cout<<"\n\t\t\t 3.view customer"; cout<<"\n\t\t\t 4.add to cart"; cout<<"\n\t\t\t 5.delete product"; cout<<"\n\t\t\t 6.EXIT"; cout<<"\n\t\t\t* * * * * * * * * * * *\n"; cout<<"\n\t\t\t Enter Your choice: "; cin>>ch; switch(ch){ case 1: myManager.add_product (); break; case 2: myCustomer.add_customer(); break; case 3: myCustomer.viewCustomer(); break; case 4: myCart.addTocart(); myCart.viewCart(); break; case 5: myManager.deleteProduct(); break; case 6: exit(0); break; default: cout<<"Enter valid choice\n"; break; } } }
the architecture of your code doesn't make sense to me, what are you trying to achieve? e.g. why does a single customer have ten names? Why is a product a customer? Why has a product 10 Names? Why is a manager a product?
Swapnil
im now to c++ bro
Swapnil
new*
Swapnil
rose shutup😂
Swapnil
tr told me to do that way
olli
Without knowing what you're trying to do it's hard to tell what's wrong (apart from syntax errors).
Xudoyberdi
😁
Roshan
😁
😁
PaAaAria
Hi everyone I have a differential equation. I've used euler method and heun method to solve it but the codes give me different answers, could anybody help me to Fix this problem?
Anonymous
What is the back ground of c,c++..
ברני
What is the back ground of c,c++..
What do you mean "background"
Anonymous
Historically? C was developed to make it easier to develop complex systems such as operationg systems and have a general purpose language that was higher level. Other higher level languages at that time where very narrow in scope. C++, from what i know bjarne wanted to have a safer version of c. But it supported object oriented programming as well, which was a new and rising concept at the time and i think greatly helped to its success. People critical towards object orientation (at the time some argued that through the abstraction there would be a too big performance loss and other arguments... ) mostly stayed with C. And it is still used for embeded systems until this day because it is "easy" to write a compiler for and has very little overhead. But thats just all out of memory and things i heared so dont quote me on any of this 😅
Anonymous
Or even less
g3rm4n
hey, how can I call a function 3 times with a "for" loop
Anonymous
For example Jason Turner wanted to rewrite Doom to C++ Actually it was really hard task And the only thing he did was just fixing compiler errors And after he fixed the errors, a benchmark he had ran faster than on the original version
Roshan
g3rm4n
Put the function call inside the loop 😂
i put inside the loop but it call only one time
Anonymous
For example Jason Turner wanted to rewrite Doom to C++ Actually it was really hard task And the only thing he did was just fixing compiler errors And after he fixed the errors, a benchmark he had ran faster than on the original version
Sure it all depends on the code you write, really. C++ Compilers do an insane job at optimazing things, so unless your really restricted and know exactly what you are doing C++ surely runs pretty mich the same. However, especially in modern c++ there are a lot of things like smart pointers and safety checks that lead to a small overhead, but at least for me that wasnt really an issue ever. The biggest part ist that the vode you write doesnt do anything unnecesarry or do things in a stupid way.
Roshan
i put inside the loop but it call only one time
Isn't there any logical error?
Roshan
Show code...
g3rm4n
printf("\n\nPlease enter first string:\n\n"); char FirstString[STR_SIZE] = { "Abc 123 $#& cDE AAA" }; fgets(FirstString, STR_SIZE, stdin); FirstString[strlen(FirstString) - 1] = '\0'; // cut the " \n " after the string for (int i = 0; i <=3; ++i) { rotate_right(FirstString); } puts(FirstString); I need to move 3 words from the end of the string to the beginning
g3rm4n
it moving only one word..
g3rm4n
yeah i know, i put equal sign by mistake
Yazidi
#include <iostream> #include <string> using namespace std; void info(string [] , double []int&); void print(string[], double[], int); int main () { int num; cout << "How many students do you have? "; cin >> num; cout << endl; string student[num]; double score[num]; info(student, score, num); print(student, score, num); return 0; } // to get information of students.. void info (string& student[], double& score[], int& num) { for (int i=0; i<num; i++) { cout << "Enter studen's name (" << i+1 << "): "; cin >> student[i]; cout << "Enter student's score (" << i+1 << "): "; cin >> score[i]; cout << endl; } } // to calculate the lowest score.. void print(string student[], double score[], int num) { for (int j=0; j<num; j++) { for (int i=0; i<num; i++) { int min; if (score[i] > score[i+1]) { min = score[i]; score[i] = score[i+1]; score[i+1] = min; } } } cout << student[0] << " , " << student[1]; }
Roshan
#include <iostream> #include <string> using namespace std; void info(string [] , double []int&); void print(string[], double[], int); int main () { int num; cout << "How many students do you have? "; cin >> num; cout << endl; string student[num]; double score[num]; info(student, score, num); print(student, score, num); return 0; } // to get information of students.. void info (string& student[], double& score[], int& num) { for (int i=0; i<num; i++) { cout << "Enter studen's name (" << i+1 << "): "; cin >> student[i]; cout << "Enter student's score (" << i+1 << "): "; cin >> score[i]; cout << endl; } } // to calculate the lowest score.. void print(string student[], double score[], int num) { for (int j=0; j<num; j++) { for (int i=0; i<num; i++) { int min; if (score[i] > score[i+1]) { min = score[i]; score[i] = score[i+1]; score[i+1] = min; } } } cout << student[0] << " , " << student[1]; }
Roshan
Also the one below it... Imagine i is now at the last element. Then what is at score[i+1] ??
Lava
Am I allowed to ask improvements for a small code also am I allowed to send the question link from a site ?
PaAaAria
ofstream command does not work is this code, does anybody know the reason? #include <iostream> #include <cmath> #include <cmath> #include <fstream> using namespace std; int main () { ofstream myfolder ("Rung-kutta-second order.txt"); double x1,x2,a,b,h,y1,y2,y,k1,k2,f1,f2,y_new,x0; int n; a=0; b=2;h=0.1;n=(b-a)/h; y1=b; x0=a; for (int i=1;i<=n; i++) { x1=x0; f1=y1-pow(x1,2)+1; k1=h*f1; x2=x0+h; y2=y1+k1; f2=y1-pow(x2,2)+1; k2=h*f2; y_new=y1+(k1+k2)/2; cout<<x2<<"\t"<<y_new<<endl; myfolder<<x2<<"\t"<<y<<endl; y1=y_new; x0=x2; } myfolder.close (); return 0; }
Anonymous
固定规则 **您无权获得答案,对未回答的问题生气会警告您。 *不检查您在Google(或任何其他搜索引擎) 中的问题 ) 首先会警告您。 *要求解决作业 测试 其他 Rules pinned * You are not entitled to an answer, getting angry about not answered questions will get you warned. * Not checking your problem in google (or any other search engine) first will get you a warn. * Asking to solve an assignment test whatever (达到长度限制,请私聊翻译全文)
Maxat
good evening i am a new member of the group :)
Ishank
Hey how many are from outside India ?
Roshan
Me
Good
Anonymous
I'm from Brazil
Junaid
When I say bgd how can some study ?
Not able to understand your saying
Anonymous
Ok for studing this subject what some body intended to do?
Xudoyberdi
Dark
someone help me how to normalise the data within array from 0 to 255 not exceed value when something added on it Array is 2d
Anonymous
hi
Anonymous
By this could I be matured enough to study further
Dark
i don't know how to use if statement with 2d array