Sunday, 27 August 2017

c program for inter-process communication using double pipe (with algorithm)

c program for inter-process communication using double pipe (with algorithm)

aim : to implement inter-process communication using double pipe

algorithm :

step 1 : start
step 2 : declare p1,p2,buff1[25],buff2[25],pid
step 3 : call system calls pipe(p1),pipe(p2)
step 4 : call the fork and initialize pid
step 5 : check if pid==0 then goto step 6 else goto step 11
step 6 : read the message to parent and store on buff1
step 7 : write the message to child using pipe p1
step 8 : call sleep()
step 9 : read the message from parent using pipe p2 and store in buff1
step 10 : print the message from parent
step 11 : read the message from child using pipe p1
step 12 : print the message from child
step 13 : read the message from child
step 14 : write the message to child using pipe2
step 15 : stop

C PROGRAM FOR INTER-PROCESS COMMUNICATION USING SINGLE PIPE (WITH ALGORITHM)

C PROGRAM FOR INTER-PROCESS COMMUNICATION USING SINGLE PIPE (WITH ALGORITHM)

AIM : TO IMPLEMENT INTERPROCESS COMMUNICATION USING SINGLE PIPE

ALGORITHM :

STEP 1 : START

STEP 2 : DECLARE P[2],PID,BUFF

STEP 3 : CALL THE SYSTEM CALL PIPE(P)

STEP 4 : CREATE A PROCESS

STEP 5 : IF THE PROCESS IS CHILD THEN GO TO STEP 6

STEP 6 : READ THE MESSAGE FOR PARENT

STEP 7 : WRITE THE MESSAGE TO PARENT

STEP 8 : CALL SLEEP()

STEP 9 : READ THE MESSAGE FROM PARENT

STEP 10 : PRINT THE MESSAGE FROM PARENT

STEP 11 : IF THE PROCESS IS PARENT, GO TO STEP 12

STEP 12 : READ THE MESSAGE FROM CHILD

STEP 13 : DISPLAY THE MESSAGE FROM CHILD

STEP 14 : READ THE MESSAGE FROM CHILD

STEP 15 : WRITE THE MESSAGE TO CHILD

STEP 16 : STOP


PROGRAM :

#include<stdio.h>
#include<string.h>
void main()
{
     int pid,p[2];
     char buff[20];
     pipe(p);
     pid=fork();
     if(pid==0)
     {
         printf("\n child process \n");
         printf("\n enter the message to parent : \n");
         gets(buff);
         write(p[1],buff,sizeof(buff));
         sleep(8);
         printf("\n message from parent : \n");
         read(p[0],buff,sizeof(buff));
         puts(buff);
         close(p[0]);
    }
    else
    {
         printf("\n parent process ");
         read(p[0],buff,sizeof(buff));
         printf("\n message from child : ");
         puts(buff);
         sleep(4);
         printf("\n enter the message to child : ");
         gets(buff);
         write(p[1],buff,sizeof(buff));
         sleep(2);
         close(p[0]);
    }
}


OUTPUT :

parent process
child process
enter the message to parent :
hai
message from child :
hai
enter the message to child :
hai
message from parent : hai



C PROGRAM TO IMPLEMENT FORK SYSTEM CALL (WITH ALGORITHM)

C PROGRAM TO IMPLEMENT FORK SYSTEM CALL (WITH ALGORITHM)

AIM : TO IMPLEMENT FORK SYSTEM CALL

ALGORITHM :

STEP 1 : START

STEP 2 : CREATE A CHILD PROCESS USING FORK

STEP 3 : IF THE PROCESSID EQUALS 0 GOTO STEP 4 ELSE GOTO STEP5

STEP 4 : IT IS A CHILD PROCESS AND GET ITS ID AND PARENT PROCESSID

STEP 5 : IF PROCESSID>0 IT IS A PARENT PROCESS AND GET ITS ID

STEP 6 : HANDLE THE SYSTEM INTERRUPT(ERROR)

STEP 7 : STOP


PROGRAM :

#include<stdio.h>
void main()
{
   int pid;
   pid=fork();
   if(pid==0)
   {
        printf("\n child process ");
        printf("\n pid of child process : %d \n pid of parent process : %d\n",getpid(),getppid());
   }
   else if(pid>0)
       printf("\n parent process : %d",getpid());
   else
       printf("\n error");
}


OUTPUT :

parent process : 3248
child process
pid of child process : 3249
pid of parent process : 1









Saturday, 26 August 2017

MASM PROGRAM FOR STRING REVERSAL (WITH ALGORITHM)

MASM PROGRAM FOR STRING REVERSAL (WITH ALGORITHM)

AIM : TO REVERSE A STRING

