Category: C programming

python tutorials and learn python

Created with Sketch.

Decimal to binary in C

  Decimal to binary in C Decimal to binary in C programming: C program to convert an integer from decimal number system (base-10) to binary number system (base-2). Size of an integer is assumed to be 32 bits. We will use the bitwise operator “AND” to perform the desired task. We right shift the original…
Read more

C program to find nCr and nPr

  C program to find nCr and nPr C program to find nCr and nPr, remember, nCr = n!/(r!*(n-r)!) and nPr = n!/(n-r)!. C program to find nPr and nCr using a function #include <stdio.h> long factorial(int); long find_ncr(int, int); long find_npr(int, int); int main() { int n, r; long ncr, npr; printf(“Enter the value…
Read more

Sum of n numbers in C

  Sum of n numbers in C Sum of n numbers in C: This program adds n numbers which will be entered by a user. The user will enter a number indicating how many numbers to add and then the user will enter n numbers. We can do this by using or without using an…
Read more

C program to swap two numbers

  C program to swap two numbers C program to swap two numbers with and without using third variable, using pointers, functions (Call by reference) and using bit-wise XOR operator. Swapping means interchanging. If the program has two variables a and b where a = 4 and b = 5, after swapping them, a =…
Read more

C program to reverse a number

  C program to reverse a number C program to reverse a number and to print it on the screen. For example, if the input is 123, the output will be 321. In the program, we use the modulus operator (%) to obtain digits of the number. To invert the number write its digits from…
Read more

Palindrome number in C

  Palindrome number in C A palindrome number is one that remains the same on reversal. Some examples are 8, 121, 212, 12321, -454. To check if a number is a palindrome or not, we reverse it and compare it with the original number, if both are the same, it’s a palindrome otherwise not. C…
Read more

Pattern programs in C

  Pattern programs in C Pattern programs in C language, showing how to create various patterns of numbers and stars. The programs require nested loops (a loop inside another loop). A design of numerals, stars, or characters is a way of arranging these in some logical manner, or they may form a sequence. Some of…
Read more

C program to print diamond pattern

  C program to print diamond pattern The diamond pattern in C language: This code prints a diamond pattern of stars. The diamond shape is as follows: * *** ***** *** * C programming code #include <stdio.h> int main() { int n, c, k, space = 1; printf(“Enter number of rows\n“); scanf(“%d”, &n); space =…
Read more

Prime number program in C

  Prime number program in C Prime number program in C language to check whether a number is prime or composite, to print prime numbers. A number is prime if it’s divisible only by one and itself. Two is the only even and the smallest prime number. First few prime numbers are 2, 3, 5,…
Read more

Armstrong number in C

  Armstrong number in C Armstrong number C program: C programming code to check whether a number is an Armstrong number or not. An Armstrong number is a number that is equal to the sum of digits raise to the power total number of digits in the number. Some Armstrong numbers are: 0, 1, 2,…
Read more