Questions – Exam Papers – Computer Sir Ki Class  Question Typewise Collection-"Program Writing" Questions - Exam Papers (CPP) Q.1   Exam - CBSE12D-2016/02C/4

```Write the definition of a class METROPOLIS in C++ with following description:
Private Members
-Mcode    //Data member for Code (an integer)
-MName    //Data member for Name (a string)
-MPop     //Data member for Population (a long int)
-Area     //Data member for Area Coverage (a float)
-PopDens  //Data member for Population Density (a float)
-CalDen() //A member function to calculate
//Density as PopDens/Area
Public Members
-Enter()  //A function to allow user to enter values of
//Mcode,MName,MPop,Area and call CalDen()
//function
-ViewALL()//A function to display all the data members
//also display a message "Highly Populated Area"
//if the Density is more than 12000```

Q.2   Exam - CBSE12D-2017/04B/2

Write a definition for function COUNTDEPT( ) in C++ to read each object of a binary file TEACHERS.DAT, find and display the total number of teachers in the department MATHS. Assume that the file TEACHERS.DAT is created with the help of objects of class TEACHERS, which is defined below:

```class TEACHERS
{
int TID; char DEPT;
public:
void GET()
{
cin>>TID;gets(DEPT);
}
void SHOW()
{
cout<<TID<<":"<<DEPT<<endl;
}
char *RDEPT(){return DEPT;}
};```

Q.3   Exam - CBSE12D-2017/04A/3

Aditi has used a text editing software to type some text. After saving the article as WORDS.TXT , she realised that she has wrongly typed alphabet J in place of alphabet I everywhere in the article.
Write a function definition for JTOI() in C++ that would display the corrected version of entire content of the file WORDS.TXT with all the alphabets “J” to be displayed as an alphabet “I” on screen .
Note: Assuming that WORD.TXT does not contain any J alphabet otherwise.
Example: If Aditi has stored the following content in the file WORDS.TXT :

WELL, THJS JS A WORD BY JTSELF. YOU COULD STRETCH THJS TO BE A SENTENCE

The function JTOI() should display the following content:

WELL, THIS IS A WORD BY ITSELF. YOU COULD STRETCH THIS TO BE A SENTENCE

Q.4   Exam - CBSE12D-2017/03D/4

Write the definition of a member function ADDMEM() for a class QUEUE in C++, to add a MEMBER in a dynamically allocated Queue of Members considering the following code is already written as a part of the program.

```struct Member
{
int MNO;
char MNAME;
Member *Next;
};
class QUEUE
{
Member *Rear,*Front;
public:
QUEUE(){Rear=NULL;Front=NULL;}
void REMOVEMEM();
~QUEUE();
};```

Q.5   Exam - CBSE12D-2017/03B/2

Write definition for a function ADDMIDROW(int MAT[],int R,int C) in C++, which finds sum of the middle row elements of the matrix MAT (Assuming C represents number of Columns and R represents number of rows, which is an odd integer). For example, if the content of array MAT having R as 3 and C as 5 is as follows:

 1 2 3 4 5 2 1 3 4 5 3 4 1 2 5

The function should calculate the sum and display the following:
Sum of Middle Row: 15

Q.6   Exam - CBSE12D-2017/03A/3

Write the definition of a function Reverse(int Arr[], int N) in C++, which should reverse the entire content of the array Arr having N elements, without using any other array.
Example: if the array Arr contains

 13 10 15 20 5

Then the array should become

 5 20 15 10 13

NOTE:
-The function should only rearrange the content of the array.
-The function should not copy the reversed content in another array.
-The function should not display the content of the array.

Q.7   Exam - CBSE12D-2017/02C/4

```Write the definition of a class RING in C++ with following description:
Private Members
- RingNumber   // data member of integer type
- Radius       // data member of float type
- Area         // data member of float type
- CalcArea()   // Member function to calculate and assign
Public Members
- GetArea()    // A function to allow user to enter values of
// RingNumber and Radius. Also, this
// function should call CalcArea() to calculate
// Area
- ShowArea()   // A function to display RingNumber, Radius
// and Area```

