MRT
i dont see any relation object, but this->deleteLater() not working
Otumian
Ava
How does one receive enter as user input
Diego
If you can already receive individual keys as user input, then simply match the one for enter/return
Diego
You know I really dislike how I'm googling that exact question and the first 6 results somehow resolve to lmgtfy or "x minutes of googling"
AHMED
#include<iostream>
using namespace std;
int getAve(int a[], int n){
int sum = 0;
for (int i = 0; i<10; i++){
sum += a[i];
}
return sum/n;
}
int main()
{
int myArray[10];
cout<<"Enter 10 integers separated by the enter key:\n";
for (int i = 0; i<10; i++){
cin>>myArray[i];
}
cout<<"The average is: "<<(double)getAve(myArray[], 10);
}
AHMED
+ g++ -w -Wall -std=c++14 -O2 -o main.out main.cpp -lm
main.cpp: In function ‘int main()’:
main.cpp:30:54: error: expected primary-expression before ‘]’ token
cout<<"The average is: "<<(double)getAve(myArray[], 10);
^
+ ./main.out
Enter 10 integers separated by the enter key:
AHMED
The program works , but why is this error?
Mar!o
ouch
Dhroov
#include <iostream>
using namespace std;
int main()
{
int a[] = {10, 20, 30, 40};
for (int i = 0; i < 4; i++)
{
cout << (a[i] == i[a]) << " ";
}
return 0;
}
Output: 1 1 1 1
Dhroov
Why is it equating to True? Can array name and array index be interchanged?
E
H
Dhroov
Mar!o
Mar!o
Mar!o
Dhroov
Which is basically what you explained
Dhroov
Thanks a lot!
Anonymous
Give the array address and display the output of the given array declaration and initialization
int num[4][5]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25}
dispay the value 8
Anonymous
Help me please
Anonymous
I've been trying to do it for 6 hours
Vlad
Give the array address and display the output of the given array declaration and initialization
int num[4][5]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25}
dispay the value 8
printf("%d", *(num + 7));
Mercy
Give the array address and display the output of the given array declaration and initialization
int num[4][5]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25}
dispay the value 8
int num[4][5]?
Vlad
Vlad
And why it works the way it does
Nils
Vlad
Give the array address and display the output of the given array declaration and initialization
int num[4][5]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25}
dispay the value 8
Long story short multidimensional arrays on the stack are contiguous in memory
Vlad
Vlad
What's difference between 5 + 2 vs 2 + 5
Vlad
gab
Anonymous
Hi
I have a program that I open every time, in Chrome it opens two tabs from their site that I downloaded
How to edit the program?
Anonymous
Anonymous
Anonymous
Vlad
Vlad
I bet it's some kind of adware
Anonymous
What is tools?
https://en.m.wiktionary.org/wiki/tool
You are welcome
Vlad
It usually just messes up with your files/configs but you can clean that up
Vlad
#ot
Mamas
Please i have a question to ask ..can I.. please
Anonymous
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
int main(){
pid_t pid;
int x = 5;
pid = fork();
printf("pid fork() returned value = %d\n", pid);
x++;
if (pid < 0){
printf("Process creation error");
exit(-1);
}
else if (pid == 0){
printf("Child process:");
printf("\nProcess id is %d", getpid());
printf("\nValue of x is %d", x);
printf("\nProcess id of parent is %d\n", getppid());
}
else{
printf("\nParent process:");
printf("\nProcess id is %d", getpid());
printf("\nValue of x is %d", x);
printf("\nProcess id of shell is %d\n", getppid());
}
return 0;
}
OUTPUT:
pid fork() returned value = 1282
pid fork() returned value = 0
Child process:
Parent process:
Process id is 1282
Process id is 1281
Value of x is 6
Value of x is 6
Process id of parent is 1281
Process id of shell is 10
Why the output is printing like this?
Anonymous
when the fork() returned is 1282 which is process id(parent),
then it should print everything inside the else{} and then when fork() return is 0 it should print everything inside else if (pid == 0){}
when fork() is done, does the two process run in parallel?
Anonymous
Mamas
I need help.please
Anonymous
Mamas
just ask
Okay can it be possible to study programming without a computer ..or Android phone..
Anonymous
Mamas
Can that work??
Mamas
Okay thanks for your help...
Anonymous
Hi guys i have a question, why i can do class p{
int *r;
int& operator[](unsigned int index) const {
return *r;
}
}
And not
class p{
int r;
int& operator[](unsigned int index) const {
return r;
}
}
Thanks guys
H
Anonymous
Anonymous
Mamas
Andrew
/get cbook
Anonymous
Mh without const works
I mean i understand why it works without const, but with why it wouldn't work? I don't change class variables
Anonymous
MRT
in windows after start many threads in application i get this error QMutex: destroying locked mutex;QThread: Destroy while thread is still running, why ?
MRT
staticMetaObject <not accessible>
MRT
I just put a few small items on the stack
Anonymous
Anonymous
Are boost::python questions appropriate here?
Anonymous
Can you guys give me a sample code of 3D Arrays?
あおい ハート
How can i Create multiple objects in a for loop? Is it advance thing to do which i should leave for now?
Diego
Diego
The thing you should be worrying about is, instead, how will you access these objects
あおい ハート
Diego
I mean sure, you create them somewhere in memory and receive a pointer back to them