ALGORITHM :

STEP 1 : WRITE THE DATA SEGMENT

STEP 2 : MOVE DATA TO AX

STEP 3 : MOVE AX TO DS

STEP 4 : LOAD EFFECTIVE ADDRESS OF MSG1 TO DX

STEP 5 : PRINT MESSAGE

STEP 6 : MOVE 0DH TO DL

STEP 7 : LOAD EFFECTIVE ADDRESS OF ST1 TO S1

STEP 8 : MOVE 00H TO CL

STEP 9 : INPUT A CHARACTER

STEP 10 : COMPARE IF IT IS A LINE FEED

STEP 11 : JUMP IF ZERO TO STEP 18

STEP 12 : INCREMENT CL

STEP 13 : INCREMENT SI

STEP 14 : MOVE AL TO THE CONTENT OF SI

STEP 15 : INCREMENT SI

STEP 16 : INCREMENT CL

STEP 17 : JUMP TO STEP 9

STEP 18 : MOVE 0AH TO DL

STEP 19 : MOVE 0DH TO DL

STEP 20 : LOAD EFFECTIVE ADDRESS OF MSG2 TO DX

STEP 21 : PRINT THE MESSAGE

STEP 22 : MOVE THE CONTENT OF SI TO DL

STEP 23 : PRINT THE CHARACTER WHERE VALUE IN DL

STEP 24 : DECREMENT SI

STEP 25 : DECREMENT CL

STEP 26 : COMPARE 00H TO CL

STEP 27 : JUMP IF NOT ZERO TO STEP 21

STEP 28 : TERMINATE THE PROGRAM

STEP 29 : STOP


PROGRAM :

DATA SEGMENT
            ST1 DB 100 DUP(?)
            MSG1 DB "ENTER THE STRING $"
            MSG2 DB "REVERSED STRING $"
DATA ENDS

CODE SEGMENT
            ASSUME CS:CODE
            START:
                         MOV AX,DATA
                         MOV DS,AX
                         LEA DX,MSG1
                         MOV AH,09H
                         INT 21H
                         LEA SI,ST1
                         MOV CL,00H
           L1:
                         MOV AH,01H
                         INT 21H
                         CMP AL,0DH
                         JZ L2
                         INC CL
                         INC SI
                         MOV [SI],AL
                         INC SI
                         INC CL
                         JMP L1
          L2:
                         MOV DL,0AH
                         INT 21H
                         MOV DL,0DH
                         INT 21H
                         LEA DX,MSG2
                         MOV AH,09H
                         INT 21H
         L3:
                         MOV DL,[SI]
                         MOV AH,02H
                         INT 21H
                         DEC SI
                         DEC CL
                         CMP CL,00H
                         JNZ L3
                         MOV AH,4CH
                         INT 21H
        CODE ENDS
        END START


OUTPUT :

ENTER THE STRING : CAT
REVERSED STRING : TAC






























MASM PROGRAM TO CONVERT THE CASE OF A CHARACTER (WITH ALGORITHM)

MASM PROGRAM TO CONVERT THE CASE OF A CHARACTER


AIM : TO CONVERT THE CASE OF A CHARACTER

ALGORITHM :

STEP 1 : INPUT THE CHARACTER

STEP 2 : MOVE THE CHARACTER IN AL TO CL

STEP 3 : MOVE CL TO DL

STEP 4 : COMPARE DL WITH 01H

STEP 5 : JUMP IF CARRY TO 8

STEP 6 : SUBTRACT DL WITH 20H

STEP 7 : JUMP IF NO CARRY TO 9

STEP 8 : ADD DL WITH 20H

STEP 9 : PRINT THE CHARACTER

STEP 10 : TERMINATE THE PROGRAM

STEP 11 : STOP


PROGRAM :

CODE SEGMENT
ASSUME CS: CODE
                START:
                             MOV AH,01H
                             INT 21H
                             MOV CL,AL
                             MOV DL,CL
                             CMP DL,61H
                             JC L1
                             SUB DL,20H
                             JNC L2
                             L1:
                                     ADD DL,20H
                             L2:
                                    MOV AH,02H
                                    INT 21H
                                    MOV AH,4CH
                                    INT 21H
                            CODE ENDS
              END START


OUTPUT :

aA







MASM PROGRAM TO DISPLAY "HELLO" (WITH ALGORITHM)


MASM PROGRAM TO DISPLAY "HELLO" (WITH ALGORITHM) 


AIM : TO DISPLAY HELLO

ALGORITHM :

STEP 1 : WRITE DATA SEGMENT

STEP 2 : MOVE DATA TO AX

STEP 3 : MOVE AX TO DS

