0

C language

I want to calculate the combination and permutation of tow numbers But it doesn’t work Do you know what is it’s problem?! https://code.sololearn.com/c07gKmCHL8Wb/?ref=app

20th Dec 2019, 4:27 PM
Laya Mousavi
13 ответов
+ 1
Laya Mousavi Give the values to a=1,b=1,d=1. And run it...
20th Dec 2019, 6:03 PM
Jayakrishna 🇮🇳
0
you are using [int e=n-r;] before n and r are assigned any value. move [int e=n-r;] below [scanf] for r and n to be initialized.
20th Dec 2019, 5:35 PM
Bahhaⵣ
Bahhaⵣ - avatar
0
bahha🐧 i did that but it doesn’t work again😭
20th Dec 2019, 5:42 PM
Laya Mousavi
0
For global a,b,d give values fisrt. You are multiplying so give 1 value to them. a=1,b=1,d=1;
20th Dec 2019, 5:50 PM
Jayakrishna 🇮🇳
0
the problem is that the a, b, d at the end of the loop they equal 0
20th Dec 2019, 5:57 PM
Bahhaⵣ
Bahhaⵣ - avatar
0
#include <stdio.h> int f1(int a,int d); int f2(int a,int b, int d); int a,b,d; int main() { int n,r,c,p; scanf("%d%d",&n,&r); int e=n-r; for(;n>1;n--) a*=n; for(;r>1;r--) b*=r; for(;e>1;e--) d*=e; printf("a = %d b = %d c = %d",a, b, d); return 0; }
20th Dec 2019, 6:01 PM
Bahhaⵣ
Bahhaⵣ - avatar
0
bahha🐧 would you check it again?!i wrot the loop works till n==1 why it becomes 0?!
20th Dec 2019, 6:01 PM
Laya Mousavi
0
Jayakrishna i don’t know what you mean would you do it your self?!please
20th Dec 2019, 6:02 PM
Laya Mousavi
0
int a=1; int b = 1; int d = 1; don't forget to change n==1 to n>1
20th Dec 2019, 6:09 PM
Bahhaⵣ
Bahhaⵣ - avatar
0
Laya Mousavi Give the values to a=1,b=1,d=1. And run it... And why you changed for loop conditions.. Its e>1, and next also .. Its output if i give 5,3 output: 60 10. is it ok...
20th Dec 2019, 6:11 PM
Jayakrishna 🇮🇳
0
bahha🐧 Jayakrishna thanks both of you so much it runs at last but i have a new problem with my last question,if you could help me i became thanksfull
20th Dec 2019, 6:11 PM
Laya Mousavi
0
😂
20th Dec 2019, 6:12 PM
Bahhaⵣ
Bahhaⵣ - avatar
0
write a c program to creat folder?
17th May 2020, 6:29 AM
Zainab abdulameer
Zainab abdulameer - avatar