Monday 2 December 2019

Important Output Finding Questions Based On Randomize And Pointer Concept Class-12




Important Output Finding Questions Based On Randomize And Pointer Concept
Class-12
1. Find the output of the following program :
#include<iostream.h>
#include<ctype.h>
void Secret(char Msg[ ], int N);
void main( )
{ char SMS[ ]=”rEPorTmE”;
Secret(SMS,2);
cout<<SMS<<endl;
}
void Secret(char Msg[ ], int N)
{ for(int C=0;Msg[C]!=’\0’;C++)
if(C%2= =0)
Msg[C]=Msg[C]+N;
else if(isupper(Msg[C]))
Msg[C]=tolower(Msg[C]);
else
Msg[C]=Msg[C]-N;
}
Ans: teRmttoe
2. Study the following program and select the possible output from it:
#include<iostream.h>
#include<stdlib.h>
const int MAX=3;
void main( )
{ randomize( );
int Number;
Number=50+random(MAX);
for(int P=Number;P>=50;P--)
cout<<P<<”#”;
cout<<endl;
}
(i) 53#52#51#50# (ii) 50#51#52#
(iii) 50#51# (iv) 51#50#
Ans: (iv) 51#50#
Solution: MAX value is 3 That’s why random(MAX) can produce 0 or 1 or 2. (random(N) will produce no. between 1 to n-1) The Number value may be 50 or 51 or 52. The P value starts from Number, upto 50, each time decreases by 1. So Possible outputs are as follows:
52#51#50#
51#50#
50#
As the output 51#50# is available in given answers, so 51#50# is the answer.)
3.  Find the output of the following program;
#include<iostream.h>
#include<ctype.h>
void main( )
{ char Text[ ] = “Mind@work!”;
for(int I=0; Text[I]!=’\0’;I++)
{ if(!isalpha(Text[I]))
Text[I]=’*’;
else if(isupper(Text[I]))
Text[I]=Text[I]+1;
else
Text[I] = Text[I+1];
}
cout<<Text;
}
Ans): Output: Nnd@*Xrk!*
4. In the following program, find the correct possible output(s) from the options:
#include<stdlib.h>
#include<iostream.h>
void main( )
{ randomize( );
char City[][10]= {“DEL”,”CHN”,”KOL”,”BOM”,”BNG”};
int Fly;
for(int I=0; I<3;I++)
{ Fly=random(2) + 1;
cout<<City[Fly]<<”:”;}
}
Outputs:
(i) DEL : CHN : KOL:
(ii) CHN: KOL : CHN:
(iii) KOL : BOM : BNG:
(iv) KOL : CHN : KOL:
Ans): Since random(2) gives either 0 or 1, Fly value will be either 1 or 2.(random(n) gives you any number between 0 to n-1)City[1] is “CHN”. City[2] is “KOL”.Since I value from 0 to 2 (ie<3), 3 iterationswill takes place.So the possible output consists 3 strings separated by :, each of them may be either “CHN” or “KOL”.
So the possible output will be
(ii) CHN : KOL : CHN:
(iv) KOL :CHN : KOL:

5. Find the output of the following program:
#include<iostream.h>
#include<ctype.h>
void main( )
{ char Mystring[ ] = "what@OUTPUT!";
for(int I=0; Mystring[I]!='\0';I++)
{ if(!isalpha(Mystring[I]))
Mystring[I]='*';
else if(isupper(Mystring[I]))
Mystring[I]=Mystring[I]+1;
else
Mystring[I] =Mystring[I+1];
}
cout<<Mystring;}
Ans: Output:
hat@*PVUQVU*

6. In the following program, find the correct possible output(s) from the options:
#include<stdlib.h>
#include<iostream.h>
void main( )
{ randomize( );
char Area[ ][10]={“NORTH”,”SOUTH”,”EAST”,”WEST”};
int ToGo;
for(int I=0; I<3;I++)
{ ToGo=random(2) + 1;
cout<<Area[ToGo]<<”:”;
}}
2
Ans: Outputs:
(i) SOUTH : EAST : SOUTH :
(ii) NORTH : SOUTH : EAST :
(iii) SOUTH : EAST : WEST :
(iv) SOUTH : EAST : EAST :
Ans) Since random(2) gives either 0 or 1, ToGo value will be either 1 or 2.(random(n) gives you any number between 0 to n-1) Area[1] is “SOUTH”. Area[2] is “EAST”.Since I value from 0 to 2 (ie<3), 3 iterations will takes place. So the possible output consists 3 strings separated by :, each of them may be either “SOUTH” or “EAST”.
So the possible output will be
(i) SOUTH : EAST : SOUTH :
(iv) SOUTH : EAST : EAST :



