Thursday, September 27, 2012

Doubly Linked Lists Implementation using oops of c plus plus | Data Structure

Doubly Linked Lists Implementation using oops of c plus plus | Data Structure By Sanjay Sinalkar Write a program in c++ using object oriented concept to create Double Linklist which having following functionality  1)Insert element at Begin 2)Insert element at given position 3)Insert element at End 4)Delete element from Begin 5)Delete element From End 6)Delete element from Given position  7) Show all element Inserted in Display function() Program...

Monday, September 17, 2012

Stack implementation in c++ code using array | Data Structure

Stack implementation in c++ code using array  | Data StructureThis program is the demonstration for implementing Simple Stack Program using array and Object Oriented Concept with basic functions of Stack push() and pop() with index called top which gives the current status of Stack! Stack has defined size so need two more function to check whether isEmpty() or isFull() to check stack is empty or not or is full or not. In this scenario top is integer type as default to top=-1,if top=-1 Mean Stack is Empty , if top=sizeOfStack-1 then stack is...

Thursday, September 13, 2012

Function Overloading for Volume Calculation C++ Programming

Function Overloading for Volume Calculation C++ Programming  ...

Virtual Function Implementation in C++ Programming

Virtual Function Implementation in C++ ProgrammingQuestion:Write a base class called Employee. Use this class to store values name, salary etc. Derive three specific classes called Manager, Teamleadand Programmer. Add to the base class, a member function get_data() to initialize base class data members and another function display() to compute and display information . Make display() as a virtual function and redefine this function in the derived classes to suit their requirement...

Operator Overloading in C++ Programming Hr Min Sec Example

Operator Overloading in C++ Programming Hr Min Sec ExampleQuestion:Create a class Time with members hr, min and sec. Write all threeconstructors, destructor, and make one static member to count the objects ofclass.Overload the following operators :>>,<<,= =,=,+,++,-- Solutions: /* Program for Operator Overloading */ #include<iostream> using namespace std; static int c=0; class Time { public: int hr,m,s; Time() { hr=0;m=0;s=0; //cout<<"\nDefault Constructor Called!"<<endl; c++; } Time(int thr,int tm,int ts) { hr=thr; m=tm; s=ts; //cout<<"\nParameterized...

Friend Function Implementation in C++ Programming

