Posts

C Programming Code To Create Pyramid and Pattern

Examples to print half pyramid, pyramid, inverted pyramid, Pascal's Triangle and Floyd's triangle in C Programming using control statements.  Read -  Programming language To understand this example, you should have the knowledge of following C programming topics: C if, if...else and Nested if...else Statement C Programming for Loop C Programming while and do...while Loop C Programming break and continue Statement Programs to print triangles using *, numbers and characters Example 1: Program to print half pyramid using * * * * * * * * * * * * * * * * Source Code #include <stdio.h> int main () { int i , j , rows ; printf ( "Enter number of rows: " ); scanf ( "%d" ,& rows ); for ( i = 1 ; i <= rows ; ++ i ) { for ( j = 1 ; j <= i ; ++ j ) { printf ( "* " ); } printf ( "\n" ); } return ...

C Program to Make a Simple Calculator Using switch...case

Example to create a simple calculator to add, subtract, multiply and divide using switch and break statement. To understand this example, you should have the knowledge of following C programming topics: C switch...case Statement C Programming break and continue Statement This program takes an arithmetic operator  +, -, *, /  and two operands from the user and performs the calculation on the two operands depending upon the operator entered by the user. Read -  Programming language Example: Simple Calculator using switch Statement // Performs addition, subtraction, multiplication or division depending the input from user # include <stdio.h> int main () { char operator ; double firstNumber , secondNumber ; printf ( "Enter an operator (+, -, *,): " ); scanf ( "%c" , & operator ); printf ( "Enter two operands: " ); scanf ( "%lf %lf" ,& firstNumber , & secondNumb...