C Programming Code Examples
C > If Else and Switch Case Code Examples
if...else statement - check whether an integer entered by the user is odd or even
Code Sum of Prime numbers between 1- n -
C program to find sum of all prime numbers between 1 to n using for loop. Prime numbers are positive integers greater than 1 that has only two divisors 1 and the number itself. For
Creating a Function Checks Prime Number -
Function returns true if the number passed to the function is a 'prime number', returns false if the number passed is not a 'prime number'. The appropriate message is printed from the
Code Finds the Sum of 2 Binary Numbers -
Take two Binary Numbers as input. Add each bits from the two binary numbers separately starting from LSB. The operations may be as follows. a) (0+0)=0, b) (1+0)=1, c) (1+1)=0 and
Code Print Natural Numbers from 1 to N -
Declare c recursive function to print natural numbers in a range. Lets give a meaningful name to function, "printNaturalNumbers()". Next we need to print Natural Numbers in...
Enter Week Number & Prints Day of Week -
C language program input week number(1-7) & print the corresponding day of week name using if else. Input week day number. Store it in some variable say week. And print Monday
C++ Language Do While Loop Statements -
The statement is executed, then expression is evaluated. If it is true, statement is evaluated again, and so on. When 'expression' becomes false, the 'loop terminates'. Experience shows
Most Significant Bit (MSB) of a number is -
In C programming language we use bitwise AND & operator to check status of any bit. Bitwise AND operation evaluate each bit of resultant value as 1, if corresponding bit of...
C++ Language & Monoalphabetic Cypher -
A substitution cipher is a method of encoding by which units of 'plaintext are replaced' with ciphertext, according to a regular system; the "units" may be "single letters", pairs of letters