Q.8   Exam - CBSE12A-2015/04C/1

Find the output of the following C++ code considering that the binary file MEMBER.DAT exists on the hard disk with records of 100 members:

```class MEMBER
{
int Mno; char Name;
public:
void In();void Out();
};
void main()
{
fstream MF;
MF.open("MEMBER.DAT”,ios::binary|ios::in);
MEMBER M;
int POSITION=MF.tellg()/sizeof(M);
cout<<"PRESENT RECORD:"<<POSITION<<endl;
MF.close();
}```

Q.9   Exam - CBSE12A-2015/04B/3

Write a definition for function COSTLY() in C++ to read each record of a binary file GIFTS.DAT, find and display those items, which are priced more that 2000. Assume that the file GIFTS.DAT is created with the help of objects of class GIFTS, which is defined below:

```class GIFTS
{
int CODE;char ITEM; float PRICE;
public:
void Procure()
{
cin>>CODE; gets(ITEM);cin>>PRICE;
}
void View()
{
cout<<CODE<<":"<<ITEM<<":"<<PRICE<<endl;
}
float GetPrice() {return PRICE;}
};```

Q.10   Exam - CBSE12A-2015/04A/2

Write function definition for TOWER() in C++ to read the content of a text file WRITEUP.TXT, count the presence of word TOWER and display the number of occurrences of this word.
Note :
‐ The word TOWER should be an independent word
‐ Ignore type cases (i.e. lower/upper case)
Example: If the content of the file WRITEUP.TXT is as follows:

 Tower of hanoi is an interesting problem. Mobile phone tower is away from here. Views from EIFFEL TOWER are amazing.

The function TOWER () should display the following:

 3

Q.11   Exam - CBSE12A-2015/03D/3

Write a function REVROW(int P[],int N, int M) in C++ to display the content of a two dimensional array, with each row content in reverse order.
For example, if the content of array is as follows:

 15 12 56 45 51 13 91 92 87 63 11 23 61 46 81

The function should display output as:
51 45 56 12 15
63 87 92 91 13
81 46 61 23 81

Q.12   Exam - CBSE12A-2015/03C/4

Write the definition of a member function PUSH() in C++, to add a new book in a dynamic stack of BOOKS considering the following code is already included in the program:

```struct BOOKS
{
char ISBN, TITLE;
};
class STACK
{
BOOKS *Top;
public:
STACK()
{Top=NULL;}
void PUSH();
void POP();
~STACK();
};```

Q.13   Exam - CBSE12A-2015/03A/2

Write the definition of a function Change(int P[], int N) in C++, which should change all the multiples of 10 in the array to 10 and rest of the elements as 1. For example, if an array of 10 integers is as follows:

 P P P P P P P P P P 100 43 20 56 32 91 80 40 45 21

After executing the function, the array content should be changed as follows:

 P P P P P P P P P P 10 1 10 1 1 1 10 10 1 1

Q.14   Exam - CBSE12A-2015/02C/4

Write the definition of a class Photo in C++ with following description:

```Private Members
Pno        //Data member for Photo Number
(an integer)
Category   //Data member for Photo Category
(a string)
Exhibit    //Data member for Exhibition Gallery
(a string)
FixExhibit //A member function to assign
//Exhibition Gallery as per Category
//as shown in the following table
Category  Exhibit
Antique   Zaveri
Modern    Johnsen
Classic   Terenida

Public Members
Register()  //A function to allow user to enter
//values
//Pno,Category and call FixExhibit()
//function
ViewAll()   //A function to display all the data
//members```

Q.15   Exam - CBSE12D-2015/03D/3

