Posts

C Program for Compound Preposition | Discrete Mathematics | C Programming

Compound Preposition One that can be broken down into more primitive propositions. E.g., If it is sunny outside then I walk to work; otherwise I drive, and if it is raining then I carry my umbrella.

C Program To Implement Dijkstra's Algorithm For Finding Shortest Path | C Programming

C Program To Implement Dijkstra's Algorithm For Finding Shortest Path | C Programming #include "stdio.h" #include "conio.h" #define infinity 999 void dij ( int n , int v , int cost [ 10 ][ 10 ], int dist []) {     int i , u , count , w , flag [ 10 ], min ;     for ( i = 1 ; i <= n ; i ++)         flag [ i ] = 0 , dist [ i ] = cost [ v ][ i ];     count = 2 ;     while ( count <= n )     {         min = 99 ;         for ( w = 1 ; w <= n ; w ++)             if ( dist [ w ] < min && ! flag [ w ])                 min = dist [ w ], u = w ;         flag [ u ] = 1 ;         count ++;         for ( w = 1 ; w <= n ; w ++)             if (( dist [ u ] + cost [ u ][ w ] < dist [ w ]) && ! flag [ w ])                 dist [ w ] = dist [ u ] + cost [ u ][ w ];     } } int main () {     int n , v , i , j , cost [ 10 ][ 10 ], dist [ 10 ];     printf ( "Enter the number of nodes:" );     scanf ( "

C Program To Find Minimum Spanning Tree Using Kruskal's Algorithm | C Programming

C Program To Find Minimum Spanning Tree Using Kruskal's Algorithm  #include <stdio.h> #include <conio.h> #include <stdlib.h> int i , j , k , a , b , u , v , n , ne = 1 ; int min , mincost = 0 , cost [ 9 ][ 9 ], parent [ 9 ]; int find ( int ); int uni ( int , int ); int main () {     printf ( " \n\t Implementation of Kruskal's Algorithm \n " );     printf ( " \n Enter the no. of vertices:" );     scanf ( " %d " , & n );     printf ( " \n Enter the cost adjacency matrix: \n " );     for ( i = 1 ; i <= n ; i ++)     {         for ( j = 1 ; j <= n ; j ++)         {             scanf ( " %d " , & cost [ i ][ j ]);             if ( cost [ i ][ j ] == 0 )                 cost [ i ][ j ] = 999 ;         }     }     printf ( "The edges of Minimum Cost Spanning Tree are \n " );     while ( ne < n )     {         for ( i = 1 , min = 999 ; i <= n ; i ++)         {  

Difference Between Procedure Oriented Programming (POP) & Object Oriented Programming (OOP)

Difference Between Procedure Oriented Programming (POP) & Object-Oriented Programming (OOP) | C++ Programming Procedure Oriented Programming Object-Oriented Programming Divided Into In POP, the program is divided into small parts called  functions . In OOP, the program is divided into parts called  objects . Importance In POP, Importance is not given to  data  but to functions as well as the  sequence  of actions to be done. In OOP, Importance is given to the data rather than procedures or functions because it works as a  real world . Approach POP follows  Top-Down approach . OOP follows  Bottom-Up approach . Access Specifiers POP does not have any access specifier. OOP has access specifiers named Public, Private, Protected, etc. Data Moving In POP, Data can move freely from function to function in the system. In OOP, objects can move and communicate with each other through member functions. Expansion To add new data and function in POP is not so easy. OOP provides an

C++ Program For Banking System Using Class | C++ Programming

C++ Program For Banking System Using Class #include <iostream> using namespace std ; #include <iomanip> class bank {     char name [ 20 ];     int acno ;     char actype [ 20 ];     int bal ; public:     void opbal ( void );     void deposit ( void );     void withdraw ( void );     void display ( void ); }; void bank :: opbal ( void ) {     cout << endl          << endl;     cout << "Enter Name :-" ;     cin >> name ;     cout << "Enter A/c no. :-" ;     cin >> acno ;     cout << "Enter A/c Type :-" ;     cin >> actype ;     cout << "Enter Opening Balance:-" ;     cin >> bal ; } void bank :: deposit ( void ) {     cout << "Enter Deposit amount :-" ;     int deposit = 0 ;     cin >> deposit ;     cout << " \n Deposit Balance = " << bal + deposit ; } void bank :: withdraw ( void ) {     int withdraw ;     c

C++ Program for Constructor Overloading | C++ Programming

Constructor Overloading When more than one constructor function is defined in a class, then it is called constructor overloading or the use of multiple  constructors  in a class. It is used to increase the flexibility of a class by having a greater number of constructors for a single class. Overloading constructors in C++ programming gives us more than one way to initialize objects in a class.

C++ Program To Find Negation Of A Number | C++ Programming

C++ Program To Find Negation Of A Number #include <iostream> using namespace std ; class point {     int x , y ; public:     void getdata ()     {         cout << "Enter x and y coordinate:" ;         cin >> x >> y ;     }     void display ()     {         cout << "(" << x << "," << y << ")" ;     }     point operator- ()     {         point t ;         t . x = - x ;         t . y = - y ;         return t ;     } }; int main () {     point p , q ;     p . getdata ();     q = - p ;     cout << "q=" ;     q . display (); } OUTPUT Enter x and y coordinate: 5 4 q=(-5,-4)