Friend Function Implementation in C++ ProgrammingQuestions:- Create two classes DM and DB which store the value of distances. DM stores distances in meters and centimeters and DB in feet and inches. Write a program that can read values for the class objects and add one object of DM with another object of DB. Use a friend function to carry out the addition operation. The object that stores the results may be a DM or DB object, depending on the units in which the results are required. (Object Oriented Programming With C++ By Balaguruswam...

Find element in array and its repetition in one dimensional Array C program

Find element in array and its repetition in one dimensional Array C program Program to accept elements in array then take input from user to find that element and its repetition in Single Dimensional Arr...

Fibonacci series using Recursive Function C program

Fibonacci series using Recursive Function C program Program to print the Fibonacci Series up to given term by using recursive Function in C program. Same Logic will be also work in C++ Programs als...

Sin Cos Function Implementation in C program

Sin Cos Functions Implementation in C program Question :Write functions to calculate the sine and cosine of their input. Choose appropriate types for both argument and return value. The series (given below) can be used to approximate the answer. The function should return when the value of the final term is less than 0.000001 of the current value of the function. sin x = x - pow(x,3)/fact(3) + pow(x,5)/fact(5)... cos x = 1 - pow(x,2)/fact(2) + pow(x,4)/fact(4)... Note the fact that the sign in front of each term alternates ...

Sunday, September 2, 2012

Program to find Vowel in given Character in C Program

Program to find Vowel in given Character in C Program This is program to check given character is under vowel character or not using simple if condition. /* Program For Detecting Vowel*/ #include<stdio.h> int main() { char a; printf("\nEnter character\n"); scanf("%c",&a); if(a=='a'|| a=='e'|| a=='i'|| a=='o'|| a=='u' || a=='A'|| a=='E'|| a=='I'|| a=='O'|| a=='U') { printf("\nThis Alphabet Is Vowel....!\n"); } else { printf("\nThis is Not a Vowel..!\n"); } return 0; }...

Reverse Number Logic in C program

Reverse Number Logic in C program This is program for reversing digit of given number by simple logic. Program use While loop for repetitive process. /* Program For Reverse a Number*/ #include<stdio.h> #include<math.h> int main() { int no,rem; printf("\nEnter no\n"); scanf("%d",&no); int bs=no; int sum=0; while(no) { rem=no%10; sum=sum*10+rem; no=no/10; } printf("Reverse Of %d is \t :%d\n",bs,sum); return 0; } ...

Prime number Logic to check it in C program

Prime number Logic to check it in C program This program use to check given number is Prime no or not. As prime number not divisible by any number except by itself and one. /* Program For Prime No*/ #include<stdio.h> int main() { int no,i=2; printf("\nEnter no\n"); scanf("%d",&no); int a=1; while(i<=no/2) { if(no%i==0) a=0; i++; } if(a==1) printf("No %d is Prime No...!\n",no); else printf("No %d is Not a Prime No....!\n",no); return 0; } ...

Check Palindrome Number from given Input Integer C program

Check Palindrome Number from given Input Integer C program This program use to check given input integer is palindrome or not. Simple just reversing and storing digit to sum then compare it with back one! /* Program For To Palindrome No. */ #include<stdio.h> #include<math.h> int main() { int no,rem; printf("\nEnter no\n"); scanf("%d",&no); int bs=no; int sum=0; while(no) { rem=no%10; sum=sum*10+rem; no=no/10; } if(bs==sum) printf("No %d is Palindrome No.\n",bs); else printf("\nNo %d is not a Palindrome.....!\n",bs); return...

Find Maximum Number in array in C program

Find Maximum Number in array in C program This program to find the maximum number in 1 Dimensional array. Accept number then compare it with previous maximum if true then replace it with new one as simple as that /* Program to Find Maximum No in array */ #include<stdio.h> int main() { int a[100],n,i,max=0; printf("enter the no.:"); scanf("%d",&n); for(i=1;i<=n;i++) { printf("enter the value of %d no.:",i); scanf("%d",&a[i]); if(max<a[i]) max=a[i]; } printf("\nThe max is %d\n",max); return 0; } ...

Program to Find Leap year in C Program

Program to Find Leap year in C Program The program for find out the given year under leap year are or not. Leap year logic is simple as the year which divisible by 400 or divisible by 4 and not by 100 . /* Program For Finding Leap Year*/ #include<stdio.h> int main() { int yr; printf("\nEnter year\n"); scanf("%d",&yr); if( (yr%4==0 && yr%100!=0) || yr%400==0) { printf("\n%d is Leap year!\n",yr); } else { printf("\n%d is Not a Leap year..!\n",yr); } return 0; }...

Factorial of a Number Using While loop in C program

Factorial of a Number Using While loop in C programThis is program to find out factorial of a number using simple while loop. this logic use to create a function like fact to find out any factorial of number /Integer. /* Program For Factorial Of a No.*/ #include<stdio.h> int main() { int no,temp=1; printf("\nEnter no\n"); scanf("%d",&no); int fact=1; while(1) { if(temp>no) break; fact=fact*temp; temp++; } printf("Factorial of No %d \t is :%d\n",no,fact); return 0; } ...

Decimal to Binary Conversion Logic in C program

Decimal to Binary Conversion Logic in C programThis is program which is gives you output as Binary of any Integer. Program Store the binary output as Integer just for reference. We can use it further where required. Decimal to binary needs Math.h Library file to use power function. /* Program For Decimal to Binary Conversions*/ #include<stdio.h> #include<math.h> int main() { int no,rem; printf("\nEnter no\n"); scanf("%d",&no); int bs=no; int sum=0; int pw=0; while(no) { rem=no%2; sum=sum+rem*(pow(10,pw)); no=no/2; pw++; } printf("Decimal...

Calculator Operation Using Switch Case C program

Calculator Operation Using Switch Case C programThis program specially for Calculator Operation Using Switch Case C program which can do Addition,Subtractions,Multiplication,Division mathematical operations. It also has Menu to do Such Options in Simple Formats /* Program For Addition,Subtraction,Division,Multiplication*/ #include<stdio.h> int main() { int a,b,c; while(1) { printf("\n****Choose The Following Options****\n"); printf("-Press 1 for Additions\n"); printf("-Press 2 for Subtractions\n"); printf("-Press 3 for Multiplication\n"); printf("-Press...

Addition of Digits of Given No C Program

Addition of Digits of Given No C Program This program specially for separating the digits from given more than 2 digit no and add it together . This logic mainly useful at the time of reversing the digit of given no. /* Program For Adding digits of No*/ #include<stdio.h> int main() { int no,temp; printf("\nEnter no\n"); scanf("%d",&no); int bs=no; int count=; while(no) { temp =no%10; sum=sum+temp; no=no/10; } printf("Sum of digit of this no %d \t :%d\n",bs,sum); return 0; ...

Check Armstrong Number from given Input Integer C program

Check Armstrong Number from given Input Integer C programThis program is to check given input integer is Armstrong Number or Not such that sum of qube of each digit is equal to that no. /* Program to check Armstrong No*/ #include<stdio.h> #include<math.h> int main() { int no,rem; printf("\nEnter no\n"); scanf("%d",&no); int bs=no; int sum=0; while(no) { rem=no%10; sum=sum+(pow(rem,3)); no=no/10; } if(bs==sum) printf("The No %d is Armstrongs No.....!!!\n",bs); else printf("The No %d is not a Armstrongs NO....!!\n",bs); return...

Addition of Two Dimensional Matrix in C program

 Addition of Two Dimensional Matrix in C program The following program is the example of 2 Dimensional Array for adding it and save it to 3rd Array. /* Program to Addition of two Matrix */ #include<stdio.h> void printarry(int ap[2][2]); int main() { int n,i,j; int a[2][2],b[2][2],c[2][2]; printf("Enter The A matrix"); for(i=0;i<2;i++) { for(j=0;j<2;j++) { scanf("%d",&a[i][j]); } } printf("Enter the B Matrix"); for(i=0;i<2;i++) { for(j=0;j<2;j++) { scanf("%d",&b[i][j]); } } for(i=0;i<2;i++) { for(j=0;j<2;j++) { ...