Posts

C Program to Print Pascal's Triangle

Write a C Program to Print Pascal's Triangle Table of Contents Problem Defination Source Code Output Program What is Pascal's Triangle ? Pascal's Triangle is a triangular array of binomial co-efficient. It is constructed by summing adjacent elements in preceding rows. Pascal’s triangle can be used as an instance of binomial coefficient and binomial theorem. Problem Definition We have to write a C program that will print pascal's triangle. Solution/Source Code Here is the Source C code to print Pascal's Triangle. Output results are also shown below. #include <stdio.h> int main() { int rows, co = 1, space, i, j; printf("Enter the number of rows: "); // total numbers of rows in pascal's triangle scanf("%d", &rows); for (i = 0; i < ro...

Write a C program to convert Infix to Postfix Expression

C Program to convert infix expression to equivalent postfix Table of Contents Problem Defination Source Code Output Program Problem Definition We will be provied a infix expression and all we have to do is to convert that equation into its equivalent postfix expression using C Language. Solution/Source Code Here is the Souce C code to convert an infix expression to its equivalent postfix expression using stack. We will be using here few functions to impliment the code easily. The below code snippets are successfully compiled and runned on DEV C++ Windows 10 Platform. Output results are also shown below. #include<stdio.h> #include<string.h> #define MAX 50 char stack[MAX]; int top=-1; void push(char a){ stack[++top]=a; } int pop(){ return(stack[top--]); } int pre(char s){ int a; switch(s){ case '+': case '-': a=1; break; case '*': case '/': case '%...

C Program to search element from a sorted array using Binary Search

C Program to search element from a sorted array using Binary Search Table of Contents Problem Defination Source Code Output Program Problem Definition We have to implement a C program that will search a value from a Sorted Integer Array using Binary Search Algorithms. The Search value will be a user input value. Solution/ Source Code Here is the Souce C code to find whether a search element is present in the array or not using Binary Search Algorithms. The below code is tested multiple times successfully using gcc Compiler on DEV C++ Windows 10 Platform. Output results are also shown below. Program Output Enter the number of elements=5 a[0]= 10 a[1]= 20 a[2]= 30 a[3]= 40 a[4]= 50 Enter the value to be searched=40 value 40 is present in possition 4. -------------------------------- Enter the number of elements=5 a[0]= 15 a[1]= 25 a[2]= 35 a[3]= 45 a[4]= 55 ...