Category: C programming

python tutorials and learn python

Created with Sketch.

Hello world C

  Hello world C   How to write a hello world in C language? To learn a programming language, you must start writing programs in it, and this could be your first C program. Let’s have a look at the program first. #include <stdio.h> int main() { printf(“Hello world\n“); return 0; } Library function printf…
Read more

Print an int (integer) in C

  Print an int (integer) in C Print an integer in C language: a user inputs an integer, and we print it. Input is done using scanf function, and the number is printed on screen using printf. C priogram to print an int (integer) #include <stdio.h> int main() { int a; printf(“Enter an integer\n“); scanf(“%d”,…
Read more

Addition of two numbers in C

  Addition of two numbers in C The addition of two numbers in C language is performing the arithmetic operation of adding them and printing their sum on the screen. For example, if the input is 5, 6, the output will be 11. Addition program in C #include <stdio.h> int main() { int x, y,…
Read more

Even or odd program in C

  Even or odd program in C C programs to check odd or even using different methods. In the decimal number system, even numbers are exactly divisible by two while odd numbers are not. We can use modulus operator ‘%’ which returns the remainder, for example, 4%3 = 1 (remainder when four is divided by…
Read more

C program to perform addition, subtraction, multiplication and division

  C program to perform addition, subtraction, multiplication and division C program to perform basic arithmetic operations which are addition, subtraction, multiplication, and division of two numbers. Numbers are assumed to be integers and will be entered by a user. In C language when we divide two integers we get an integer as a result,…
Read more

C program to check whether a character is a vowel or consonant

  C program to check whether a character is a vowel or consonant C program to check whether a character is a vowel or consonant: A user will input a character and we will check whether it is a vowel or not. Both lower-case and upper-case are checked. Check vowel using if else #include <stdio.h>…
Read more

Leap year program in C

  Leap year program in C C program to check leap year: C code to check if a year is a leap year or not. To understand logic of the program read Leap year article at Wikipedia. This code is based on the Gregorian Calendar. C program to check leap year  #include <stdio.h> int main()…
Read more

Sum of digits in C

  Sum of digits in C C program to calculate the sum of digits of a number: we will use modulus operator (%) to extract individual digits of a number and keep on adding them. Sum of digits of a number in C #include <stdio.h> int main() { int n, t, sum = 0, remainder;…
Read more

Factorial program in C

  Factorial program in C Factorial program in C using a for loop, using recursion and by creating a function. Factorial is represented by ‘!’, so five factorial is written as (5!), n factorial as (n!). Also, n! = n*(n-1)*(n-2)*(n-3)…3.2.1 and zero factorial is defined as one, i.e., 0! = 1. Factorial in C using…
Read more

C program to find HCF and LCM

  C program to find HCF and LCM C program to find HCF and LCM: The code below find the highest common factor and the least common multiple of two integers. HCF is also known as the greatest common divisor (GCD) or the greatest common factor (GCF). C programming code #include <stdio.h> int main() {…
Read more