7. Find the output of the following program.
#include<iostream.h>
#include<string.h>
#include<ctype.h>
void Convert(char Str[ ],int Len)
{ for(int Count=0;Count<Len;Count++)
{ if(isupper(Str[Count]))
Str[Count]=tolower(Str[Count]);
else if (islower(Str[Count]))
Str[Count]=toupper(Str[Count]);
else if(isdigit(Str[Count]))
Str[Count]=Str[Count]+1;
else Str[Count]=’*’;
}
}
void main( )
{ char Text[ ]=”CBSE Exam 2005”;
int Size = strlen(Text);
Convert(Text,Size);
cout<<Text<<endl;
for(int C=0,R=Size – 1;C<=Size/2;C++,R--)
{ char Temp=Text[C];
Text[C]=Text[R];
Text[R]=Temp;
}
cout<<Text<<endl;
}
Ans:Output: cbse*eXAM*3116
8. Find and write the output of the following C++ program code:
Note: Assume all required header files are already being included in
the program.
void main( )
{
int Ar[ ] = { 6 , 3 , 8 , 10 , 4 , 6 , 7} ;
int *Ptr = Ar , I ;
cout<<++*Ptr++ << '@' ;
I = Ar[3] - Ar[2] ;
cout<<++*(Ptr+I)<<'@'<<"\n" ;
cout<<++I + *Ptr++ << '@' ;
cout<<*Ptr++ <<'@'<< '\n' ;
for( ; I >=0 ; I -=2)
cout<<Ar[I] << '@' ;
}
Ans 7@11@
6@8@
11@3@
9. Find and write the output of the following C++ program code:
typedef char STRING[80];
void MIXNOW(STRING S)
{
 int Size=strlen(S);
 for(int I=0;I<Size;I+=2)
 {
 char WS=S[I];
S[I]=S[I+1];
 S[I+1]=WS;
}
for (I=1;I<Size;I+=2)
 if (S[I]>=’M’ && S[I]<=’U’)
 S[I]=’@’;
}
void main()
{
 STRING Word=”CBSEEXAM2019”;
MIXNOW(Word);
cout<<Word<<endl;
}
Ans. BCE@XEMA0291



LIST OF PROGRAMS ON PYTHON STRINGS CLASS-11




Programs on Python Strings
Class-11
Q1. Write Python script to input a string and a character and count the number of occurrences of the character in the string.
Q2. Write Python script to input a string and display it in reverse order.
Q3. Write Python script to input a string and check whether it is a palindrome or not.
Q4. Write Python script to input a string and count the number of words in it.
Q5. Write Python script to input a string and count the number of words beginning with ‘A; or ‘a’.
Q6. Write Python script to input a string and replace the first letter of every word to uppercase and then display it.
Q7. Write Python script to input a string and replace all occurrences of the word ‘the’ with ‘that’.
Q8. Write Python script to input a string and count and display the number of capital alphabets, small alphabets and numbers.
Q9. Write a program to read a line of strings and count total no. of uppercase and lowercase characters.
Q10. Write  program to input the line of strings and replace each uppercase alphabet with '*' symbol and each lowercase character with '@'


Sunday 1 December 2019

LIST OF PYTHON PROGRAMS ON LIST CLASS-11




Programs On Python Lists
Class-11

1.   Write a Python program to get the largest number from a list
2.   Write a Python program to get the smallest number from a list
3.   Write a program to input 10 numbers from the user and then display this list of numbers in reverse order.
4.   Write a program to input 10 numbers from the user and find their sum and average.
5.   Write a program to create a list of 10 random integers in the range 10 to 99, and display this list. Then display all the odd elements of the list.
6.   Write a Python program to remove duplicates from a list.
7.   Write a Python program to check a list is empty or not.
8.   Write a Python program to print a specified list after removing the 0th, 4th and 5th elements.
9.   Write a Python program to find all the values in a list are greater than a specified number.
10. Write a program to create a list names1 to store the names of n1 students of a class. Also create a list names2 to store the names of n2 students of another class. n1, n2, and the names are to be input from the user. Then combine these two lists into a new list and display this new list in the ascending order of names.
11. Write a menu driven program which creates an empty list and gives the following options to the user to perform various operations on a list:
(i)   Append an element to the list
(ii)  Input an element from the user and remove it from the list
(iii) Remove all elements from the list
(iv) Count the number of occurrences of an element in the list
(v)  Sort the list
(vi) Reverse the list 
(vii)         Display the list
The program should terminate when the user chooses the option to exit.

