Saturday, January 26, 2019

C++ Programs Questions and answers Solved it

Solve C++ programs Questions and answers:

 



1)Which C++ header file(s) will be essentially required to be included to run /execute the following C++ code:

 void main()
{
     char Msg[ ]="Sunset Gardens";
     for (int I=5;I<strlen(Msg);I++)
     puts(Msg);
 }


Ans : stdio.h, string.h

 

Feedback form






Click here for feedback form :


Feedback form
 




College form





Click here for Admission form :

Form of College



Job Application Form jobs for you in a click







Enter Details FOR JOB


Click Here For :


Job Application Form 


 



Sunday, January 20, 2019

PHP program of Slip 19 practical of User Information in bill


<?
// This is Slip19_a.php
// It takes User Information And Send it to slip19_b.php
?>
<html>
<body bgcolor=#AAAAAA>
<center> <font color="red" font size=6>U</font>ser Information</center>
<br><br><br>
<form action="slip19_b.php" method="GET">
<p>
<table border=0>
<tr><td>Name:<td> <input type="text" name="u_name">

<tr><td>Address:<td> <input type="text" name="u_address">

<tr><td>Phone No:<td> <input type="text" name="u_no">
<tr><td><td><input type="submit" value="SUBMIT">
</form>
</table>
</form>
</body>
</html>





















<?
// This is Slip19_b.php
// It Takes The Product Information....
//and Passes to Slip19_c.php

?>
<html>
<body bgcolor=#AAAAAAA>
<center><font color="red" font size=6>P</font>roduct Information</center>
<br><br><br>
<form action="slip19_c.php" method="POST">
<p>
<table border=0>
<tr><td>Prod.Name:<td> <input type="text" name="p_name">

<tr><td>Quantity:<td> <input type="text" name="p_qty">

<tr><td>Rate:<td> <input type="text" name="prize">

<tr><td><?
$var1=$_GET['u_name'];
$var2=$_GET['u_address'];
$var3=$_GET['u_no'];
printf("<br><br>Customer Information is:");
printf("<br><br><input type='text' name='user' value='$var1'><br>");
printf("<input type='text' name='add' value='$var2'><br>");
printf("<input type='text' name='phone' value='$var3'><br>");
?>

<tr><td><td><input type="submit" value="Display">

</table>
</form>
</body>
</html>
















<?
// This is Slip19_c.php
//It Genrates the Tabular format bill of the Customer
?>

<html>
<body bgcolor=#AAAAAAA>
<center><font color="red" font size=6>B</font>ill Information</center>
<br><br><br>
<center>
<table border=1 cellspacing=2 cellpadding=2>
<?
$usr_name=$_POST['user'];
$usr_address=$_POST['add'];
$usr_phone=$_POST['phone'];
$prod_name=$_POST['p_name'];
$prod_quantity=$_POST['p_qty'];
$prod_price=$_POST['prize'];
$bill=$prod_quantity*$prod_price;
printf("<br><br><br>");
printf("<th bgcolor=#ABCDEF>Customer Bill<td bgcolor=#ABCDEF>");
printf("<tr><td>Name<td>$usr_name");
printf("<tr><td>Address<td>$usr_address");
printf("<tr><td>Phone No<td>$usr_phone");
printf("<tr><td>Product Name<td>$prod_name");
printf("<tr><td>Product Quantity<td>$prod_quantity");
printf("<tr><td>Product Price<td>$prod_price / Unit");
printf("<tr><td>Total<td>$bill Rs.");
?>
</table>
</form>
</body>
</html>




Friday, January 18, 2019

Conversion of string program java



Conversion of string java program UPPER lower BOLD ITALIC 

import javax.swing .* ;
import java.awt . * ;
import java.awt.event .* ;

class Convt extends JFrame implements ActionListener
{
       JLabel l1;
       JButton b1,b2,b3,b4;
       JTextField t1,t2,t3,t4,t5;
     Convt( )
  {
         setVisible(true);
         setSize(400,400);
         setTitle("Conversion of Text");

         l1=new JLabel("ENTER   THE   STRING :=");
         b1=new JButton("LOWER");
         b2=new JButton("UPPER");
         b3=new JButton("BOLD");
         b4=new JButton("ITALIC");
         b1.addActionListener(this);
         b2.addActionListener(this);
         b3.addActionListener(this);
         b4.addActionListener(this);

         t1=new JTextField(10);
         t2=new JTextField(10);
         t3=new JTextField(10);
         t4=new JTextField(10);
         t5=new JTextField(10);

     JPanel p1=new JPanel( );
      p1.setLayout(new GridLayout(5,2));
      p1.add(l1);
      p1.add(t1);
      p1.add(b1);
      p1.add(t2);
      p1.add(b2);
      p1.add(t3);
      p1.add(b3);
      p1.add(t4);
      p1.add(b4);
      p1.add(t5);

     Container cn=getContentPane( );
     cn.setLayout(new FlowLayout( ));
     cn.add(p1);
   }
    public void actionPerformed(ActionEvent ae)
    {
             String s=t1.getText( );
            if(ae.getSource( )==b1)
        {
             t2.setText(s.toLowerCase( ));
           }
       else
           if(ae.getSource( )==b2)
           {
                 t3.setText(s.toUpperCase( ));
                }
       else
          if(ae.getSource( )==b3)
          {
                 t4.setFont(new Font("Dialog",Font.BOLD,20));
                 t4.setText(s);
               }

        else
             if(ae.getSource( )==b4)
            {
                   t5.setFont(new Font("Dialog",Font.ITALIC,20));
                   t5.setText(s);
                 }
        }
      public static void main(String args[])
      {
             Convt cv=new Convt( );
             cv.validate( );
           }
    }