Write a function REVCOL (int P[], int N, int M) in C++to display the content of a two dimensional array, with each column content in reverse order.
Note: Array may contain any number of rows.
For example, if the content of array is as follows:

 15 12 56 45 51 13 91 92 87 63 11 23 61 46 81

The function should display output as:

```11      23     61    46    81
13      91     92    87    63
15      12     56    45    51```

Q.16   Exam - CBSE12D-2015/03C/4

Write the definition of a member function Pop() in C++, to delete a book from a dynamic stack of TEXTBOOKS considering the following code is already included in the program.

```struct TEXTBOOKS
{
char ISBN; char TITLE;
};
class STACK
{
TEXTBOOKS *Top;
public:
STACK() {Top=NULL;}
void Push();
void Pop();
~STACK();
};```

Q.17   Exam - CBSE12D-2015/03A/2

Write the definition of a function Alter(int A[], int N) in C++, which should change all the multiples of 5 in the array to 5 and rest of the elements as 0. For example, if an array of 10 integers is as follows:

 A A A A A A A A A A 55 43 20 16 39 90 83 40 48 25

After executing the function, the array content should be changed as follow:

 A A A A A A A A A A 5 0 5 0 0 5 0 5 0 5

Q.18   Exam - CBSE12D-2015/02C/4

Write the definition of a class PlC in C++ with following description:
Private Members

```Pno       //Data member for Picture Number (an integer)
Category  //Data member for Picture Category (a string)
Location  //Data member for Exhibition Location (a string)
FixLocation  //A member function to assign
//Exhibition Location as per category
//as shown in the following table```
 Category Location Classic Amina Modern Jim Plaq Antique Ustad Khan
```Public Members
Enter()     //A function to allow user to enter values
//Pno, category and call FixLocation() function
SeeAll()    //A function to display all the data members```

Q.19   Exam - CBSE12A-2017/04B/2

Write a definition for function COUNTPICS ( ) in C++ to read each object of a binary file PHOTOS.DAT, find and display the total number of PHOTOS of type PORTRAIT. Assume that the file PHOTOS.DAT is created with the help of objects of class PHOTOS, which is defined below:

```class PHOTOS
{
int PCODE;
char PTYPE;//Photo Type as “PORTRAIT”,”NATURE”
public:
void ENTER()
{
cin>>PCODE;gets(PTYPE);
}
void SHOWCASE()
{
cout<<PCODE<<":"<<PTYPE<<endl;
}
char *GETPTYPE(){return PTYPE;}
};```

Q.20   Exam - CBSE12A-2017/04A/3

Polina Raj has used a text editing software to type some text in an article. After saving the article as MYNOTES.TXT , she realised that she has wrongly typed alphabet K in place of alphabet C everywhere in the article. Write a function definition for PURETEXT() in C++ that would display the corrected version of the entire article of the file MYNOTES.TXT with all the alphabets “K” to be displayed as an alphabet “C” on screen .
Note: Assuming that MYNOTES.TXT does not contain any C alphabet otherwise.
Example:
If Polina has stored the following content in the file MYNOTES.TXT :

 I OWN A KUTE LITTLE KAR. I KARE FOR IT AS MY KHILD.

The function PURETEXT() should display the following content:

 I OWN A CUTE LITTLE CAR. I CARE FOR IT AS MY CHILD.

Q.21   Exam - CBSE12A-2017/03D/4

Write the definition of a member function PUSHGIFT() for a class STACK in C++, to add a GIFT in a dynamically allocated stack of GIFTs considering the following code is already written as a part of the program:

```struct GIFT
{
};
class STACK
{
public:
STACK(){TOP=NULL;}
~STACK();
};```

Q.22   Exam - CBSE12A-2017/03B/2

Write a definition for a function SUMMIDCOL(int MATRIX[],int N,int M) in C++, which finds the sum of the middle column’s elements of the MATRIX (Assuming N represents number of rows and M represents number of columns, which is an odd integer).
Example: if the content of array MATRIX having N as 5 and M as 3 is as follows:

 1 2 1 2 1 4 3 4 5 4 5 3 5 3 2

