Question:What are the parameter passing conventions in c? 

Answer Explanation: 1. pascal: In this style function name should (not necessary ) in the uppercase .First parameter of function call is passed to the first parameter of function definition and so on. 2. cdecl: In this style function name can be both in the upper case or lower case. First parameter of function call is passed to the last parameter of function definition. It is default parameter passing convention. Examples: 1. What will be output of following program?
int main(){
static int a=25;
void cdecl conv1() ;
void pascal conv2();
conv1(a);
conv2(a);
return 0;
}
void cdecl conv1(int a,int b){
printf("%d %d",a,b);
}
void pascal conv2(int a,int b){
printf("\n%d %d",a,b);
}
Output: 25 0 0 25 (2) What will be output of following program?
void cdecl fun1(int,int);
void pascal fun2(int,int);
int main(){
    int a=5,b=5;
   
    fun1(a,++a);
    fun2(b,++b);
   return 0;
}
void cdecl fun1(int p,int q){
    printf("cdecl:  %d %d \n",p,q);
}
void pascal fun2(int p,int q){
    printf("pascal: %d %d",p,q);
}
Output: cdecl:  6 6 pascal: 5 6 (3) What will be output of following program?
void cdecl fun1(int,int);
void pascal fun2(int,int);
int main(){
    int a=5,b=5;
   
    fun1(a,++a);
    fun2(b,++b);
    return 0;
}
void cdecl fun1(int p,int q){
    printf("cdecl:  %d %d \n",p,q);
}
void pascal fun2(int p,int q){
    printf("pascal: %d %d",p,q);
}
Output: cdecl:  6 6 pascal: 5 6 (4) What will be output of following program?
void convention(int,int,int);
int main(){
    int a=5;
   
    convention(a,++a,a++);
    return 0;

void  convention(int p,int q,int r){
    printf("%d %d %d",p,q,r);
}
Output: 7 7 5 (5) What will be output of following program?
void pascal convention(int,int,int);
int main(){
    int a=5;
   
    convention(a,++a,a++);
    return 0;}
void pascal  convention(int p,int q,int r){
    printf("%d %d %d",p,q,r);
}
Output: 5 6 6 (6) What will be output of following program?
void pascal convention(int,int);
int main(){
    int a=1;
   
    convention(a,++a);
    return 0;
}
void pascal  convention(int a,int b){
    printf("%d %d",a,b);
}
Output: 1 2 (7) What will be output of following program?
void convention(int,int);
int main(){
    int a=1;
   
    convention(a,++a);
    return 0;}
void  convention(int a,int b){
    printf("%d %d",a,b);
}
Output: 2 2 

+ Report
Total Preview: 878
What are the parameter passing conventions in c?
Copyright © 2024. Powered by Intellect Software Ltd