Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update readme #66

Merged
merged 3 commits into from
May 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added 513de10da425f3790aa54c94f23c06b8.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# C PROGRAMS
<h1 align="center">C Programs</h1>

<div align= "center"><img src="https://github.com/Ayushparikh-code/C-Programs-/blob/update-readme/513de10da425f3790aa54c94f23c06b8.jpg?raw=true" width="400" height="200"/>

<h4>C is a general-purpose, procedural computer programming language supporting structured programming, lexical variable scope, and recursion, with a static type system. By design, C provides constructs that map efficiently to typical machine instructions.

C is a general-purpose, procedural computer programming language supporting structured programming, lexical variable scope, and recursion, with a static type system. By design, C provides constructs that map efficiently to typical machine instructions

It can be used to develop software like operating systems, databases, compilers, and so on.


Hre you could contribute to your first C programs and can get your PR Merged with us
Here you could contribute to your C programs and get your PR Merged with us !
</h4>
</div>


42 changes: 42 additions & 0 deletions calc_nPr.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include <stdio.h>

void main()
{
int n, r, npr_var;

printf("Enter the value of n:");
scanf("%d", &n);
printf("\nEnter the value of r:");
scanf("%d", &r);

/* nPr is also known as P(n,r), the formula is:
* P(n,r) = n! / (n - r)! For 0 <= r <= n.
*/
npr_var = fact(n) / fact(n - r);
printf("\nThe value of P(%d,%d) is: %d",n,r,npr_var);
}
// Function for calculating factorial
int fact(int num)
{
int k = 1, i;
// factorial of 0 is 1
if (num == 0)
{
return(k);
}
else
{
for (i = 1; i <= num; i++)
{
k = k * i;
}
}
return(k);
}
Output:

Enter the value of n:
5
Enter the value of r:
2
The value of P(6,2) is: 30