The function should calculate the sum and display the following:
Sum of Middle Column: 15

Q.23   Exam - CBSE12A-2017/03A/3

Write the definition of a function AddUp(int Arr[], int N) in C++, in which all even positions (i.e. 0,2,4,…) of the array should be added with the content of the element in the next position and odd positions (i.e. 1,3,5,…) elements should be incremented by 10.
Example: if the array Arr contains

 23 30 45 10 15 25

Then the array should become

 53 40 55 20 40 35

NOTE:

• The function should only alter the content in the same array.
• The function should not copy the altered content in another array.
• The function should not display the altered content of the array.
• Assuming, the Number of elements in the array are Even.

Q.24   Exam - CBSE12A-2017/02C/4

Write the definition of a class BOX in C++ with following description:
Private Members
– BoxNumber // data member of integer type
– Side // data member of float type
– Area // data member of float type
– ExecArea() // Member function to calculate and assign
// Area as Side * Side
Public Members
– GetBox() // A function to allow user to enter values of
// BoxNumber and Side. Also, this
// function should call ExecArea() to calculate
// Area
– ShowBox() // A function to display BoxNumber, Side
// and Area

Q.25   Exam - CBSE12A-2018/04B/2

Write a definition for function TotalTeachers( ) in C++ to read each object of a binary file SCHOOLS.DAT, find the total number of teachers, whose data is stored in the file and display the same. Assume that the file SCHOOLS.DAT is created with the help of objects of class SCHOOLS, which is defined below:

```class SCHOOLS
{
int SCode; // School Code
char SName; // School Name
int NOT; // Number of Teachers in the school
public:
void Display()
{cout<<SCode<<"#"<<SName<<"#"<<NOT<<endl;}
int RNOT(){return NOT;}
};```

Q.26   Exam - CBSE12A-2018/04A/3

A text file named MATTER.TXT contains some text, which needs to be displayed such that every next character is separated by a symbol ‘#’. Write a function definition for HashDisplay () in C++ that would display the entire content of the file MATTER.TXT in the desired format.
Example:
If the file MATTER.TXT has the following content stored in it:
THE WORLD IS ROUND
The function HashDisplay () should display the following content:
T#H#E# #W#O#R#L#D# #I#S# #R#O#U#N#D#

Q.27   Exam - CBSE12A-2018/03D/4

Write the definition of a member function AddPacket() for a class QUEUE in C++, to remove/delete a Packet from a dynamically allocated QUEUE of Packets considering the following code is already written as a part of the program.

```struct Packet
{
int PID;
};
class QUEUE
{
Packet *Front, *Rear;
public:
QUEUE(){Front=NULL;Rear=NULL;}
void DeletePacket();
~QUEUE();
};```

Q.28   Exam - CBSE12A-2016/04B/3

Write a definition for function ONOFFER( ) in C++ to read each object of a binary file TOYS.DAT, find and display details of those toys, which has status as “ÖN OFFER”. Assume that the file TOYS.DAT is created with the help of objects of class TOYS, which is defined below:

```class TOYS
{
int TID;char Toy,Status; float MRP;
public:
void Getinstock()
{
cin>>TID;gets(Toy);gets(Status);cin>>MRP;
}
void View()
{
cout<<TID<<”:”<<Toy<<”:”<<MRP<<””:”<<Status<<endl;
}
char *SeeOffer() { return Status; }
};```

Q.29   Exam - CBSE12A-2016/04A/2

Write function definition for DISP3CHAR() in C++ to read the content of a text file KIDINME.TXT, and display all those words, which have three characters in it.
Example: If the content of the file KIDINME.TXT is as follows:

```When I was a small child, I used to play in the garden with my grand mom.
Those days were amazingly funful and I remember all the moments of that time```