Friday 29 November 2019

HTML FORMS-CLASS-X




Class X
COMPUTER APPLICATIONS
HTML FORMS
HTML Forms are required, when you want to collect some data from the site visitor. For example, during user registration you would like to collect information such as name, email address, credit card, etc.
A form will take input from the site visitor and then will post it to a back-end application such as CGI, ASP Script or PHP script etc. The back-end application will perform required processing on the passed data based on defined business logic inside the application.
There are various form elements available like text fields, textarea fields, drop-down menus, radio buttons, checkboxes, etc.
The HTML <form> tag is used to create an HTML form and it has following syntax −
<form action = "Script URL" method = "GET|POST">
   form elements like input, textarea etc.
</form>

Form Attributes
Apart from common attributes, following is a list of the most frequently used form attributes −
Sr.No
Attribute & Description
1
action
Backend script ready to process your passed data.
2
method
Method to be used to upload data. The most frequently used are GET and POST methods.
3
target
Specify the target window or frame where the result of the script will be displayed. It takes values like _blank, _self, _parent etc.

HTML Form Controls

There are different types of form controls that you can use to collect data using HTML form −
  • Text Input Controls
  • Checkboxes Controls
  • Radio Box Controls
  • Select Box Controls
  • Hidden Controls
  • Clickable Buttons
  • Submit and Reset Button

Text Input Controls

There are three types of text input used on forms −
·        Single-line text input controls − This control is used for items that require only one line of user input, such as search boxes or names. They are created using HTML <input> tag.
·        Password input controls − This is also a single-line text input but it masks the character as soon as a user enters it. They are also created using HTMl <input> tag.
·        Multi-line text input controls − This is used when the user is required to give details that may be longer than a single sentence. Multi-line input controls are created using HTML <textarea> tag.

Single-line text input controls

This control is used for items that require only one line of user input, such as search boxes or names. They are created using HTML <input> tag.
<!DOCTYPE html>
<html>

   <head>
      <title>Text Input Control</title>
   </head>
      
   <body>
      <form >
         First name: <input type = "text" name = "first_name" />
         <br>
         Last name: <input type = "text" name = "last_name" />
      </form>
   </body>
      
</html>
This will produce the following result –
Firstname: 
Last name: 

Attributes

Following is the list of attributes for <input> tag for creating text field.
Sr.No
Attribute & Description
1
type
Indicates the type of input control and for text input control it will be set to text.
2
name
Used to give a name to the control which is sent to the server to be recognized and get the value.
3
value
This can be used to provide an initial value inside the control.
4
size
Allows to specify the width of the text-input control in terms of characters.
5
maxlength
Allows to specify the maximum number of characters a user can enter into the text box.

Password input controls

This is also a single-line text input but it masks the character as soon as a user enters it. They are also created using HTML <input>tag but type attribute is set to password.

Example

Here is a basic example of a single-line password input used to take user password −
<!DOCTYPE html>
<html>
 
   <head>
      <title>Password Input Control</title>
   </head>
       
   <body>
      <form >
         User ID : <input type = "text" name = "user_id" />
         <br>
         Password: <input type = "password" name = "password" />
      </form>
   </body>
       
</html>
This will produce the following result –
UserID: 
Password: 

Attributes

Following is the list of attributes for <input> tag for creating password field.
Sr.No
Attribute & Description
1
type
Indicates the type of input control and for password input control it will be set to password.
2
name
Used to give a name to the control which is sent to the server to be recognized and get the value.
3
value
This can be used to provide an initial value inside the control.
4
size
Allows to specify the width of the text-input control in terms of characters.
5
maxlength
Allows to specify the maximum number of characters a user can enter into the text box.

Multiple-Line Text Input Controls

This is used when the user is required to give details that may be longer than a single sentence. Multi-line input controls are created using HTML <textarea> tag.

Example

Here is a basic example of a multi-line text input used to take item description −
<!DOCTYPE html>
<html>
 
   <head>
      <title>Multiple-Line Input Control</title>
   </head>
       
   <body>
      <form>
         Description : <br />
         <textarea rows = "5" cols = "50" name = "description">
            Enter description here...
         </textarea>
      </form>
   </body>
       
</html>
This will produce the following result –
Description:

Attributes

