9th Jun 2017, 11:57 AM
Bahubali
Bahubali - avatar
8 Respostas
+ 3
thank u dhanyabaad
9th Jun 2017, 12:58 PM
Bahubali
Bahubali - avatar
+ 2
in prototype and in definition I use arr in main I use ar I think there is no issue
9th Jun 2017, 12:28 PM
Bahubali
Bahubali - avatar
+ 2
if don't use cout sum then it doesn't display anything why?
9th Jun 2017, 12:42 PM
Bahubali
Bahubali - avatar
+ 2
thank u so much but I. am not able to understand pointer concept please use simple language I am beginner
9th Jun 2017, 12:48 PM
Bahubali
Bahubali - avatar
+ 1
#include <iostream> using namespace std; int sum(int arr[], int); int main() { int p=5; int ar[5]={3,5,4,6,7}; cout<<sum(ar, p); return 0; } int sum(int arr[], int) { int total=0; for(int i=0;i<5;i++) {total+=arr[i];} return total; }
9th Jun 2017, 12:35 PM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
+ 1
cout is the std stream function which says the compiler to print this statement.. but there was two problem in this code : u were trying to convert the int p as a pointer to the array.. sum(a[p],p) the second problem was you didn't had any print statement in it.. so I added cout<<
9th Jun 2017, 12:45 PM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
+ 1
for pointer.. it is a vast topic to understand.. u will learn further .. but for pointer in short and simple... pointers are the variable created to store the address of a local variable or of a pointer.. kisi b variable ya pointer Ka address store krta h pointer
9th Jun 2017, 12:50 PM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
0
What's the name of your array: "ar" or "arr"?
9th Jun 2017, 12:26 PM
Infospacer