1:
#include<stdio.h>
///***NCR
int main(){
int n,r,ncr;
printf("Enter any two numbers->");
scanf("%d %d",&n,&r);
ncr=fact(n)/fact(r)*fact(n-r);
printf("The NCR factor of %d and %d is %d",n,r,ncr);
return 0;
}
int fact(int n){
int i=1;
while(n!=0){
i=i*n;
n--;
}
return i;
}
output: depend on your value
2:
#include<stdio.h>
///***NPR
int main(){
int n,r,ncr;
printf("Enter any two numbers->");
scanf("%d %d",&n,&r);
ncr=fact(n)/fact(n-r);
printf("The NPR factor of %d and %d is %d",n,r,npr);
return 0;
}
int fact(int n){
int i=1;
while(n!=0){
i=i*n;
n--;
}
return i;
}
output: depend on your value
3:
#include<stdio.h>
///***Leap year
int main(){
int year;
printf("Enter any year: ");
scanf("%d",&year);
if(((year%4==0)&&(year%100!=0))||(year%400==0))
printf("%d is a leap year",year);
else
printf("%d is not a leap year",year);
return 0;
}
output: depend on your value
No comments:
Post a Comment