The function DISP3CHAR() should display the following:

`was the mom and all the`

Q.30   Exam - CBSE12A-2016/03D/3

Write definition for a function DISPMID(int A[],int R,int C) in C++ to display the elements of middle row and middle column from a two dimensional array A having R number of rows and C number of columns.
For example, if the content of array is as follows:

 215 912 516 401 515 103 901 921 802 601 285 209 609 360 172

The function should display the following as output
103 901 921 802 601
516 921 609

Q.31   Exam - CBSE12A-2016/03C/4

Write the definition of a member function DELETE() for a class QUEUE in C++, to remove a product from a dynamically allocated Queue of products considering the following code is already written as a part of the program.

```struct PRODUCT
{
int PID; char PNAME;
PRODUCT *Next;
};
class QUEUE
{
PRODUCT *R,*F;
public:
QUEUE(){R=NULL;F=NULL;}
void INSERT();
void DELETE();
~QUEUE();
};```

Q.32   Exam - CBSE12A-2016/03A/2

Write the definition of a function FixSalary(float Salary[], int N) in C++, which should modify each element of the array Salary having N elements, as per the following rules:

Existing Salary Values Required Modification in Value
If less than 100000 Add 35% in the existing value
If >=100000 and <20000 Add 30% in the existing value
If >=200000 Add 20% in the existing value

Write a program to search members of integer array 1 in array 2 and print the members of array 1 that are also found in array 1. Also print the total number of members found.
For e.g. if array 1 is [12,19,23,3,2] and array 2 is [13,12,2,3,14,21],
the output would be
12 3 2
count = 3

Q.34   Exam - CBSE12A-2016/02C/4

Write the definition of a class CITY in C++ with following description:

Private Members

Ccode         //Data member for City Code (an integer)
CName      //Data member for City Name (a string)
Pop              //Data member for Population (a long int)
KM              //Data member for Area Coverage (a float)
Density      //Data member for Population Density (a float)
DenCal()   //A member function to calculate Density as Pop/KM

Public Members
Record()   //A function to allow user to enter values of Acode,Name,Pop,KM and call DenCal() function
View() //A function to display all the data members. Also display a message ”Highly Populated City”
if the Density is more than 10000

Write a program to collect members of a 2-D integer array in A form. Double value of each member and then print the array in matrix form

Write a program to collect 5 numbers from user into a 1-D integer array. Calculate sum of all the input numbers and print it with a suitable message.

Write a function to find the sum of following series with any looping statement
12 + 22 + 32 ……… +72

Write a program to find the sum of following series with any looping statement
12 + 22 + 32 ……… +72

Write a program to print hypotenuse of a right angled triangle if base and height of the triangle is given by the user.

Q.40   Exam - CBSE12A-2018/03B/3

Write definition for a function UpperHalf(int Mat) in C++, which displays the
elements in the same way as per the example shown below.

For example, if the content of the array Mat is as follows:

```25 24 23 22
20 19 18 17
15 14 13 12
10  9  8  7```

The function should display the content in the following format:

```25 24 23 22
20 19 18
15 14
10```

Q.41   Exam - CBSE12A-2018/03A/2

Write the definition of a function SumEO(int VALUES[], int N) in C++, which should display the sum of even values and sum of odd values of the array separately.

Example: if the array VALUES contains
25 20 22 21 53

Then the functions should display the output as:
Sum of even values = 42 (i.e 20+22)
Sum of odd values = 99 (i.e 25+21+53)

Q.42   Exam - CBSE12A-2018/02C/4

Write the definition of a class CONTAINER in C++ with the following description:
Private Members
– Type // int (1 for Cone,2 for Cylinder)
– Volume // float
– CalVolume() // Member function to calculate volume as per the Type

Type Formula to calculate Volume

Public Members
– GetValues() // A function to allow user to enter value of Radius, Height and Type. Also, call
function CalVolume() from it.
– ShowAll() // A function to display Radius, Height, Type and Volume of Container