Write a command line program for line editor of practcal slip



/*
    slip-7
1. Write a command line program for line editor. The file to be edited is taken
 as command line argument, an empty  file is opened for editing if no argument
 is supplied.  It should display '$' prompt to accept the line editing commands.
Implement the following commands.
i)    a                 - to append
ii)    i  n                 - to insert after nth line
iii)    c    n1   n2              - to copy line n1 at  n2 position
iv)    c    n1, n2    n3   - to copy range of line at n3        [30 marks]

*/




#include<stdio.h>
#include<conio.h>
#include<string.h>
#define newnode (struct node *)malloc(sizeof(struct node))

struct node
{
    char line[80];
    struct node *next,*prev;
}*head=NULL;

int  length();
void print();
void append(char *line);
void load(char *);
void add();
void insert(char *,int);
void copy(int,int,int,int);





void load(char *fname)
{
    FILE *fp;
    char line[80];
    fp=fopen(fname,"r");
    if(fp==NULL)
    {
        printf("\nFile cannot boe opened..");
        getch();
        exit(0);
    }
    while(!feof(fp))
    {
        fgets(line,80,fp);
        append(line);
    }

}

void append(char *line)
{
    struct node *f,*s;
    f=newnode;
    strcpy(f->line,line);
    f->next=NULL;
    f->prev=NULL;
    if(head==NULL)
        head=f;
    else
    {
        for(s=head;s->next!=NULL;s=s->next);
        s->next=f;
        f->prev=s;
        s=s->next;
    }
}

void print()
{
    struct node *f;
    int i=1;
    for(f=head;f!=NULL;f=f->next)
        printf("%d %s",i++,f->line);
}

int length()
{
    int cnt=0;
    struct node *s;
    for(s=head;s!=NULL;s=s->next)
        cnt++;
    return cnt;
}

void insert(char *line,int from)
{
    struct node *f,*s;
    int len,i;
    if(from-1>length())
    {
        printf("\nError..");
        return;
    }

    f=newnode;
    f->next=NULL;
    f->prev=NULL;
    strcpy(f->line,line);

    if(from==1)
    {
        f->next=head;
        head->prev=f;
        head=head->prev;
        return;
    }
    else
    {
        s=head;
        for(i=1;i<(from-1);i++)
            s=s->next;
        f->next=s->next;
        s->next->prev=f;
        s->next=f;
        f->prev=s;
    }
}






main(int argc,char *argv[])
{
    int ch;
    int i,notok,from,to,range;
    char cmd[80],tok[4],line[80];
    clrscr();
    for(i=0;i<4;i++)
        tok[i]=(char )malloc(20);

    if(argc==2)
    {
        head=NULL;
        load(argv[1]);
    }
    while(1)
    {
        printf("\n?");
        flushall();
        gets(cmd);
        notok=sscanf(cmd,"%s%s%s%s",tok[0],tok[1],tok[2],tok[3]);
        switch(cmd[0])
        {
            case 'q':exit(1);

            case 'p':print();
                   break;
            case 'i':from=atoi(tok[1]);
                    printf("Input Line:");
                    flushall();
                    fgets(line,80,stdin);
                    insert(line,from);
                    break;

            case 'c':from=atoi(tok[1]);
                   to=atoi(tok[2]);
                   range=atoi(tok[3]);
                   copy(notok,from,to,range);
                   break;



        }
    }
}

void copy(int notok,int from,int to,int range)
{
    int len,i;
    struct node *s,*f,*temp;
    char line[80];
    len=length();
    if(from>len)
    {
        printf("\nError...");
        return;
    }

    if(notok==3)
    {
        s=head;
        for(i=0;i<(from-1);i++)
            s=s->next;
        insert(s->line,to);
    }

    if(notok==4)
    {
        if(to>len || range-1>len)
        {
            printf("\nError,,,");
            return;
        }
        s=head;
        for(i=0;i<(from-1);i++)
            s=s->next;
        for(i=from;i<=to && s!=NULL;i++)
        {
            insert(s->line,range++);
            s=s->next;
        }
    }
}

RoundRobin Program of practical slip



 /* Implementation of RoundRobin method for CPU scheduling using Circular LL */
 


#include<stdlib.h>
#define newnode (struct node *)malloc(sizeof(struct node))
struct node
{ int jobno,time;
  struct node *next;
}*JOBQ=NULL;


