# C Program for Staircase Problem (TCS Codevita) | PrepInsta

## Staircase Problem

Staircase Problem is one of the sample problem of this year TCS CodeVita 2020 Season 9 coding competition. This is a prestigious coding competition that is organized by TCS every year for promotion Programming-As-A-Sport among the new generation. This competition’s difficulty level is pretty high comparing with other coding competitions.

## Problem Description

There are n stairs, a person standing at the bottom wants to reach the top. The person can climb either 1 stair or 2 stairs at a time.

• Count the number of ways, the person can reach the top.

## C Code

```#include  <stdio.h>
int calc(int n);
int count(int x);

int main ()
{
int n ;
printf("Enter number of stairs : ");
scanf("%d", &n);
printf("Number of ways = %d", count(n));
getchar();
return 0;
}
int count(int x)
{
return calc(x + 1);
}
int calc(int n)
{
if (n <= 1)
return n;
return calc(n-1) + calc(n-2);
}```
```Output
Enter number of stairs : 5
Number of ways = 8```

## Python

To find the solution of Staircase problem in Python Programming language click on the button below:

Python

## C++

To find the solution of Staircase  problem in C++ Programming language click on the button below:

C++

## Java

To find the solution of Staircase  problem in Java Programming language click on the button below:

Java