+ 1
How to come output 4 . can you please tell ?
#include <iostream> using namespace std; int *fun(){ return new int[2]; } int fun(int *p){ delete[]p; return 0; } void fun(int *p,int q) { p[q]*=2;} void fun(int *p,int q,int r){ p[q]=r; } int main(){ int *v=fun(); fun(v,0,1); fun(v,1,2); fun(v,0); cout<<v[1]+v[0]; fun(v); }
6 odpowiedzi
+ 16
Line 1 : An array of size 2.
Line 2 : Element at Index 0 = 1.
Line 3 : Element at Index 1 = 2. Array is [1, 2]
Line 4 : Element at Index 0 is doubled. Array is [2, 2]
Line 5 : Sum of elements = 2 + 2 = 4 is printed.
+ 11
@Anuj Kumar : The main() function in the program in your question.
+ 2
can any body tell the program to find the gcd of n numbers entered by user (in CPP)
+ 2
#include <iostream>
using namespace std;
int *fun(){
    return new int[2];
}
int fun(int *p){
    delete[]p; // how will this work
    return 0;
}
void fun(int *p,int q)
{   p[q]*=2;}
void fun(int *p,int q,int r){
    p[q]=r;
}
int main(){
    int *v=fun();
    fun(v,0,1);  // ??
    fun(v,1,2);  //??
    fun(v,0);    //  ???
    cout<<v[1]+v[0];  ///??
    fun(v);//??
}
+ 1
krishna teja yeluylripati@  which program are you telling about ?
+ 1
well it can be more simple



