+ 3

I am stuck here please help me

https://code.sololearn.com/c4Ki0hR3B2xX/?ref=app Here I am creating an example of c function to find perimeter and area please help mešŸ˜žšŸ˜žšŸ˜ž

30th Apr 2020, 2:40 PM
Kavya Mittal
Kavya Mittal - avatar
5 Answers
+ 3
You are having 1 parameter in function call but 2 parameters in function definition, also the parameters are separated by comma not semicolon. It should look like 'int square(int a, int b)' Also you can return only 1 variable either peri or area, if you want to return both either use pointer or return them in array having 2 elements as area and peri or make separate functions for calculating area and perimeter. Link to function lesson in C for basics https://www.sololearn.com/learn/C/2929/
30th Apr 2020, 3:30 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 1
Bro you can't have 2 return statements in the same function
30th Apr 2020, 2:43 PM
Prabhat Ranjan
Prabhat Ranjan - avatar
+ 1
Then also it is not working
30th Apr 2020, 3:19 PM
Kavya Mittal
Kavya Mittal - avatar
+ 1
//You have to make two seperate //functions: #include <stdio.h> int area(int a){ int area = a*a; return area; } int peri(int a){ int peri = 4*a; return peri; } int main() { int k; scanf("%d",&k); printf ("Your answer is:\n Area: %d Peri: %d",area(k),peri(k)); return 0; }
30th Apr 2020, 3:32 PM
Alexander Thiem
Alexander Thiem - avatar
0
#include <stdio.h> int area,peri; int square(int a){ peri = 4*a; area = a*a; return area*peri; } int main() { int k; scanf("%d",&k); k=square(k); printf ("area=%d peri=%d k=%d",area,peri,k); return 0; } //use this code
1st May 2020, 3:04 PM
Ash Akshay
Ash Akshay - avatar