|
Problem Solving Assignments |
|
C Language |
|
SCO 74 Level II Sector 46-C, Chandigarh(U.T.) INDIA Phone: 0172-4605347 (m): +91-9646374115,9915005347 |
Introduction
1.
What is C?
2.
What is
operating system?
3.
What is the
role of computer memory and its types?
4.
Which memory
used at run-time of program?
5.
What is code
editor?
6.
What is
compiler?
7.
What is IDE?
Explain.
8.
Define the
following terms:
n
Program
n
Source File
n
Executable
File
n
Header File
n
Comments
n
Main()
function
n
Statement
Terminator
n
tc.exe
n
clrscr()
Function
n
printf() Function
n
Keyword/
Reserve words.
9. What is your first
experience to join COMPUHELP?
Variables
and Operators
Conditional statements
Q1: Enter the marks from the user and display the corresponding grades:
Marks grade
100-80 A
80-60 B
60-40 C
Below 40 Fail
Q2: Accept a number and check if it is positive or negative or zero.
Q3: Accept a number and check if it is odd or even.
Q4: Accept a character and check whether it is vowel or not.
Q5: Accept a character and check if it is vowel, consonant or a special
character.
Q6: Accept a number between 1 and 7 and print the corresponding week
days. If the number is out of range, print message “wrong input”.
Q7: Accept a number between 0 and 9 and print the words equivalent.
Q8: Accept a number between 1 and 12 and print the month it represents in
words.
Q9: Accept a number between 1 and 5. If the user:
Enters 1:
add two numbers
Enters 2:
subtract two numbers
Enters 3:
division of two numbers
Enters 4:
multiplication of two numbers
Enters 5:
exit the program
Q10: Enter three numbers and check the greatest out of the three.
Q11: Enter a number and check if the number is Palindrome or not.
Q12: Enter a number and check if the number is Armstrong or not.
Q13 :Enter a number and check Whether it is prime number or not.
Switch Statements
Q1: Accept a number
between 0 and 9 and print the words equivalent.
Q2: Accept a number
between 1 and 12 and print the months it represents in words.
Q3: Accept a number
between 1 and 7 and print the days it represents in words.
Q4: Accept a
character and check whether it is vowel or not.
Q5: Accept a number
between 1 and 5. When the user
Press 1: add two numbers
Press 2: subtract two numbers
Press 3: division of two numbers
Press 4: multiplication
Press 5: for exit.
Q6: Accept a number
between 1 and 5. When the user
Press 1 for Fibonacci series
Press 2 for Factorial
Press 3 for printing even series
Press 4 for printing odd series
Press 5 for exit
Q7: Accept a number
between 1 and 5. When the user
Press 1: print even numbers starting
from 0 till the user wants
Press 2: print odd numbers starting from
0 till the user wants
Press 3: print the square of the number
entered by the user
Press 4: print the character entered by
the user, that to, till the user wants
Press 5 for exit
Q8: Accept a string
by the user. Accept a number between 1 and 3. When the user
Press 1: display the reverse of the string
Press 2: display the entered string in
upper case
Press 3: display the entered string in
lower case
Do you want to continue? Press y for yes
or n for no
LOOPS α
*
*
*
*
*
*
*
*
COMPUHELP
*
COMPUHELP
*
COMPUHELP
*
COMPUHELP
*
COMPUHELP
*
COMPUHELP
*
LOOPS β
***
***
***
111
111
111
123
123
123
111
222
333
123
456
789
333
222
111
321
321
321
987
654
321
*
**
***
***
**
*
1
12
123
1
22
333
3
22
111
111
22
3
3
23
123
3
32
321
* * *
* *
*
123
12
1
111
22
3
*
*
*
* * *
*
*
*
*
* *
*
* * *
A
A
B
A
B C
C
B A
C
B
C
A
A
B
A
B C
While/Do-while
Q1: Write a program
to print the series starting from 0 till the user wants.
Q2: Write a program
to print the series starting from the number entered by the user till 0.
Q3: Write a program
to print the Fibonacci series till the user wants.
Q4: Write a program
to generate a table of the entered number.
Q5: Write a program
to input marks of 5 students in 3 subjects and print their marks average
marks.
Q6: Accept a number
and reverse it i.e. 1234-->4321
Q7: Write a program
to print factorial of a number entered i.e. 5*4*3*2*1=120.
Q8: Write a program
to print the series mn where m and n are entered by the user.
Character Assignments
Write a program to accept a character from the user and display the character.
Write a program to accept a character in lower case and display it in uppercase.
Write a program to accept a character from the user and display its ASCII value.
Write a program to accept a character in uppercase and display it in lowercase.
Write a program to display the ASCII values of 0 and 9.
Write a program to display the ASCII values from 0 to 9.
Write a program to display the ASCII values of all characters from A to Z.
Write a program to accept a character using getch(),getche() and getchar() functions and display the character.
Write a program to let the user press any key on the keyboard until x but count
only how many upper case character keys are pressed on the keyboard?
Variations
Q1: for (i=1; i<=3; i++)
{
printf (“%d”,i);
printf (“thanks\n”);
}
printf (“\n”);
printf (“welcome”);
printf (“%d”, i);
Q2: int i=1;
for ( ;i<=3;i++)
{
printf (“hello”);
printf (“%d”, i);
printf (“\n”);
}
printf (“%d”, i);
Q3: int j=3;
for
( ; j>=1; )
{
printf
(“%d”, j);
printf
(“\n”);
}
printf (“welcome”);
printf (“%d”, j);
Q4: for (i=1; i<=3; i++)
printf (“\n hello”);
printf (“%d”, i);
printf (“welcome”);
Q5: for (
; i>=1; i--)
{
printf (“hello”);
printf (“\n thanks”);
printf (“%d”, i);
}
printf (“\n welcome”);
printf (“%d”,i);
Q6: int i=0;
For( ; ; )
{
If(i<5)
{printf(“\nHello”);
i++;
}
}
Q7: for(i=0;i<10;i++);
{
printf(“\n%d”,i);
}
Q8: for(i=0;i>=5;i--)
{
printf(“\n%d”,i);
}
Q9: int i=5;
for(i=0;i>=5;i--)
{
printf(“\n%d”,i);
}
Q10:
int i=9,ctr=0;
for(;ctr<=i;i--)
{
printf(“%d”,i);
Ctr++;
}
Q11: int i=-5,ctr=0;
for(;;i++)
if(i<ctr)
{
printf(“%d”,ctr);
c++;
}
Q12: int i=91;
for(;;i--)
if(i>0)
printf(“%d”,i); printf(“bye”);
Single Dimension Arrays
1.
Write a
program to accept an integer array of 5 elements from the user, and display the
array. For e.g.: if the user enters the array 2 3 4 6 7, the output should be
as follows:
ENTER THE ARRAY ELEMENTS: 2 3 4 6 7
ELEMENT IS: 2
ELEMENT IS: 3
ELEMENT IS: 4
ELEMENT IS: 6
ELEMENT IS: 7
2.
Write a
program to accept an integer array of 5 elements from the user and display the
array elements in reverse order. For e.g.: if the array is 3 5 6 2 8 then the output
should be:
ENTER THE ARRAY ELEMENTS: 3 5 6 2 8
ELEMENT IS: 8
ELEMENT IS: 2
ELEMENT IS: 6
ELEMENT IS: 5
ELEMENT IS: 3
3.
Write a
program to accept 2 integer arrays of the same size and copy the elements of
the first array into the second array. The output should be as follows:
ENTER THE ARRAY ELEMENTS OF THE FIRST
ARRAY: 2 3 4 5 1
THE COPY OF THE ARRAY IS: 2 3
4 5 1
4.
Write a
program to accept 2 arrays of the same size and copy the reverse of the
elements of the first array into the second array. The output should be as
follows:
ENTER THE ARRAY ELEMENTS OF THE FIRST
ARRAY: 2 3 4 5 1
THE REVERSE COPY OF THE ARRAY
IS: 1 5 4 3 2
5.
Write a
program to accept an integer array of 6 elements, display them, then add the
elements of the array and display the sum. For e.g.: if the array is 2 4 1 5 6
3 then the output should be:
ENTER THE ARRAY ELEMENTS: 2 4 1 5 6 3
ELEMENT IS: 2
ELEMENT IS: 4
ELEMENT IS: 1
ELEMENT IS: 5
ELEMENT IS: 6
ELEMENT IS: 3
THE SUM OF THE ELEMENTS IS:
2 + 4 + 1 + 5 + 6 + 3 = 21
9. Write a program to accept 2
integer arrays of 5 elements from the user and display their elements. Then add
the elements of the two arrays store their sum in another array and display the
sum as a third array. The output should be:
ENTER THE FIRST ARRAY ELEMENTS: 2 3 1 5 6
ENTER
THE SECOND ARRAY ELEMENTS: 3 1 8 4 7
THE
ELEMENTS OF THE FIRST ARRAY ARE:
ELEMENT IS: 2
ELEMENT IS: 3
ELEMENT IS: 1
ELEMENT IS: 5
ELEMENT IS: 6
THE ELEMENTS OF THE SECOND ARRAY ARE:
ELEMENT IS: 3
ELEMENT IS: 1
ELEMENT IS: 8
ELEMENT IS: 4
ELEMENT IS: 7
THE
SUM OF EACH ELEMENT OF THE TWO ARRAYS IS:
ELEMENT IS: 5
ELEMENT IS: 4
ELEMENT IS: 9
ELEMENT IS: 9
ELEMENT IS: 13
10. Write a program to accept 2 integer arrays of
5 elements from the user and display their elements. Then subtract the elements
of the two arrays, store their differences in another array and display the
subtraction as a third array. The output should be:
ENTER
THE FIRST ARRAY ELEMENTS: 2 4 1 5 6
ENTER
THE SECOND ARRAY ELEMENTS: 3 1 8 4 7
THE
ELEMENTS OF THE FIRST ARRAY ARE:
ELEMENT IS: 2
ELEMENT IS: 4
ELEMENT IS: 1
ELEMENT IS: 5
ELEMENT IS: 6
THE ELEMENTS OF THE SECOND ARRAY ARE:
ELEMENT IS: 3
ELEMENT IS: 1
ELEMENT IS: 8
ELEMENT IS: 4
ELEMENT IS: 7
THE
DIFFERENCE OF EACH ELEMENT OF THE TWO ARRAYS IS:
ELEMENT IS: -1
ELEMENT IS: 3
ELEMENT IS: -7
ELEMENT IS: 1
ELEMENT IS: -1
11. Write a
program to accept an integer array of 5 elements from the user and find the
greatest element in the array and display it along with its position/location.
The output should be:
ENTER
THE ARRAY ELEMENTS: 2 3 1 5 6
THE
ELEMENTS OF THE FIRST ARRAY ARE:
ELEMENT 1: 2
ELEMENT 2: 3
ELEMENT 3: 1
ELEMENT 4: 5
ELEMENT 5: 6
THE GREATEST ELEMENT IS: 6
THE LOCATION IS: 5
12. Write a
program to accept an integer array of 5 elements from the user and find the
smallest element in the array and display it along with its
position/location. The output should be:
ENTER THE ARRAY ELEMENTS: 2 4 1 5 6
THE
ELEMENTS OF THE ARRAY ARE:
ELEMENT 1: 2
ELEMENT 2: 4
ELEMENT 3: 1
ELEMENT 4: 5
ELEMENT 5: 6
THE SMALLEST ELEMENT IS: 1
THE LOCATION IS: 3
13. Write a
program to accept an integer array of 5 elements, display them. Then sort the
array in ascending order and display the sorted array. The output should be:
ENTER THE ARRAY ELEMENTS: 2 4 1 5 6
THE
ELEMENTS OF THE ARRAY ARE:
ELEMENT 1: 2
ELEMENT 2: 4
ELEMENT 3: 1
ELEMENT 4: 5
ELEMENT 5: 6
THE SORTED ARRAY IS:
ELEMENT 1: 1
ELEMENT 2: 2
ELEMENT 3: 4
ELEMENT 4: 5
ELEMENT 5: 6
14. Write a
program to accept an integer array of 5 elements, display them. Then sort the
array
in descending order and display the sorted array. The output should be:
ENTER THE ARRAY ELEMENTS: 2 4 1 5 6
THE
ELEMENTS OF THE ARRAY ARE:
ELEMENT 1: 2
ELEMENT 2: 4
ELEMENT 3: 1
ELEMENT 4: 5
ELEMENT 5: 6
THE SORTED ARRAY IS:
ELEMENT 1: 6
ELEMENT 2: 5
ELEMENT 3: 4
ELEMENT
4: 1
ELEMENT 5: 2
15. Write a program to accept an integer array of 5
elements from the user, display them. Then accept a number from the user and
search that number in the array. If the number is found print ”NUMBER IS FOUND AT THE LOCATION------“
along with its location/position. If the number is not found print “NUMBER IS NOT FOUND”.
Double Dimension Arrays
1.
What is a
double dimension array? How does it look like? Explain it with a pictorial
representation.
What other name is given to double dimension arrays?
2.
Write a
program to accept a 3 X 3 matrix from the user and display the matrix.
For e.g: if the user enters the array 2 3
4 6 7 9 1 4 2, the output should be as follows:
ENTER THE ELEMENTS:
2 3 4
6 7 9
1 4 2
THE ARRAY ELEMENTS ARE:
2 3 4
6 7 9
1 4 2
3. Write a
program to accept two matrices of the same size and copy the elements of the
first
matrix into second matrix. The output should be as follows:
ENTER THE ELEMENTS OF THE FIRST MATRIX:
2 3
1 2
THE COPY OF THE MATRIX IS:
2 3
1 2
4. Write a
program to accept two matrices of the same size and store the reverse of
the
first
matrix into second matrix. The output should be as follows:
ENTER THE ELEMENTS OF THE FIRST MATRIX:
2 3
1 2
THE REVERSE COPY OF MATRIX IS:
2 1
3 2
5. Write a program to accept a matrix and display
its elements in the reverse order. The
output
should be as follows:
ENTER THE ELEMENTS OF THE MATRIX:
2 3 4 1
THE REVERSE OF MATRIX IS:
1 4 3 2
6. Write a program to accept a 2 x 2 matrix,
display them and add the elements of the
matrix
and display the sum. For e.g. if the array is 2 4 1 5 then the output should be
as
follows:
ENTER THE ELEMENTS OF THE MATRIX:
2 4
1 5
THE SUM OF THE ELEMENTS IS:
2+4+1+5=12
7. Write a
program to accept two 3 x 3 matrices from the user, display their elements,
then add the elements of the two
matrices store their sum in another matrix and display the third matrix. The
output should be as follows:
ENTER THE FIRST MATRIX:
2 3 1 5 6 7 1 2 3
ENTER THE SECOND MATRIX:
3 1 8 4 7 6 5 4 3
THE SUM OF TWO MATRICES IS:
5 4 9
9 13 13
6 6 6
8. Write a program to accept two 3 x 3 matrices
from the user, display their elements, then
subtract the elements of the two matrices store their subtraction in
another matrix and display the third matrix. The output should be as follows:
ENTER THE FIRST MATRIX:
2 3 1 5 6 7 1 2 3
ENTER THE SECOND MATRIX:
3 1 8 4 7 6 5 4 3
THE SUBTRACTION OF TWO MATRICES IS:
-1 2 -7
1 -1 1
-4 -2 0
9. Write a
program to multiply two matrices. For multiplication of two matrices one
must
keep in
mind that number of columns in the first matrix should be equal to the
number
of rows
in the second matrix. The output should be as follows:
ENTER THE FIRST MATRIX:
2 3 4
1 3 6
ENTER THE SECOND MATRIX:
3 2
1 5
6 3
THE MULTIPLICATION IS:
33 31
18 35
11. Write a program to accept 2 x 2 matrix from the
user and find the greatest element
in the
matrix and display it along with its row and column number. The output
should
be as
follows:
ENTER THE MATRIX:
2 4 1 5
THE ELEMENTS OF THE MATRIX ARE:
2 4
1 5
THE GREATEST ELEMENT IN THE MATRIX IS: 5 AND IS PRESENT IN ROW
2 AND COLUMN 2
12. Write a program to accept 2 x 2 matrixes from
the user and find the smallest element
in the matrix and display it along with its
row and column number. The output should
be as
follows:
ENTER THE MATRIX:
2 4 1 5
THE ELEMENTS OF THE MATRIX ARE:
2 4
1 5
THE SMALLEST ELEMENT IN THE MATRIX IS: 1 AND IS PRESENT IN
ROW 2 AND COLUMN 1
13. Write a program to transpose a matrix.
Transpose means changing the rows into
columns
and columns into rows. The output should be as follows:
ENTER THE MATRIX:
2 4
1 5
THE TRANSPOSE IS:
2 1
4 5
14. Write a program to accept two matrices from the
user, display it. Then accept a
number
from the user and search that number in the matrix. If the number is found
print
“NUMBER IS FOUND AT LOCATION …….” along with its location/position. If
the
number is not found print “NUMBER IS NOT FOUND”. For e.g.:
ENTER THE MATRIX: 2 3 1 6 4 6 7 9 8
THE MATRIX IS:
2 3 1
6 4 6
7 9 8
ENTER THE NUMBER TO BE SEARCHED: 7
NUMBER FOUND IN ROW 3 COLUMN 1
15. Write a program to accept two matrices of the
same size and check whether each
element
of the first matrix matches the each element of the second matrix or not.
If
both
are equal, then display “MATRICES ARE EQUAL”.
Character Array
1. What is a character array? What is the collection of character known
as?
2. What are the various input output functions for character arrays
apart from scanf () and
printf ()?
3. Write a program to accept a string from the user and display it.
OUTPUT:
ENTER A STRING: COMPUHELP
THE STRING YOU ENTERED IS: COMPUHELP
4. Write a program to accept a string from the user and display it in
reverse.
OUTPUT:
ENTER A STRING: COMPUHELP
THE STRING YOU ENTERED IS: PLEHUPMOC
5. Write a
program to find the length of an entered string and display it as follows:
ENTER A STRING: COMPUHELP
THE LENGTH OF THE STRING IS: 9
6. Write a program to accept a string in upper case
and convert it into lower case. The output should
be:
ENTER A STRING IN UPPER CASE:
COMPUHELP
THE STRING IN LOWER CASE: compuhelp
7. Write a program to accept a string in lower case and convert it into
upper case. The output should
be:
ENTER A STRING IN LOWER CASE: compuhelp
THE STRING IN UPPER CASE: COMPUHELP
8. Write program to count and print the number of vowels in an entered
string. The output should be as follows:
ENTER A STRING: COMPUHELP
THE VOWELS ARE: O U E
THE NUMBER OF VOWELS IS: 3
9. Write a program to count and print the number of
consonants in an entered string. The output
should be as follows:
ENTER A STRING: COMPUHELP
THE
CONSONANTS ARE: CMPHLP
THE NUMBER OF CONSONANTS ARE: 6
10. Write a program to accept two
character arrays and copy the first string into second one. The
output
should be as follows:
ENTER THE STRING: COMPUHELP
THE COPY OF STRING IS: COMPUHELP
11. Write a program to find out the number of words in a sentence. The
output should be:
ENTER A SENTENCE: COMPUHELP COMPUTER
EDUCATION
THE NUMBERS OF WORDS ARE: 3
Functions
1. What is function?
Why do we need them? Explain with the help of pictorial diagrams.
2. What are the
stages of the functions? What is the default return type of any function?
3. How is function
declaration different from function definition?
4. How many types of
functions are provided by the c language? Explain.
5. How many different
types of user-defined functions we can make?
6. What is the use of
main ( ) in a program? What will happen, if there is no main ( ) in our
Program?
7. What is calling
and called function?
8. Write a function
sum ( ) to calculate the sum of four numbers and display the sum. Neither
does
the function return any value nor accepts
any value. The output should be as follows:
ENTER FIRST NUMBER: 3
ENTER SECOND NUMBER: 4
ENTER THIRD NUMBER: 2
ENTER THIRD NUMBER: 1
THE SUM OF ALL NUMBERS IS: 10
9. Write a program
which contains the following functions performing all arithmetic operations:
Add ( ) - function to add two numbers
Sub ( ) - function to subtract the smaller
number from the greater one.
Div ( ) - function to divide the greater
number from the smaller one
Mull ( ) - function to multiply two
numbers
If mull ( ) function is called for
instance, the output should be as following:
ENTER FIRST NUMBER: 3
ENTER SECOND NUMBER: 4
THE PRODUCT OF THE TWO NUMBERS IS:
12
10. What do you mean
by arguments? What other name can you give to arguments?
11. Write a function
odd ( ) to display all the odd numbers from 1to n, where n is the ending
number passed as arguments to the
function. The output should be as follows:
ENTER THE NUMBER: 8
THE ODD SERIES IS: 1 3 5 7
12. Write a function
even ( ) to display all the even numbers from 1 to n, where n is the
ending
number passed as an argument to the
function. The output should be as follows:
ENTER THE NUMBER: 8
THE EVEN SERIES IS: 2 4 6 8
13. Write
a program for following output:
ENTER A CHARACTER: $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
14. Write a function
series ( ) which accept two values as arguments. One value is the starting
value of the series and the second value
is the ending value of the series. The function prints all
the numbers from the starting value till
the ending value. The output should be as follows:
ENTER THE STARTING VALUE: 5
ENTER THE ENDING VALUE: 15
THE SERIES IS: 5 6 7 8 9 10 11 12
13 14 15
15. Write a function
named is_pos_neg ( ) which accepts a number and calculates if the entered
number is positive or negative.
16. Write a function
Fibonacci ( ) to generate the Fibonacci series till ‘n’ numbers, where n is an
integer passed as argument to the
function. The output should be:
Enter the number: 9
Fibonacci series: 0 1 1 2 3 5 8
17. Write a function
to_upper ( ) which accepts a single alphabet in lower case and converts that
alphabet into upper case. The output
should be as follows:
ENTER AN ALPHABET IN LOWER CASE:
k
THE ALPHABET IN UPPER CASE IS: K
18. Write a function
to_lower ( ) which accepts a single alphabet in upper case and converts that
alphabet into lower case. The output
should be as follows:
ENTER AN ALPHABET IN UPPER CASE:
K
THE ALPHABET IN LOWER CASE IS: k
19. Write a function
to generate the following series till ‘n’, where n is an integer passed as
an argument to the function. The output
should be as follows:
ENTER A NUMBER: 5
SERIES: 1+4+9+16+25=55
20. What is the use
of the return statement? Where is the return statement placed? Maximum how
many values can be returned to a function?
21. Write a function
factorial( ) which calculates the factorial of a number given as an argument to
the function and returns the value of
that factorial of that number to the calling function. The
output should be should be as follows:
ENTER A NUMBER: 5
THE FACTORIAL IS: 5*4*3*2*1=120
22. Write a function
swap ( ) which accepts two numbers as arguments and swaps the value of
these two variables. The output should be
as follows:
ENTER FIRST NUMBER: 5
ENTER SECOND NUMBER: 8
THE VALUE OF THE NUMBERS
BEFORE SWAPPIG IS:
FIRST: 5
SECOND: 8
THE VALUES AFTER SWAPPING IS:
FIRST: 8
SECOND: 5.
23. What do you mean
by recursion? Write a program for finding out the factorial of a number
illustrating the concept of recursion in
it.
24. Write a function
fact(), that through recusrsion, prints the series of factorial. The output
should
be should be as follows:
ENTER A NUMBER: 5
THE FACTORIAL IS: 5*4*3*2*1=120
25. What are the most
commonly used in-built functions for input and output? Name the files
which contain their definition.
Pointers
1.
What are
pointers? Why do we need them?
2.
What are
the stages of pointers? What is the data type of pointers? How much memory do
they occupy?
3.
What does
this mean?
int
*ptr;
4.
Enter two
numbers from the user, add them through pointers and display their sum through
pointers.
5.
Swap the
values of two variables through pointers.
6.
Write a
program to enter an array of 5 elements. Through pointers reverse them and
display them.
7.
Write a
program to enter an array of 5 elements. Through pointers add the elements, and
display them.
8.
Write a
program to enter two arrays of 5 elements. Through pointers add the two arrays,
copy the result in third array and display them.
9.
Write a
program to print the series till the user wants starting from 0 through
pointers.
10. Write a program to add
the elements of a 3x3 matrix through pointers.
11. Write the output for the following program:
void main( )
{
int *ptr;
cin>>*ptr;
cout<<*ptr;
getch( );
}
12. Write the output for the following program:
void main( )
{
int num1,*ptr;
cin>>num1;
cout<<*ptr;
cout<<ptr;
cout<<&ptr;
cout<<&num1;
getch( );
}
13. Write the output for the following program:
void main( )
{
int
num1,*ptr,**ptr1,***ptr2;
ptr=&num1;
ptr1=&ptr;
ptr2=&ptr1;
cin>>num1;
cout<<*ptr;
cout<<ptr;
cout<<&ptr;
cout<<&num1;
cout<<*ptr1;
cout<<&ptr1;
cout<<**ptr1;
cout<<*ptr2;
cout<<&ptr2;
cout<<**ptr2;
cout<<***ptr2;
getch( );
}
Structures
Q1 Write
a program to input rollno, name and fees of a student and display the output.
Q2 Write
a program to input the rollno and marks of a student in five subjects and
display the output.
Q3 Write
a program to find the average marks of nine subjects through structures.
Q4 Write
a program to input the details of 5 employees using array of structures and
print them back.
Q5 Write
a program to find percentage of five subjects of five students.
Q6 Write
a program to find the percentage of five subjects through pointers.
Q7 Write
a program to find the percentage of five subjects of five students through
pointers.
Q8 Write
a program to pass a structure to a function by reference.
File Handling
Q1 Write
a program to create a file and write a string into it.
Q2 Write
a program to create a file. Accept a number from the user and write that number
into the file which you have created.
Q3 Write
a program to create a file. Accept a number from the user and write that number
into the file which you have created. Now read the number from the file and
display it on the console screen
Q4 Write
a program to create a file. Accept a number from the user and write that number
into the file which you have created. Now read the number from the file and
write it into another file.
Q5 Write
a program to create a text file and read all the contents of the file character
by character and display all the contents on the console screen.
Q6 Write
a program to create a text file and count the number of characters in it.
Q7 Write
a program to create a text file and count the number of vowels in it
Q8 Write
a program to create a text file and count the number of upper case letters and
lower case letters in it.
Q9 Write
a program to create a file and count the number of spaces and words in the
file.
Q10 Write a program to
create a file and count the number of lines in the file.
Q11
Write a program to write 10 numbers into a
file and display the even and odd numbers separately on the console screen.
Q12
Write a program to enter few characters from
the user and store in a file. Enter another character and convert all
occurrences of that character to upper case.
Q13
Write a program to enter the rollno, name, and
fees of the student through structures and save the data into a file.