void erase()
{ struct node *S,*T;
  if(JOBQ!=NULL)
  { for(T=JOBQ;T->next!=JOBQ; T=T->next) ;  // go to last node
    T->next=NULL;

    while(JOBQ!=NULL)  { S=JOBQ;  JOBQ=JOBQ->next;  free(S);  }
  }
}

void CreateJOBQ()
{ struct node *S;   int i,n;
  printf("\nHow many jobs?"); scanf("%d",&n);


  if(JOBQ!=NULL) erase(JOBQ);
  JOBQ=newnode;
  printf("\nEnter JOB No. & execution time in sec. "); scanf("%d %d",&JOBQ->jobno,&JOBQ->time);

  S=JOBQ;
  for(i=2;i<=n;i++)
  { S->next=newnode;
    S=S->next;
    printf("\nEnter JOB No. & execution time in sec. "); scanf("%d %d",&S->jobno,&S->time);
  }
  S->next=JOBQ;
}

void DisplayJOBQ()
{struct node *T=JOBQ;
  if(JOBQ==NULL) printf("\nJOB Q is Empty!");
  else
  { printf("\nJOB  Rem. Time");
    do{ printf("\n J%d : %d ",T->jobno,T->time);
    T=T->next;
      }while(T!=JOBQ);
  }
}

void ExecuteJOBQ()
{ struct node *T=JOBQ,*S=NULL,*t1;  int flag,timeslot=1,time=0; char choice;
  printf("\nEnter Time Slot (in sec.) "); scanf("%d",&timeslot);
  printf("\nclock CPU   JOBQ ");
  while(JOBQ!=NULL)
  {
    do{ flag=0;
    if(T->time<=timeslot)  // job remaining time < time slot
    { printf("\n%3d  J%d(%d) |--",time,T->jobno,T->time); // cpu allocated
      for(t1=T->next; t1!=T; t1=t1->next) printf(" J%d(%d) ",t1->jobno,t1->time);  // print JOBQ
      time+=T->time; // increment clock
      T->time=0; // job finished, delete from JOBQ
      if(T==JOBQ) // 1st job
      { if(JOBQ->next==JOBQ) // only 1 job in Q
        { JOBQ=NULL; free(T); T=NULL; } // JOBQ became empty
        else  // more jobs in Q
        {  for(t1=JOBQ;t1->next!=JOBQ; t1=t1->next) ;  // go to last node
           JOBQ=JOBQ->next;   t1->next=JOBQ;
           free(T);     T=JOBQ; flag=1;
        }
      }
      else // job other than 1st position
      {   S->next=T->next; free(T);  T=S->next;
      }

    }
    else  // job is executed for given time slot
    {  printf("\n%3d  J%d(%d) |--",time,T->jobno,T->time); // cpu allocated
       for(t1=T->next; t1!=T; t1=t1->next) printf(" J%d(%d) ",t1->jobno,t1->time); // print JOBQ

       T->time-=timeslot;
       time+=timeslot;
       S=T; T=T->next;  // go to next job
    }

    printf(" --|  Add New Job(y/n)? ");  choice=getche();
    if(choice=='y' || choice=='Y')
    { struct node *S1;
      if(JOBQ==NULL) // JOBQ empty
      { JOBQ=newnode; JOBQ->next=JOBQ;    // 1st job in Q
        printf("\nEnter JOB No. & execution time in sec. "); scanf("%d %d",&JOBQ->jobno,&JOBQ->time);
        T=JOBQ; flag=1;
      }
      else
      { for(S1=S;S1->next!=S; S1=S1->next) ;  // go to last node of JOBQ
        S1->next=newnode; S1=S1->next; S1->next=S;    // add new job at the end of JOBQ
        printf("\nEnter JOB No. & execution time in sec. "); scanf("%d %d",&S1->jobno,&S1->time);
      }
    }
      }while(T!=JOBQ || flag);
  }
  printf("\n%3d  -idle-",time);
}

char menu()
{ char choice='a';
  clrscr();
  printf("----- Round Robin ------");
  printf("\nC: Create New JOB Queue");
  printf("\nD: Display JOB Queue");
  printf("\nE: Execute JOB Queue");
  printf("\nX: exit");
  printf("\nEnter your choice : ");
  choice=getche();
  return toupper(choice);
}

void main()
{
  while(1)
  { switch(menu())
    { case 'X' : erase(); exit(0);  // release memory allocated to JOBQ
      case 'C' : CreateJOBQ();  break;
      case 'D' : DisplayJOBQ(); break;
      case 'E' : ExecuteJOBQ(); break;
      default  : printf("\7 Invalid Choice!");
    }
    printf("\npress any key to continue...");
    getch();
  }

}

Featured posts

Happy Independence Day August 15th

 Here's a message for India's Independence Day (August 15th): "शुभ स्वतंत्रता दिवस! आजादी की 79वीं वर्षगांठ पर, आइए हम अपने देश...

Popular posts