Computer Science, asked by Basilisk, 1 year ago

Write a c program to calculate card castling ?
example To built a  2 storeys of card castle you need
bottom ( 2 + 2)
Top ( 2 ) + 1 for support
so totally 7 cards.
Similarly write a program to compute the number of cards to build the castle to a given  "N" storeys  ..
{ with Solution }

Answers

Answered by megusta
0
#include<stdio.h>
main(
int N;                      /*No. of storeys*/
int a,b;                    /*a=No. of standing cards, b= cards for support*/
int T;                       /*Total Cards*/

scanf("%d",&N);       /*Input from user about no. of storeys*/

a=N*(N+1);
b=(N*(N-1))/2;

T=a+b;

printf("Cards needed for a %d storeyed castle are %d",N,T);

return 0;
)

megusta: Sample values:
megusta: If N=1, T=2; N=2, T=7; N=3, T=15; N=4, T=26
Answered by firdous41
4

Explanation:

bottom ( 2 + 2)

bottom ( 2 + 2)Top ( 2 ) + 1 for support

bottom ( 2 + 2)Top ( 2 ) + 1 for support so totally 7 cards.

bottom ( 2 + 2)Top ( 2 ) + 1 for support so totally 7 cards.Similarly write a program to compute

Similar questions