STEP 4 : DISPLAY THE MESSAGE IN DS

STEP 5 : PROGRAM TERMINATES

STEP 6 : STOP


PROGRAM :

DATA SEGMENT
          MSG DB "HELLO$"
DATA ENDS
CODE SEGMENT
          ASSUME CS:CODE,DS:DATA
START:
          MOV AX,DATA
          MOV DS,AX
          LEA DX,MSG
          MOV AH,09H
          INT 21H
          MOV AH,4CH
          INT 21H
          CODE ENDS
END START


OUTPUT :

HELLO






Monday, 7 August 2017

Subject and Predicate & Kinds of Sentences

Subject and Predicate
                                                                       Courtesy: Cordova Learning Series
A sentence has two parts:

(a) Subject

(b) Predicate

eg: Rahul likes playing football.

This is a sentence that makes complete sense.

'Rahul' is the subject because the sentence is about Rahul.

'likes playing football' is the predicate because it tells us about the subject 'Rahul'.

  • The part of the sentence that tells us what or whom the sentence is about is called the subject.


  • The part of the sentence that tells us something about the subject is called the predicate.


Eg: The players are not tired.

Subject : The players       Predicate: are not tired

  • The predicate always includes the verb.


More examples to understand subject and predicate


1) The boy was chasing a cat

Subject: The boy predicate: was chasing a cat

2) Suraj is sleeping.

Subject : Suraj     Predicate: is sleeping

  • The subject may have only one or more than a word.


Subject in commands

(i)Come here  (ii) Don't talk

In these sentences, the subject is not mentioned.

The subject is actually 'you' and the sentences actually read like the following:

(i) You come here  (ii)You don't talk

In all commands, the subject is 'you' which is not mentioned in the sentence but is understood.

Subject in questions

The subject usually comes before the predicate. But, in questions, subjects come after predicates.

Eg: (i) Where is mother ?

Subject : mother Predicate: Where is

(ii) Who are you ?

Subject : you  Predicate: Who are

Let's revise

  • A sentence has two parts : subject and predicate
  • In commands, the subject is 'you' which is not mentioned but implied.
  • In questions and exclamatory sentences, predicates usually come before the subjects.



Kinds of Sentences

There are four kinds of sentences.

1) Statements

2) Interrogative sentences

3) Imperative sentences

4) Exclamatory sentences

  • A statement says or states something. It begins with a capital letter and ends with a full stop.



Eg: 1) I like water melons.


2) I love to paint pictures.

  • An interrogative sentence or question asks something. It begins with a capital letter and ends with a question mark.


Eg: 1) What is your name?


2) Did you meet Mr. Verma?

  • An imperative sentence requests, commands or gives directions. It usually begins with a verb. It begins with a capital letter and ends with a full stop.



Eg: 1) Switch off the fan.


2) Please, come to me.

  • An exclamatory sentence expresses a strong feeling or emotion. It ends with an exclamation mark.



Eg: 1) What a beautiful picture it is!


2) How fast is she running!

Tuesday, 1 August 2017

Best phones under ₹ 10,000 in India for August 2017

Xiaomi Redmi 4


  • 13MP primary camera with 5-elements lens, f/2.2 aperture, PDAF, high dynamic range (HDR), panorama, 1080p full HD video recording and 5MP front facing camera
  • 12.7 centimeters (5-inch) display with 1280 x 720 pixels resolution and 293 PPI pixel density
  • Android v6.0.1 Marshmallow operating system with up to 1.4GHz Qualcomm Snapdragon 435 octa core processor with Adreno 505 GPU, 3GB RAM, 32GB internal memory expandable up to 128GB and dual SIM (micro+nano) dual-standby (4G+4G)
  • 4100mAH lithium-ion battery providing talk-time of 36 hours and standby time of 432 hours
  • 1-year manufacturer warranty for device and 6 months manufacturer warranty for in-box accessories including batteries from the date of purchase
Yu Yureka Black 

With a superior metal finish, the Yureka Black is designed to impress. Boasting 4 GB of RAM and a 1.4 GHz Qualcomm Snapdragon 430 octa-core processor, this smartphone packs quite a punch, making every task smooth and fast. Its 13 MP Sony IMX 258 rear camera helps you capture life’s beautiful moments in picture-perfect photos. The 8 MP selfie camera of the Yureka Black, with its selfie flash, lets you take stunning selfies even in poorly lit conditions. Watch movies, play games or shop online - the 12.7 cm (5) FHD IPS display is made to offer an impressive viewing experience. The 3000 mAh battery of this smartphone keeps the fun going on for up to two days on a single full charge. To top it off, the fingerprint sensor of this phone keeps all your private data truly private from prying eyes.