Simplifying and Fixing code for Finding nth Row of Pascal Triangle
Sep 10, 2014 at 5:27pm UTC
I'm a noob in programming and can't simplify this messy code or even fix the error saying:error C2086: 'b' : redefinition. Please help me. Here's the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
#include<iostream>
using namespace std;
int main()
{
int c,b,row,ent,factorial=1,s,d,nth;
cout<<" Enter Row: " ;
cin>>row;
for (int a=1;a<=row;a++)
{
s=factorial*a;
}
cout<<" Enter Entry: " ;
cin>>ent;
for (int f=1;f<=ent;f++)
{
d=factorial*f;
}
c=s-d;
for (int b=1;b<=c;b++)
{
c=factorial*b;
}
nth=s/(d*c);
cout<<" The nth row is " << nth;
return 0;
}
Topic archived. No new replies allowed.