0

I want to create a program in C language and in that i want to pass two integer value argument in main function is it possible if is it so how? because i wrote a code for it it say that is segment fault help me please?

`#include<stdio.h>

//recurtion power
long rpow(int x, int n){
    if(n == 1)
        return x;
    return x * rpow(x, n-1);
}

int main(int a, int b){
    
    printf("power of %d^%d is %ld", a,b,rpow(a,b));
    return 0;
}

I wrote this code and run it and it give-

mearjuntripathi@imubuntu:~/Documents/Programming/C_C++ Programming/C Programming$ gcc recurtion.c -o recurtion mearjuntripathi@imubuntu:~/Documents/Programming/C_C++ Programming/C Programming$ ./recurtion 3 4 Segmentation fault (core dumped) mearjuntripathi@imubuntu:~/Documents/Programming/C_C++ Programming/C Programming$

I want to create a program in C language and in that i want to pass two integer value argument in main function is it possible if is it so how?

  • https://en.wikibooks.org/wiki/A_Little_C_Primer/C_Command_Line_Arguments Short answer: No, you can accept a string array and have to convert to int. – Pinke Helga Dec 31 '22 at 03:23

0 Answers0