Write a program to print the following alphabet series up to 7 terms.

C F I L …..

Write a program to display all the words in a file that are three character words. Assume that filename is
MATTER.TXT and it contains the following matter.

The quick brown fox jumps over a lazy dog

Write a program to display the lines starting with character ‘A’ or ‘a’ in the file “PROG.TXT” that contains following text. Also display the count of such lines.

A programmer should always be hardworking.
For that matter everyone should be hardworking.
A programmer is always under pressure.
Yes! not everyone is always under pressure.

Write a function to count and return the number of space characters present in the filename passed to it as an argument. Also show implementation of this function in the main routine using NOTES.TXT file that contain the following data

This is first line
This is second line
This is third line

Write a function to count and return the number of words present in the filename passed to it as an argument. Assume that each word is separated by a single space and their is no space in the
beginning and end of the file.

Also demonstrate the use of this function in the main routine assuming a file NOTES.TXT that contains the following text.

This is first line
This is second line
This is third line

Write a function named DIVISION to pass maximum marks and marks obtained by a student. Return division as integer value 1, 2 3 or 0 as follows

=60 % as first division – return 1
>=45 <60 % as Second Division – return 2
>=33 <45 % as Third Division – return 3
<33 as Fail – return 0

Show implementation of above function in main routine with some fixed values.

Write a program to count alphabets in a given file “NOTES.TXT”. What would be  the output when this file is tested with the NOTES.TXT  file containing the following lines.

This is first line
This is second line
This is third line

A sports teacher has been confidentially asked to reject the persons whose Tee-shirt numbers are divisible by 10. Make a program to help this teacher collect the T-shirt numbers one by one and stop counting when 10 persons have been counted. Keep printing the selected Tee-shirt numbers.

Write a user-defined function swap_col(int ARR[ ],int R,int C) in C++ to swap the first column values with the last column values:

For example if the content of array is –
11 12 13
21 22 23
31 32 33

Then after function call the content of array would be

13 12 11
23 22 21
33 32 31

Write a user-defined function swap_row(int ARR[ ],int R,int C) in C++ to swap the first row values with the last row values:

For example if the content of array is –
10 20 30
40 50 60
70 80 90

Then after function call the content of array would be

70 80 90
40 50 60
10 20 30

Write a C++ program to collect a positive integer from the user and the check its reversed number would be a palindrome or not (same number when reversed for e.g. 121, 1331). Please use some alternate technique to find remainder instead of modulus operator.

Write a program to input a small sentence from the user and ask about frequency of which character is to be found. Print how many times the character occurred in the given string. Do it for a a c-style (null-terminated string). Please note that the character frequency is to be found  irrespective of its lower or upper case.

Write a program which collects an integer number from the user and if the number is even it prints the square of the number else it prints its cube.

Prepare an array of temperature readings of an entire week with data as
25.3, 27.0, 24.8, 26.9, 25.9, 26.4, 24.0. Now find out the average temperature of the week and then print out the readings which are more than the average temperature.

Write a program to collect 5 integer values from user in an integer array and then pass this array to a function along with its size. Return the sum of the array members from the function and print its value in the main routine.

Write a program to reverse the given integer number.using a separately called function to reverse the number.

Write a program where a function of prototype int ispalin(int) is written, which returns 1 when
given input number is a palindrome (eg. 121, 16561) else returns 0. Show implementation of this function in main routine by collecting a positive integer from the user.

Write a program to take a sentence input from the user and then print the sentence by reversing each word in the sentence.

Write a program to display 2nd, 4th and 6th multiple of the input integer number.

Convert given user input in gallons to cubic centimeter.  fter conversion use the converted quantity back to gallons. Print both the values. Assume appropriate data types.
Use conversion of 1 gallon = 3785.41 cc.

