Andrew
exactly wher i am wrong
the 2 last lines
Anonymous
What is the use of int main void ??
Faruk
A two-dimensional matrix with rownumber rows and columnNumber columns is stored in a one-dimensional dynamic array declared as below. int * arrayPtr = new int [rownumber, columnNumber] What is the C ++ script statement to use to access the southwestern neighbor of the index element in row i and column j of this matrix?
Faruk
friends can help you ?
Talula
What is the use of int main void ??
To return a value to OS...
Anonymous
#include<stdio.h> #include<math.h> int main(void){ int a,b,c; float d,x1,x2; printf("Enter the Value of a,b,c: "); scanf("%d%d%d",&a,&b,&c); d=(b*b)-4*a*c; if(d>0){ x1= ((-b)-sqrt(d))/2.0*a; x2= ((-b)+sqrt(d))/2.0*a; printf("x1=%f x2=%f",x1,x2); } else if(d=0){ printf("Both Roots Are Equal"); x1=-b; x2=x1; printf("x1=%f x2=%f",x1,x2); }else{ printf("Roots are Not Real"); } return(0); }
Andrew
It means function returns int and has no arguments
Anonymous
Okay
Hamza
What is the concept of capsulation in c++
Pavel
What is the concept of capsulation in c++
You mean encapsulation? https://www.tutorialspoint.com/cplusplus/cpp_data_encapsulation.htm
Ksj⁷
If im going to make an app using c++ where should i start? Is there am— like other app that can help me to make the app?
Nova
Hey guys, so I am trying to learn priority queue in c++ Which is by default Max heap priority_queue<int> pq; but to use it as min heap We have to use the following syntax priority_queue<int,vector<int>,greater<int>> pq; I know about greater<int> is comparator but What does vector represent here I mean why we have to write vector in it
Pavel
Hey guys, so I am trying to learn priority queue in c++ Which is by default Max heap priority_queue<int> pq; but to use it as min heap We have to use the following syntax priority_queue<int,vector<int>,greater<int>> pq; I know about greater<int> is comparator but What does vector represent here I mean why we have to write vector in it
Because you need to provide comparator (which is 3rd template parameter), you also need to provide the second template parameter as well (despite it having a default value). The same logic as with function calls with default values provided: foo(int a = 1, int b = 2, int c = 3); if you want to specify the third argument, you need to specify all three foo(1, 2, 4); std::vector<T> is the default value to the second template parameter, so providing std::vector<int> in your case doesn't change the behavior. https://en.cppreference.com/w/cpp/container/priority_queue
Anonymous
Plz solve my doubt #include <stdio.h> #include <stdlib.h> int main() { int i=2,d=2; while(d<100) { if(i<=d) { if(d%i==0&&i==d) { printf("%d",d); i=2; d++; continue; } if(d%i!=0) { i++; continue;} else break; } } } Is above code correct for printing prime numbers under 100
Ksj⁷
What platform you want to make it for?
Im not sure what platform is this but they want us to make computer based application
Ashraff
I need a project on hospital management system.... Please help me out. Thanks
sweezy
Plz solve it ) Write a code that prints out the nonnegative integers less than or equal to 100 using a) array implementation. b) list implementation. c) vector implementation.
Pavel
Im not sure what platform is this but they want us to make computer based application
So it's probably Windows? It is important, because if you need to do it on Mac or iOS or Android, then you need different tools If it's windows you can start with downloading Visual Studio (not Visual Studio Code) and watch some tutorials how to create a basic application using it. There are two ways: with or without WinForms. If you need to have some windows with buttons or other widgets in your app, then it may be easier to start with WinForms, if you don't need it, for example it's purely console or server-side application, then better start without it.
Ashraff
In cpp
Anonymous
In cpp
extern "C" {}
Engineer
https://floooh.github.io/2019/09/27/modern-c-for-cpp-peeps.html
Engineer
https://floooh.github.io/2019/09/27/modern-c-for-cpp-peeps.html
This is a good read just to understand different view points like so many views here🤓🤣
Pavel
like the strange typedef constructions to declare a struct
Emmanuel
#include<stdio.h> #include<stdlib.h> // include required libraries typedef struct movie // movie structure { char director[50]; // stores the director name char title[50]; // stores the title name int year; // stores the year }movie; // void read(movie * tab,int size) // read method read the movie details { for(int i=0;i<size;i++) // read size of movies { printf("Director : "); // reading movie details from user scanf("%s",&tab[i].director); // printf("Title : "); scanf("%s",&tab[i].title); printf("Year : "); scanf("%d",&tab[i].year); } } void write(movie * tab,int size) // write the movies on to the screen using write method { for(int i=0;i<size;i++) // print each movie details in array { printf("Director : %s\n",tab[i].director); printf("Title : %s\n",tab[i].title); printf("Year : %d\n",tab[i].year); printf("---------------------------\n"); } } movie * select(movie * tab1, movie *tab2,int size1,int size2,int yearp,int * ans_size) // select method with required parameters and return type movie array { movie * ans_list; // here is our answer movie array ans_list=(movie*)malloc((size1+size2)* sizeof(movie)); // allocate memory maxsize (size1+size2) *ans_size=0; // our answer size initilaize with 0 (we use ans size index for ans list) for(int i=0;i<size1;i++) // for every movie in list1 { if(tab1[i].year>=yearp) //check movie year is greater than or equal to year of production { ans_list[*ans_size]=tab1[i]; //store this movie in answer list *ans_size+=1; //increase size by 1 } } for(int i=0;i<size2;i++) // here also same for every movie in list2 and checking and add to ans list and increse ans size { if(tab2[i].year>=yearp) { ans_list[*ans_size]=tab2[i]; *ans_size+=1; } } return ans_list; //return our ans list } int main() { int fsize;//stores the list1 size int ssize;// stores the list2 size int yearp; // year of production //reading movies in first list and second list and year of production printf("Enter a size of the first list of movies : "); scanf("%d",&fsize); printf("Enter a size of the second list of movies : "); scanf("%d",&ssize); printf("Enter year of production : "); scanf("%d",&yearp); movie * list_1; // create list1 movie array list_1=(movie*)malloc(fsize* sizeof(movie)); //allocate memory to the list1 movie *list_2;//create list2 movie array list_2=(movie*)malloc(ssize* sizeof(movie)); // allocate memory to the list 2 printf("Enter the movies of first list\n"); // read(list_1,fsize); //reading list 1 data using read function printf("Enter the movies of second list\n"); read(list_2,ssize); // reading list 2 data using read function int ans_size; // our ans size movie * final_ans=select(list_1,list_2,fsize,ssize,yearp,&ans_size); //calling select method with required parameters printf("The following movies exceeded the year of production: %d\n",yearp); //printing write(final_ans,ans_size); // printing movie details in ans list (year greater than or equal to year of production) using write function return 0; }
Emmanuel
it has refused to compile please help
Emmanuel
Here is the question
Emmanuel
Homework 3 Define (using the typedef statement) a structure of 'movie' type with members: director (type char []), title (type char []), year (type int). Define 'read' and 'write' functions that read and write data, respectively: void read (movie * tab, int size) void write (movie * tab, int size) The 'tab' variable represents an array of movie-type structures. Define 'select' function with: * two pointers to arrays of movie-type structures, * two integers as theirs sizes, * variable of int type corresponding to the year of its production, * one pointer to integer corresponding to the size of returned array. as parameters. This 'select' function returns a pointer to an array of 'movie' structures, which contains these structures from both arrays which year component is greater or equal to the entered year. Write a program in which the user is asked to enter sizes of two arrays of movies and year. (Allocate (using malloc function) the memory for these two arrays) Next, the user inserts the data of structures into both arrays. Then, the program (using the 'select' function) creates a new array of movies, which year of the production exceeded the entered year and displays it on the screen. For example. Enter a size of first list of movies: 3 Enter a size of second list of movies: 2 Enter a year of production: 2007 Enter the movie data of the first list. Director: Morel Title: Taken Year: 2008 Director: Fincher Title: Seven Year: 1995 Director: Phillips Title: Joker Year: 2019 Enter the movie data of the second list. Director: Nolan Title: Inception Year: 2010 Director: Stone Title: Platoon Year: 1986 The following movies exceeded the year of production: 2007. Director: Morel Title: Taken Year: 2008 ------------------------------------- Director: Phillips Title: Joker Year: 2019 ------------------------------------- Director: Nolan Title: Inception Year: 2010 -------------------------------------
klimi
Homework 3 Define (using the typedef statement) a structure of 'movie' type with members: director (type char []), title (type char []), year (type int). Define 'read' and 'write' functions that read and write data, respectively: void read (movie * tab, int size) void write (movie * tab, int size) The 'tab' variable represents an array of movie-type structures. Define 'select' function with: * two pointers to arrays of movie-type structures, * two integers as theirs sizes, * variable of int type corresponding to the year of its production, * one pointer to integer corresponding to the size of returned array. as parameters. This 'select' function returns a pointer to an array of 'movie' structures, which contains these structures from both arrays which year component is greater or equal to the entered year. Write a program in which the user is asked to enter sizes of two arrays of movies and year. (Allocate (using malloc function) the memory for these two arrays) Next, the user inserts the data of structures into both arrays. Then, the program (using the 'select' function) creates a new array of movies, which year of the production exceeded the entered year and displays it on the screen. For example. Enter a size of first list of movies: 3 Enter a size of second list of movies: 2 Enter a year of production: 2007 Enter the movie data of the first list. Director: Morel Title: Taken Year: 2008 Director: Fincher Title: Seven Year: 1995 Director: Phillips Title: Joker Year: 2019 Enter the movie data of the second list. Director: Nolan Title: Inception Year: 2010 Director: Stone Title: Platoon Year: 1986 The following movies exceeded the year of production: 2007. Director: Morel Title: Taken Year: 2008 ------------------------------------- Director: Phillips Title: Joker Year: 2019 ------------------------------------- Director: Nolan Title: Inception Year: 2010 -------------------------------------
*sigh* I should at least give you a warning for this...
Talula
#include<stdio.h> #include<stdlib.h> // include required libraries typedef struct movie // movie structure { char director[50]; // stores the director name char title[50]; // stores the title name int year; // stores the year }movie; // void read(movie * tab,int size) // read method read the movie details { for(int i=0;i<size;i++) // read size of movies { printf("Director : "); // reading movie details from user scanf("%s",&tab[i].director); // printf("Title : "); scanf("%s",&tab[i].title); printf("Year : "); scanf("%d",&tab[i].year); } } void write(movie * tab,int size) // write the movies on to the screen using write method { for(int i=0;i<size;i++) // print each movie details in array { printf("Director : %s\n",tab[i].director); printf("Title : %s\n",tab[i].title); printf("Year : %d\n",tab[i].year); printf("---------------------------\n"); } } movie * select(movie * tab1, movie *tab2,int size1,int size2,int yearp,int * ans_size) // select method with required parameters and return type movie array { movie * ans_list; // here is our answer movie array ans_list=(movie*)malloc((size1+size2)* sizeof(movie)); // allocate memory maxsize (size1+size2) *ans_size=0; // our answer size initilaize with 0 (we use ans size index for ans list) for(int i=0;i<size1;i++) // for every movie in list1 { if(tab1[i].year>=yearp) //check movie year is greater than or equal to year of production { ans_list[*ans_size]=tab1[i]; //store this movie in answer list *ans_size+=1; //increase size by 1 } } for(int i=0;i<size2;i++) // here also same for every movie in list2 and checking and add to ans list and increse ans size { if(tab2[i].year>=yearp) { ans_list[*ans_size]=tab2[i]; *ans_size+=1; } } return ans_list; //return our ans list } int main() { int fsize;//stores the list1 size int ssize;// stores the list2 size int yearp; // year of production //reading movies in first list and second list and year of production printf("Enter a size of the first list of movies : "); scanf("%d",&fsize); printf("Enter a size of the second list of movies : "); scanf("%d",&ssize); printf("Enter year of production : "); scanf("%d",&yearp); movie * list_1; // create list1 movie array list_1=(movie*)malloc(fsize* sizeof(movie)); //allocate memory to the list1 movie *list_2;//create list2 movie array list_2=(movie*)malloc(ssize* sizeof(movie)); // allocate memory to the list 2 printf("Enter the movies of first list\n"); // read(list_1,fsize); //reading list 1 data using read function printf("Enter the movies of second list\n"); read(list_2,ssize); // reading list 2 data using read function int ans_size; // our ans size movie * final_ans=select(list_1,list_2,fsize,ssize,yearp,&ans_size); //calling select method with required parameters printf("The following movies exceeded the year of production: %d\n",yearp); //printing write(final_ans,ans_size); // printing movie details in ans list (year greater than or equal to year of production) using write function return 0; }
/report Homework?
klimi
Homework 3 Define (using the typedef statement) a structure of 'movie' type with members: director (type char []), title (type char []), year (type int). Define 'read' and 'write' functions that read and write data, respectively: void read (movie * tab, int size) void write (movie * tab, int size) The 'tab' variable represents an array of movie-type structures. Define 'select' function with: * two pointers to arrays of movie-type structures, * two integers as theirs sizes, * variable of int type corresponding to the year of its production, * one pointer to integer corresponding to the size of returned array. as parameters. This 'select' function returns a pointer to an array of 'movie' structures, which contains these structures from both arrays which year component is greater or equal to the entered year. Write a program in which the user is asked to enter sizes of two arrays of movies and year. (Allocate (using malloc function) the memory for these two arrays) Next, the user inserts the data of structures into both arrays. Then, the program (using the 'select' function) creates a new array of movies, which year of the production exceeded the entered year and displays it on the screen. For example. Enter a size of first list of movies: 3 Enter a size of second list of movies: 2 Enter a year of production: 2007 Enter the movie data of the first list. Director: Morel Title: Taken Year: 2008 Director: Fincher Title: Seven Year: 1995 Director: Phillips Title: Joker Year: 2019 Enter the movie data of the second list. Director: Nolan Title: Inception Year: 2010 Director: Stone Title: Platoon Year: 1986 The following movies exceeded the year of production: 2007. Director: Morel Title: Taken Year: 2008 ------------------------------------- Director: Phillips Title: Joker Year: 2019 ------------------------------------- Director: Nolan Title: Inception Year: 2010 -------------------------------------
If you have went all the way to send everything why not send the actually error message?
klimi
You are making me sad :(
Talula
I'm going to start a group which I would call "C/C++ homework" where I would charge money.
klimi
👍😂
That's all you have to say for yourself?
Emmanuel
I have already done the work so no problem
Talula
I have already done the work so no problem
Don't post homework... please... Read the rules.
Emmanuel
Noted guys
klimi
I mean .... You could just post the code + the error message and that would be sufficient
Emmanuel
Sorry for the inconvenience
Shakh
/report
Jason
Hello here please l face difficulties in creating the implementation of a code to play cards
Luís
Hello, halp please 🙏🙏 Create an array that consists of 100 elements it needs to be filled with four-digit numbers that are divisible by 2 and by 3. Find the minimum and maximum values in the array 1) function 1-remember array elements 2) function 2-searches for minimum and maximum values, return two values. In C++
Ed
Hello, please help. How can I link two implementation files to one header file?
Ed
In C
klimi
Hello, please help. How can I link two implementation files to one header file?
You have #include "file.h" in both of them and you just compile them both? I dont think that should be a problem
Ed
I have included in both but I get an error of multiple declaration
klimi
Oh right...
klimi
Hm... Idk... I'm I am too tired to search it, gl
Ed
Ok
Ed
Thanks
Earl B
Can anyone tell me what this symbol is doing? 9^1
Laopigo
Can anyone tell me what this symbol is doing? 9^1
https://en.m.wikipedia.org/wiki/Bitwise_operations_in_C
Earl B
Thanks everyone!
Earl B
Just signed up and submitted my first exercise on exercism.io for C and the second question has them. It's about armstrong numbers but that was the first I'd seen them and punching the symbol into Google didn't tell me anything. Really cool site for anyone seriously interested in learning to code
Earl B
Definitely much better then some app imo, because your actually using the command line to submit your solutions. I had been doing them on solo learn but they are only available via the app and I'm not about to put Google play services on my pinephone running mobian. I got the pinephone to get away from it and to learn to code on
Viney
Hey there let me know anyone here from UG and interested in Internship?
olli
Jen
I don't understand where I mess up but I can't get visual studio code to give me an output. #include <stdio.h> int main() { int fd = 11; while (fd >= 10) { fd = 4546 / 10; } printf("n: %d", fd); return 0; }
Jen
Oh thanks
Φ ☭
/get cbook