C Examples For Beginners – Programming Code Examples
C

C Examples For Beginners43 min read

C Program to Display “Hello, World!”

Output

C Program to Print an Integer

Output

C Program to Add Two Integers




Output

C Program to Multiply Two Numbers

Output

C Program to Print ASCII Value

Output

C Program to Compute Quotient and Remainder

Output

C Program to Find the Size of Variables

Output

C Program to Find the Size of Variables

Output

C Program Using the long keyword

Output

C Swap Numbers Using Temporary Variable

Output

C Program to Check Even or Odd

Output

C Program to Check Vowel or consonant

Output

C Program to Find the Largest Number Among Three Numbers

Example 1: Using if Statement


Example 2: Using if…else Ladder


Example 3: Using Nested if…else

Output:

C Program to Find Roots of a Quadratic Equation

Output

C Program to Check Leap Year

Output 1

Output 2

C Program to Check Positive or Negative Using if…else

You can also solve this problem using nested if else statement.


C Program to Check Positive or Negative Using Nested if…else

 

Output 1

Output 2

C Program to Check Alphabet

Output

C Program to Sum of Natural Numbers Using for Loop

The above program takes input from the user and stores it in the variable n. Then, for loop is used to calculate the sum up to n.


C Program to Sum of Natural Numbers Using while Loop

Output

In both programs, the loop is iterated n number of times. And, in each iteration, the value of i is added to sum and i is incremented by 1.

 

Though both programs are technically correct, it is better to use for loop in this case. It’s because the number of iterations is known.

The above programs don’t work properly if the user enters a negative integer. Here is a little modification to the above program where we keep taking input from the user until a positive integer is entered.


C Program to Read Input Until a Positive Integer is Entered

C Program to Find Factorial of a Number

Output

C Program to Print Multiplication Table Up to 10

Output

C Program to Print Multiplication Table Up to a range

Output

C Program to Print Fibonacci Series up to n terms

 

Output

C Program to Print Fibonacci Sequence Up to a Certain Number

Output

C Program to GCD Using for loop and if Statement

C Program to GCD Using while loop and if…else Statement

Output

C Program to GCD for both positive and negative numbers

Output

C Program to LCM using while and if

Output

C Program to LCM Calculation Using GCD

Output

Program to Print English Alphabets

Output

C Program to Print Lowercase/Uppercase alphabets

Output

C Program to Count the Number of Digits

Output

C Program to Reverse an Integer

Output

C Program to Power of a Number Using the while Loop

Output

C Program to Power Using pow() Function

Output

C Program to Check Palindrome

Output

C Program to Check Prime Number

Output

C Program to Display Prime Numbers Between Two Intervals

Output

C Program to Display Prime Numbers when Larger Number is Entered first

Output

C Program to Check Armstrong Number of n digits

Output

C Program to Display Armstrong Numbers Between Two Integers

 

Output

C Program to Find Factors of a Positive Integer