Nur Alom Hoque
Can anyone help me for Numerical analysis , Gauss Seidel method code
Nur Alom Hoque
Spline interpolation codes
Ayush Kumar
Evening guys, please help me here, Im good in Data structures, not Arrays! #define N 100 #include<iostream> #include<stdio.h> using namespace std; class merge_Array { public: void Merge(int array1[N], int array2[N], int array3[N], int n1, int n2) { int i = 0, j = 0, k = 0; while (i < n1 && j < n2) { if (array1[i] < array2[j]) { array3[k++] = array1[i++]; } else { array3[k++] = array2[j++]; } } while (i < n1) { array3[k++] = array1[i++]; } while (j < n2) { array3[k++] = array2[j++]; } } }; int main() { merge_Array ma; int n1, n2, n3; int i; int A[N], B[N], C[N]; cout << "Enter the size of First array:\n"; cin >> n1; cout << "\nEnter the elements of First array:\n"; for (i = 0; i < n1; i++) cin >> A[i]; cout << "\nEnter the size of Second array:\n"; cin >> n2; cout << "\nEnter the elements of Second array:\n"; for (i = 0; i < n2; i++) cin >> B[i]; sort(A, A + n1); sort(B, B + n2); //cout << "\nElements of First sorted array:\n"; for (i = 0; i < n1; i++) cout << A[i] << " "; //cout << "\nElements of Second sorted array:\n"; for (i = 0; i < n2; i++) { cout << B[i] << " "; } ma.Merge(A, B, C, n1, n2); cout << "\nElements after Merging Arrays:\n"; for (i = 0; i < (n1 + n2); i++) { cout << C[i] << " "; } return 0; }
#include<bits/stdc++.h> Add this among header file.
olli
Evening guys, please help me here, Im good in Data structures, not Arrays! #define N 100 #include<iostream> #include<stdio.h> using namespace std; class merge_Array { public: void Merge(int array1[N], int array2[N], int array3[N], int n1, int n2) { int i = 0, j = 0, k = 0; while (i < n1 && j < n2) { if (array1[i] < array2[j]) { array3[k++] = array1[i++]; } else { array3[k++] = array2[j++]; } } while (i < n1) { array3[k++] = array1[i++]; } while (j < n2) { array3[k++] = array2[j++]; } } }; int main() { merge_Array ma; int n1, n2, n3; int i; int A[N], B[N], C[N]; cout << "Enter the size of First array:\n"; cin >> n1; cout << "\nEnter the elements of First array:\n"; for (i = 0; i < n1; i++) cin >> A[i]; cout << "\nEnter the size of Second array:\n"; cin >> n2; cout << "\nEnter the elements of Second array:\n"; for (i = 0; i < n2; i++) cin >> B[i]; sort(A, A + n1); sort(B, B + n2); //cout << "\nElements of First sorted array:\n"; for (i = 0; i < n1; i++) cout << A[i] << " "; //cout << "\nElements of Second sorted array:\n"; for (i = 0; i < n2; i++) { cout << B[i] << " "; } ma.Merge(A, B, C, n1, n2); cout << "\nElements after Merging Arrays:\n"; for (i = 0; i < (n1 + n2); i++) { cout << C[i] << " "; } return 0; }
An array is a data structure, so what's your question? Also, when copying code you might as well ask the author of it?
Abhishek
Yeah😊
Abhishek
Thanks for the response
Alberto
Hi, I'm a newbie to poo with c ++. A fairly simple question: To separate the declaration of a class from the implementation, the only way is the one I see in this stackoverflow question? https://stackoverflow.com/questions/9579930/separating-class-code-into-a-header-and-cpp-file There is no other way? Maybe using again class Foo { . . . }; in the .cpp so you don't have to specify Foo :: before each method or attribute.
Anonymous
Thanks
meis
hey, guys. how do you pronounce x[i]? x of i?
Kalpak
pattern printing: write a c program, using printf and any character including ‘*’ , to draw a ⭐ on screen. Please send me this program
Official hooligan of Pius XII
Official hooligan of Pius XII
or i index of x, if i want to sound more sophisticated
meis
i just read this as x i
I do too. but I thought there is a common way to pronounce it
Official hooligan of Pius XII
as long as you are understood, who cares
Kalpak
Official hooligan of Pius XII
What
read the rules
Kalpak
Ok
R
I have 2 programmes they look like same but they are not giving same output can anyone help me?
R
#include <stdio.h> int main(void) { int rev[9]={34,56,54,32,67,89,90,32,21}; int i=0; for(i=0;i<9;i++); printf("%d", rev[i] ); return 0; }
R
#include <stdio.h> int main() { int array[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}; int loop; for(loop = 0; loop < 10; loop++) printf("%d ", array[loop]); return 0; }
Anonymous
z
I have 2 programmes they look like same but they are not giving same output can anyone help me?
They are different, how hard is it to spot the difference? The array elements are completely different.
R
see the output
R
like I am not able to print elements in array
z
See the difference? int rev[9]={34,56,54,32,67,89,90,32,21}; int array[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
Anonymous
z
Yeah exactly. for (i = 0; i < 9; i++); does nothing, except incrementing the i, so you only print the last element with that printf. Because the printf is not inside the loop.
z
It didn't print the last element...
Oh right, it has gone beyond the array. So that would be undefined value.
Anonymous
Yes... I heard that when an variable point to unallocated memory space then we get segmentation error....is it right ?
Anonymous
Yes... I heard that when an variable point to unallocated memory space then we get segmentation error....is it right ?
you can point to wherever you want, you can get segmentation error for de-referencing a random address (aka an address that point to an unallocated memory), but it's ub, you can also get a random value because you do have access to this memory
z
It's undefined behavior.
Emmanuel
Hello guys can any and have an idea on this project? We want to write an "agent" which will run on Linux and Windows. This agent will listen on a port for connections, and when a connection is received it will process messages from that connection and then carry out various actions. Some of the actions the "agent" will preform: Installing a remote viewing client Executing bash commands Retrieving file system information Other system administration related tasks So imagine this: Server --- TCP --- Agent This agent could be written in anything, but it should be easily portable to other systems so Java is probably best, although C++ and other languages could also work. Does this sound complicated? It's not. Just listen for connections on a port, process the messages, preform various actions, send the results back. This is going to be used as a tool for system administrators to remotely work on servers and desktops.
Anonymous
main() { int i = 2; { int i = 3, j= 4; printf("%d %d", i, j); } printf("%d %d", i, j); } What will be the output??
Anonymous
Anonymous
If you remove j from outer block then 3 4 2
Anonymous
Anonymous
Anonymous
Scope of local variable is in block... So after your inner curly braces.,, j will longer available
Anonymous
But isn't j=4 Ohh j==4 is right ??
i am not getting that for assigning we use just a one = for checking like in conditions we use ==
Anonymous
Ya " == " is use for comparison of two value...
Zel
== compare if equal to. = set equal to
Zel
that later if used in the context of a comparison will invaribly evaluate true, many compilers warn on this, some will throw errors
R
#include <stdio.h> int main() {int arr[5]= {5,6,7,8,9}; int a; for (a=0;a>4;a--) printf("%d", arr[a]); } I need to print array elements in reverse order can anyone help me?
Anonymous
Heyy
Anonymous
I need help. Can anyone tell me the error here #include<stdio.h> #include<stdlib.h> #include<conio.h> int main() { int menu_one, name1[30], score, rat; printf("Please choose:\n1. Quiz \n2. Calculator"); scanf("%d", &menu_one); if(menu_one == 1) { printf("\nPlease enter your name"); scanf("%s", name1); printf("\nHello %s!, I hope you enjoy the game", name1); void start(); void help(); void main() { int opt = 0; printf("\nPress 1 to start the game\n2 to read game help\n0 to exit"); scanf("%d", &opt); switch(opt) { case 1: start(); break; case 2: help(); break; default: exit(1); } getch(); } void help() { int ch printf("\n\n****************GAME HELP**************"); printf("\n-----------------------------------------"); printf("\n>> There will be a total of 5 questions \n>> You will be given 4 options and you have to press 1, 2 ,3 or 4 for the right option \n>> Each question will carry 5 points \n>> There is no negative for wrong answers"); printf("\n\n***************BEST OF LUCK***************"); printf("\n Do you want to continue playing? (1/0)"); scanf("%d", &ch); if(ch==1) { start(); } else { exit(1); } } void start() { int answer; int count; char rating[20]; printf("******************* Welcome \" %s \" to C Quiz Game *********************** \n\n", name1); printf("Q(1).Grand Central Terminal, Park Avenue, New York is the world's \n 1.largest railway station \t\t2.highest railway station\n 3.longest railway station\t\t 4.None of the above\n\n"); printf("Your answer: "); scanf("%d",&ans); if(ans==1) { printf("Correct! +5 points\n\n"); ++count; } else { printf("Wrong answer! Correct answer is 1.largest railway station\n\n"); } printf("Q(2) Entomology is the science that studies \n 1.Behavior of human beings\t\t2.Insects \n3.The origin and history of technical and scientific terms\n4.The formation of rocks\n\n"); printf("Your answer: "); scanf("%d",&ans); if(ans==2) { printf("Correct! +5 points\n\n"); ++count; } else { printf("Wrong answer! Correct answer is 2.Insects\n\n"); } printf("Q(3) Eritrea, which became the 182nd member of the UN in 1993, is in the continent of \n1.Asia\t\t2.Africa\n3.Europe\t4.Australia\n\n"); printf("Your answer: "); scanf("%d",&ans); if(ans==2) { printf("Correct! +5 points\n\n"); ++count; } else { printf("Wrong answer! Correct answer is 2.Africa\n\n"); } printf("Q(4).Garampani sanctuary is located at \n1.Junagarh, Gujarat\t2.Diphu, Assam\n3.Kohima, Nagaland\t4.Gangtok, Sikkim\n\n"); printf("Your answer: "); scanf("%d",&ans); if(ans==2) { printf("Correct! +5 points\n\n"); ++count; } else { printf("Wrong answer! Correct answer is 2.Diphu, Assam\n\n"); } printf("Q(5).For which of the following disciplines is Nobel Prize awarded? \n1.Physics and Chemistry\t2.Physiology or Medicine\n3.Literature, Peace and Economics\t4.All of the above\n\n"); printf("Your answer: "); scanf("%d",&ans);
Anonymous
I need help. Can anyone tell me the error here #include<stdio.h> #include<stdlib.h> #include<conio.h> int main() { int menu_one, name1[30], score, rat; printf("Please choose:\n1. Quiz \n2. Calculator"); scanf("%d", &menu_one); if(menu_one == 1) { printf("\nPlease enter your name"); scanf("%s", name1); printf("\nHello %s!, I hope you enjoy the game", name1); void start(); void help(); void main() { int opt = 0; printf("\nPress 1 to start the game\n2 to read game help\n0 to exit"); scanf("%d", &opt); switch(opt) { case 1: start(); break; case 2: help(); break; default: exit(1); } getch(); } void help() { int ch printf("\n\n****************GAME HELP**************"); printf("\n-----------------------------------------"); printf("\n>> There will be a total of 5 questions \n>> You will be given 4 options and you have to press 1, 2 ,3 or 4 for the right option \n>> Each question will carry 5 points \n>> There is no negative for wrong answers"); printf("\n\n***************BEST OF LUCK***************"); printf("\n Do you want to continue playing? (1/0)"); scanf("%d", &ch); if(ch==1) { start(); } else { exit(1); } } void start() { int answer; int count; char rating[20]; printf("******************* Welcome \" %s \" to C Quiz Game *********************** \n\n", name1); printf("Q(1).Grand Central Terminal, Park Avenue, New York is the world's \n 1.largest railway station \t\t2.highest railway station\n 3.longest railway station\t\t 4.None of the above\n\n"); printf("Your answer: "); scanf("%d",&ans); if(ans==1) { printf("Correct! +5 points\n\n"); ++count; } else { printf("Wrong answer! Correct answer is 1.largest railway station\n\n"); } printf("Q(2) Entomology is the science that studies \n 1.Behavior of human beings\t\t2.Insects \n3.The origin and history of technical and scientific terms\n4.The formation of rocks\n\n"); printf("Your answer: "); scanf("%d",&ans); if(ans==2) { printf("Correct! +5 points\n\n"); ++count; } else { printf("Wrong answer! Correct answer is 2.Insects\n\n"); } printf("Q(3) Eritrea, which became the 182nd member of the UN in 1993, is in the continent of \n1.Asia\t\t2.Africa\n3.Europe\t4.Australia\n\n"); printf("Your answer: "); scanf("%d",&ans); if(ans==2) { printf("Correct! +5 points\n\n"); ++count; } else { printf("Wrong answer! Correct answer is 2.Africa\n\n"); } printf("Q(4).Garampani sanctuary is located at \n1.Junagarh, Gujarat\t2.Diphu, Assam\n3.Kohima, Nagaland\t4.Gangtok, Sikkim\n\n"); printf("Your answer: "); scanf("%d",&ans); if(ans==2) { printf("Correct! +5 points\n\n"); ++count; } else { printf("Wrong answer! Correct answer is 2.Diphu, Assam\n\n"); } printf("Q(5).For which of the following disciplines is Nobel Prize awarded? \n1.Physics and Chemistry\t2.Physiology or Medicine\n3.Literature, Peace and Economics\t4.All of the above\n\n"); printf("Your answer: "); scanf("%d",&ans);
if(ans==4) { printf("Correct! +5 points\n\n"); ++count; } else { printf("Wrong answer! Correct answer is 4.All of the above\n\n"); } if(count > 0) { printf("Thanks for playing, Your scored: %d points \t", count*5); score=count*5; if(score >= 80) { printf("Rating: * * * * *"); rat=5; } else if(score >= 60 && score < 80) { printf("Rating: * * * *"); rat=4; } else if(score >= 40 && score < 60) { printf("Rating: * * *"); rat=3; } else if(score >= 20 && score < 40) { printf("Rating: * *"); rat=2; } else if(score < 20) { printf("Rating: *"); rat=1; } } }
@𝑺𝒐𝒃𝒌𝒂
Hi guys. I'm using Qt5 c++ to create Dashboard user panel. I want to change a background of a button when it's selected until I click in another button. I had a look to a Qt documentation, but I didn't find such signal in QPushButton nor in QAbstractButton. Anyone has an idea of how to do it?
Anonymous
I get this error "static declaration follows non static declaration", what does it mean
Anonymous
Please use a pasting service to share the code.
I did. Couldnt have it all in one message
Apk
I did. Couldnt have it all in one message
I mean use pastebin to share long codes.
ARNAV
Print("hacker");
Dee
#include <iostream> #include <stdlib.h> #include <stdio.h> #include <iomanip> using namespace std; int main() { double itemPrice[5] = {100,200,300,400,500}; double discountRate[5] = {95,90,80,100,93}; double deliveryCharge[5] = {30,20,25,37.5,15}; int cart[5] = {0,0,0,0,0}; int units=0, items, totalUnit = 0;; double totalPayment; int count = 1; while(count < 6){ // enter number of item {"P01", "P02", "P03", "P04", "P05"} represent by 1 , 2, 3, 4, 5 cout <<count<<") Enter number of items :"; cin >> items; // unit for the selected item cout <<count<<") Enter number of units :"; cin >> units; // keep track the total unit totalUnit += units; // keep track the item unit cart[items-1] += units; // when counter hit 5, start calculation if(count == 5){ // each unit contain 30 item, if total unit greater than 150, give discount // this checking avoid user miss input item unit and cause the program have less than 150 units if (totalUnit*30 >= 150) { // loop though the cart and perform calculation include discount for(int i = 0; i < 5; i++) { if(cart[i] != 0){ double tempTotal = cart[i] * itemPrice[i] * (discountRate[i]/100) +deliveryCharge[i] ; totalPayment += tempTotal; } } } else { // loop though the cart and perform calculation without discount for(int i = 0; i < 5; i++) {if(cart[i] != 0){ double tempTotal = cart[i] * itemPrice[i] +deliveryCharge[i] ; totalPayment += tempTotal; } } } cout<<"Total money you must pay is =RM" << totalPayment; } count++; } }
Dee
Can anyone help me with this
Anonymous
I mean use pastebin to share long codes.
https://pastebin.com/eEp7jL6a
z
I don't know about sizes I mean my teacher didn't teach
sizeof is simply a unary operator that yields the size of a variable or data type in byte unit. sizeof(arr) / sizeof(*arr) will yield the number of elements in the array.
'''''''
Can i use Allegro as a GUI? If so any resources to learn Allegro?