Skip to main content

Posts

Showing posts from August, 2017

how to implement adding of numbers in PROLOG

write a knowledge base add.pl with the following rules: // for two variables  sum(X,Y):-     S is X+Y,    write('sum of '),write(X),write('and '),write(Y),write('is ='),write(S). add:-     write_ln('Enter the first number:-'),     read(First),     write_ln('Enter second number:-'),     read(Second),     S is First+Second,      write('sum of '),write(First),write('and '),write(Second),write('is ='),write(S). now we can close this windows and in the main WINDOW either type  ['add.pl']. or consult the add.pl file. now you can call this funcation via two ways :- ?- sum(5,44). it will give output as  sum of 5 and 44 is 49 or you can call via  add. Enter the first number . :| 45. Enter the second Number . :| 45. sum of 45 and 45 is equal to 90. note i have used sum:- instead of add:- so i have to call it via sum.

How to do simple arithmatic in PROLOG

well you can either use any way to get simple arithmatics in prolog. For example typing X is 3+2. gives X=5. in prolog . Similarly you can write R is 5*2. it will give R= 10. so doing simple arithmatics is very simple. please note that X or R is capital it can not be a lowercase character otherwise prolog will give output as true. or use this knowledge base .!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!copy from below!!!!!!!!!!!!!!!!!!!!!!!!!!!! sum:-     write_ln('Enter the first number:-'),     read(First),     write_ln('Enter second number:-'),     read(Second),     S is First+Second,      write('sum of '),write(First),write('and '),write(Second),write('is ='),write(S). sub:-     write_ln('Enter the first number:-'),     read(First),     write_ln('Enter second number:-'),     read(Second),     S is First-Second,      write(' difference  of '),write(Firs

how to write a Factorial program in PROLOG.

So to Write A prolog programming . First Fire up your SWI -PROLOG software. then you will see something like this . Welcome to SWI-Prolog (threaded, 64 bits, version 7.4.2) SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software. Please run ?- license. for legal details. For online help and background, visit http://www.swi-prolog.org For built-in help, use ?- help(Topic). or ?- apropos(Word). ?- _ 1. So now go to File>NEW.... and give any name to knowledge base file. I Give it factorial .pl 2.  now write the follwing fact and rules . fact(0,1) . fact(N,R):-  N>0, N1 is N-1, fact(N1,R1), R is N*R1. now press ctrl +s to save  . 3. now close this windows . 4. now in the main window goto file > Consult..... and select your factorial.pl 5. now you can type query like fact(5,X). it will return X=120. done..... here are some screen shot :

C AND C++ program to find out a pattern within a String

This program takes an input string From user and tell if the given string is present in the String or not Example: This is always true pattern-> is  output -> pattern found  and if pattern input -> zxc output -> No match found  NOTE: CODE:: BLOCKS IS USED in editing and compiling the source code .... +++++++++++++++++++++++++++++C Source Code ++++++++++++++++++++++++++++++ #include <stdio.h> #include <conio.h> void main () { char str[999],pattern[999]; int flag=0,i,j=0,loc; printf("Enter the string \n"); gets(str); printf("Enter the string to find pattern\n"); gets(pattern); for(i=0;str[i]!='\0';i++) { /// main for loop     if(flag==1) break;     if(str[i]==pattern[0])     {/// a match is found         i++;         flag=1; loc=i;         for( j=1;pattern[j]!='\0';j++)         {             if(str[i]!=pattern[j])             {             flag=0

C++ Program to find out the Prime number's By sieve Method

NOTE : YOU CAN DOWNLOAD EXE FILE HERE: SIEVE.EXE SORUCE CODE (RTF): source.cpp click here   1  #include <iostream>  2  #include <conio.h>  3  using namespace std ;  4  int main ()  5   6  {  7   8  int number , n = 2 ;  9  cout << "Program to find out Prime number by sieve method\n\n\a" ; 10  11  cout << "Enter upto which number you want to find out the prime number\n" ; 12  cin >> number ; 13  int arr [ number ]; 14  for ( int i = 0 ; i < number ; i ++) 15  arr [ i ]= i + 1 ; 16  cout << "  Original number:\n" ; 17  18  for ( int i = 0 ; i < number ; i ++) 19  { 20  21  22      cout << arr [ i ]<< "\t\a" ; 23  24  } 25  while (( n * n )< number )  // while n 2  is less than original  number 26  27  { 28  29  for ( int i = n ; i < number ; i ++) 30  { 31  if ( arr [ i ]% n == 0 ) 32  { 33  arr [ i ]=- 1 ; 34

C++ program to find out the Second Largest and largest number stored in a array

Q: Write A C++ program to find out the largest as well as the second largest element in an array(user input the elements first)? note that every number is treated as a unique so largest or second largest can not be the same. FOr EXAMPLE : 45 45 32 78 9 12 in this answer should come as largest =45 and second largest=32 EXAMPLE 2 :  12 10 11 4 10 12 23 in this answer should be like largest=233 and second largest =12  code here source : click here Executables: LARGEST AND SECOND LARGEST.EXE (click here)

Mapel Download : Download mapelsoft Mapel Enggineering Btech CS & IT . DSL Lab

Maplesoft Maple 2016 Final Release is an advanced Math calculation software that provides results in seconds that helps users perform complex mathematical equations with various functions. Practitioners of such related fields as mathematics, engineering or science will soon notice that Maple is an advanced calculator for any of these branches of knowledge. It combines the most powerful spreadsheets with the most intuitive interface computational engine. Maple 2016 Serial Key Features: Maple 2016 is a powerful computational engine, which guarantees accurate results in everything that is a technical calculation. Starting from there, a whole world of possibilities opens. * Tool for simple and complex mathematical operations. * Interface optimized for intuitive handling by users. * Includes all kinds of tools: editors of mathematical equations, symbols, graphs 2D and 3D image recognition, modules etc. Calculation for all: The workflow in Maple develops around t