Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes

C Programming Code Examples

C > For Loops and While Loops Code Examples

1. It is initializing two variables. Note: both are separated by comma (,). 2. It has two test conditions joined together using AND (&&) logical operator. You cannot use multiple test

C language code to convert binary to decimal number system. The Binary number system is base 2 number system & uses only 2 symbols to represent all its numbers i.e. 0 and 1. Input

How to convert from decimal number system to binary number system in C programming. C program to convert from Decimal to Binary number system. Input decimal number from

C Program to count number of digits without using loop. The second logic uses logarithms to count number of digits in a given integer. Total number of digit in an integer is equal to

Printing alphabets in C Programming, is little trick. If you are good at basic data types and literals then this is easy for you. Internally C represent every character using ASCII Code.

C Language code input a number and print it into words using for loop. Input number from user. Find total digits in n. Store reverse of n in j. Find total trailing zeros. Extract last digit

C Program to print odd numbers from 1 to n without if statement. The above approach is not optimal approach to print odd numbers. Observe the above program for a while. You

Logic to find all Armstrong number between 1 to n. Input Upper Limit to print Armstrong number from user. Store it in some variable say end. Run a loop from 1 to end, increment

C Language program code to find first & last digit. Input a number from user & store it in some variable say num. Find last digit using modulo division by 10 lastDigit = num % 10.

Finding the first digit of any number is little expensive than last digit. To find first digit of a number we divide the given number by 10 until number is greater than 10. At the end...

Input upper limit to find sum of even number. Store it in a variable say N. Initialize another variable to store sum with 0 say sum = 0. To find sum of even numbers we need to iterate

C Language Program to input a number and find sum of first and last digit of the number using for loop. Input a number. Find last digit. Find total number of digits - 1. Find first digit.

How to find sum of all odd numbers in a given range in C programming. Input upper limit to find sum of odd numbers from user. Store it in a variable say N. Initialize other variable to

C program to find sum of all prime numbers between 1 to N. Input Lower and Upper limit from user. Find prime numbers in the range. Check if the current number x is Prime or not.

C Program Code to print all Perfect Numbers between 1 to n. A Perfect number is a positive integer which is equal to the sum of its proper positive divisors. Input upper limit from user

The above approach to list Even Numbers is not optimal. It unnecessarily iterates for odd numbers which is a performance issue and to overcome this start the loop with first even...

Fibonacci series is a series of numbers where the current number is the sum of previous 2 terms. For Example: 0, 1, 1, 2, 3, 5, 8, 13, 21,... Here c is the current term, b is the n-1th term

Logic to print Natural Number in reverse in a given range. If you got above logic, then you can easily modify to print natural numbers in reverse in given range. We need to make two

Using above logic you can easily find a way to print natural numbers in range. If not here is a hint. Input start limit from user and store it in some variable say start. Input end limit from
C program to print all odd numbers from 1 to n using for loop. Input lower and upper limit from user. If start is not odd then make it odd And Initialize loop from start, increment it by
C program print all prime numbers between 1 to n. Input upper & lower limit to print prime. Find Prime numbers between 1 to n. Assume that the current number is Prime and check if
Strong number is special number whose sum of Factorial of Digits is equal to the original number. For example: 145 is strong number. Since, 1! + 4! + 5! = 145 Logic to print Strong
C Program to input a Number from user and swap first and last digit of the given number. First input a number from user and find last digit. Total number of digit - 1. Find first digit.
When using while or do-while loop you need to place an increment, decrement statement just above the continue so that counter value is changed for the next iteration. if we do not
The variable count is initialized with value 1 and then it has been tested for the condition. If the condition returns true then statements inside the body of while loop are executed...

Page 1 Page 2 Page 3