Write a C++ code to display the following text using the same cout chain.
Apples = 5 Kg
Bananas = 2 Doz
Oranges = 2.5 Kg

Write a c++ program using a function with the following prototype –
void first_last_digit(int n,int first,int last);
In this function pass an integer number as n and then find the first and last digit of n. Then update it on locations first and last passed as reference. Assume values to be passed to demonstrate the working of this function in the main routine.

Write a c++ program using function overloading using the following prototype –
int area(int); //For area of square
float area(float); //For area of circle
int area(int,int); //For area of rectangle
show working of this program by calling this function into the main routine using some assumed valued.

Write a c++ program to find the largest of three numbers using the if-else selection ladder. Please do report with an appropriate message if two large numbers or all numbers are same.

Write a program to print a series of triangular numbers starting 1 using the property of a flyod’s triangle where the right most number is a triangular number. Accept the number of terms to be printed from the user. The series output would be 1 3 6 10 15 ……

Write a program to count number of words even when there might be extra spaces between words and extra punctuation marks. Any alphabets or numbers written contiguously will be counted as words. For. e.g. “21st Century” are two words and “21    st         century systems ?” are four words. ? is not counted as word while 21 is counted as a word.

Write a program  to count the number of space characters in a given input string or sentence using the character match for space character ‘ ‘.

Write a program to find the sum of the following series upto 5 terms. Also print the series terms.
1/1! + 2/2! + …

Write a program to find the sum of the following series if x is 3 and n is 5. Also print the series terms.
x + x^2/2 + x^3/3 + …+x^n/n

Write a program to print the following series up to 15 terms ..
1 4 8 13 19 26 …….

Write a program to print the following series up to 15 terms ..
1 8 27 64 125 …….

Write a program to print odd numbers series up to 20 terms beginning from 13.

Assume that first two terms of a series are 10 and 11. Then use the Fibonacci series rules of adding two previous terms, write a program to print 10 terms of such a series. Also print the sum of all the terms printed.

Write a C++ program to find average of three integer numbers given by the user. The output can have fractional double precision values as well.

Write a c++ program to collect a single character from the user and print ascii code of the same character and its next character.

Write the following text using the cout chain using \t and \n escape sequences.

```Subjects        Marks
---------------------
Computers       100
Physics         95
Mathematics     98```

Write a program to repeat the character as given by the user for number of times as desired by the user. Show the repeated character in the same line. Use for loop for repeatition.

Write a c++ program to power a base number with the given exponent by using a for loop.

Write a c++ program to output the square and square roots of a number in a range where range begin variable is initialised in the variable ‘from’ and range end variable is initialised in the variable ‘to’.

Instead of sending his secret code a programmer tells his friend that my secret code is a series of characters which are upper and lower alphabet sequence in their ascending order which are divisible by five. Can you help the programmer’s friend to decipher this code.

Write a c++ program to print ascii codes and given printable characters from decimal ascii code 32 to 126 (The printable ascii code range). Print each code and character set in a new line.

Write a c++ program to ask an integer number from the user and then print all its divisors in one line, followed by the count of divisors. The output should be as per example given below.

Enter an integer :45
The divisors of 45 are –
1 3 5 9 15 45
The count of divisors = 6

Write a c++ program to test if the user given integer value is an even number or an odd number.

Write a c++ program to take the value of a four digit year from the user and then print whether the given year is a leap year or not.

Write a c++ program to collect a positive integer value from the user and print the list of all natural numbers up to that number. Also print the sum of the natural number printed.

Write a function linsearch(int [],int, int) which searches for the term 23 in the given integer array [12,19,23,3,2] and returns its position in the array. This array should be initialised in the calling function and then passed as reference to the given function. Show implementation also.

Print all the armstrong numbers between 1 to 999.

Write a C++ code to display the following text “I am happy today.” using four separate string literals and by using the same cout instruction.

Print all palindrome numbers between 1 to 1000.

×