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
13 Antworten
+ 1
Laya Mousavi
Give the values to a=1,b=1,d=1.
And run it...
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.
0
bahha🐧 i did that but it doesn’t work again😭
0
For global a,b,d give values fisrt.
You are multiplying so give 1 value to them.
a=1,b=1,d=1;
0
the problem is that the a, b, d at the end of the loop they equal 0
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;
}
0
bahha🐧 would you check it again?!i wrot the loop works till n==1
why it becomes 0?!
0
Jayakrishna i don’t know what you mean would you do it your self?!please
0
int a=1;
int b = 1;
int d = 1;
don't forget to change n==1 to n>1
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...
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
0
😂
0
write a c program to creat folder?