Computer Science, asked by Anonymous, 11 months ago

write a program to find the factorial of no. between (2-7) by nested if loops do if you think you should have a place in leaderboard a challenge for all brainly users....by Miss Riya Arora ​


hardy0077: ta
hardy0077: gram
hardy0077: id
hardy0077: ab
Anonymous: why
hardy0077: as a friend
Anonymous: sorry
Anonymous: i didn't know you
hardy0077: plz
hardy0077: i hv no girl followers plz

Answers

Answered by XxMaverickxX
6

Hello !

here's your answer

#include<stdio.h>

main()

{

int fact=1, n, i, j;

printf("Enter the number whose factorial is to be found \n");

scanf("%d",&n);

if(n>=1)

{

fact=fact*n;

n--;

if(n>=1)

{

fact=fact*n;

n--;

if(n>=1)

{

fact=fact*n;

n--;

if(n>=1)

{

fact=fact*n;

n--;

if(n>=1)

{

fact=fact*n;

n--;

if(n>=1)

{

fact=fact*n;

n--;

if(n>=1)

{

fact=fact*n;

n--;

if(n>=1)

{

fact=fact*n;

n--;

}}}}}}}}

printf("The factorial of the given number is %d",fact);

}

NOTE : According to the question since it was asked for a specific case i.e. to find factorial between 2-7 this program will work fine for 2-7 only.

The same question can be solved by loops to with nested if :- (I'll mention that logic also )

Main logic :-

for(i=7; i>=1; i--)

{

if(n>=1)

{

fact=fact*n;

n--;

if(n>=1)

{

fact=fact*n;

n--;

}}

}

Hope it helps ! ^_^


Anonymous: program not working showing errors
XxMaverickxX: which complier are you using ?
XxMaverickxX: i wrote it in C language
Anonymous: thanks
Arey: A cool nd great answer
Similar questions