Following is the list of attributes for <textarea> tag.
Sr.No
Attribute & Description
1
name
Used to give a name to the control which is sent to the server to be recognized and get the value.
2
rows
Indicates the number of rows of text area box.
3
cols
Indicates the number of columns of text area box

Checkbox Control

Checkboxes are used when more than one option is required to be selected. They are also created using HTML <input> tag but type attribute is set to checkbox..

Example

Here is an example HTML code for a form with two checkboxes −
<!DOCTYPE html>
<html>
 
   <head>
      <title>Checkbox Control</title>
   </head>
       
   <body>
      <form>
         <input type = "checkbox" name = "maths" value = "on"> Maths
         <input type = "checkbox" name = "physics" value = "on"> Physics
      </form>
   </body>
       
</html>
This will produce the following result −

Attributes

Following is the list of attributes for <checkbox> tag.
Sr.No
Attribute & Description
1
type
Indicates the type of input control and for checkbox input control it will be set to checkbox..
2
name
Used to give a name to the control which is sent to the server to be recognized and get the value.
3
value
The value that will be used if the checkbox is selected.
4
checked
Set to checked if you want to select it by default.

Radio Button Control

Radio buttons are used when out of many options, just one option is required to be selected. They are also created using HTML <input> tag but type attribute is set to radio.

Example

Here is example HTML code for a form with two radio buttons −
<!DOCTYPE html>
<html>
 
   <head>
      <title>Radio Box Control</title>
   </head>
 
   <body>
      <form>
         <input type = "radio" name = "subject" value = "maths"> Maths
         <input type = "radio" name = "subject" value = "physics"> Physics
      </form>
   </body>
 
</html>
This will produce the following result −

Attributes

Following is the list of attributes for radio button.
Sr.No
Attribute & Description
1
type
Indicates the type of input control and for checkbox input control it will be set to radio.
2
name
Used to give a name to the control which is sent to the server to be recognized and get the value.
3
value
The value that will be used if the radio box is selected.
4
checked
Set to checked if you want to select it by default.

Select Box Control

A select box, also called drop down box which provides option to list down various options in the form of drop down list, from where a user can select one or more options.

Example

Here is example HTML code for a form with one drop down box
<!DOCTYPE html>
<html>
 
   <head>
      <title>Select Box Control</title>
   </head>
       
   <body>
      <form>
         <select name = "dropdown">
            <option value = "Maths" selected>Maths</option>
            <option value = "Physics">Physics</option>
         </select>
      </form>
   </body>
       
</html>
This will produce the following result −

Attributes

Following is the list of important attributes of <select> tag −
Sr.No
Attribute & Description
1
name
Used to give a name to the control which is sent to the server to be recognized and get the value.
2
size
This can be used to present a scrolling list box.
3
multiple
If set to "multiple" then allows a user to select multiple items from the menu.
Following is the list of important attributes of <option> tag −
Sr.No
Attribute & Description
1
value
The value that will be used if an option in the select box box is selected.
2
selected
Specifies that this option should be the initially selected value when the page loads.
3
label
An alternative way of labeling options

File Upload Box

If you want to allow a user to upload a file to your web site, you will need to use a file upload box, also known as a file select box. This is also created using the <input> element but type attribute is set to file.

Example

Here is example HTML code for a form with one file upload box −
<!DOCTYPE html>
<html>
 
   <head>
      <title>File Upload Box</title>
   </head>
 
   <body>
      <form>
         <input type = "file" name = "fileupload" accept = "image/*" />
      </form>
   </body>
       
</html>
This will produce the following result −

Attributes

Following is the list of important attributes of file upload box −
Sr.No
Attribute & Description
1
name
Used to give a name to the control which is sent to the server to be recognized and get the value.
2
accept
Specifies the types of files that the server accepts.

Button Controls

There are various ways in HTML to create clickable buttons. You can also create a clickable button using <input>tag by setting its type attribute to button. The type attribute can take the following values −
Sr.No
Type & Description
1
submit
This creates a button that automatically submits a form.
2
reset
This creates a button that automatically resets form controls to their initial values.
3
button
This creates a button that is used to trigger a client-side script when the user clicks that button.
4
image
This creates a clickable button but we can use an image as background of the button.

Example

Here is example HTML code for a form with three types of buttons −
<!DOCTYPE html>
<html>
 
   <head>
      <title>File Upload Box</title>
   </head>
       
   <body>
      <form>
         <input type = "submit" name = "submit" value = "Submit" />
         <input type = "reset" name = "reset"  value = "Reset" />
      </form>
   </body>
       
</html>
This will produce the following result –