[go: up one dir, main page]

0% found this document useful (0 votes)
33 views2 pages

C Problem Solving

Uploaded by

aowladhussain99
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views2 pages

C Problem Solving

Uploaded by

aowladhussain99
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

/*

A program to read n,r from user and then print the value of nPr:
nPr = n!/(n-r)! = ( n*(n-1)*(n-2)*..*(n-r+1)*(n-r)*(n-r-1)*(n-r-2)*
..*3*2*1 ) /
( (n-r)*(n-r-1)*(n-r-2)*..
*3*2*1 )
= n*(n-1)*(n-2)*..* (n-r+1)
*/
#include <stdio.h>

int main()
{
int a, n, r, f = 1;

printf("Enter n, r:\n");
scanf("%d%d", &n, &r);
for (a = n; a >= n-r+1; a--)
{
f = f * a;
}

printf("nPr : %d\n", f);


return 0;
}
#include <stdio.h>
int main()
{
int number, digit, rev = 0;
printf("Enter a number: ");
scanf("%d", &number);
int temp = number;
while(temp > 0)
{
digit = temp % 10;
rev = rev*10+digit;
temp = temp / 10;
printf("digit = %d, rev = %d, temp = %d\n", digit, rev,
temp);
}
if(number == rev)
printf("palindrome");
else
printf("not palindrome");

return 0;}

You might also like