Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
78 views

C Assignments

The document contains 9 exercises covering fundamental C programming concepts like input/output, decision making, loops, arrays, strings, pointers, functions, and more. Each exercise includes 10-11 programming problems/tasks to practice the relevant concept. The exercises progress from basic syntax and logic to more advanced data structures and program design techniques.

Uploaded by

ketandeshpande1
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views

C Assignments

The document contains 9 exercises covering fundamental C programming concepts like input/output, decision making, loops, arrays, strings, pointers, functions, and more. Each exercise includes 10-11 programming problems/tasks to practice the relevant concept. The exercises progress from basic syntax and logic to more advanced data structures and program design techniques.

Uploaded by

ketandeshpande1
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 7

EXERCISE 1

============

INITIAL PROGRAMS

1. Print the given output


\n -> New line
\t -> Tab
\\ -> Backslash
\" -> Double quote

2. Print the following output in the middle of the screen.


(Use only \n and \t in printf statement don't use spaces)
*
* * *
* * * * *
* * * * * * *

3. Print your name in double quotes and print the address of


three lines.

4. Take two variables and swap their contents using third temporary
variable.

5. Take two variables and swap their contents without using third
temporary variable.

6. Take a four digit number from the user print its reverse.

7. Take a four digit number from the user and print the sum of
the digits.

8. Take a three digit number from the user and print the sum of
first and last digit.

9. Take the marks of five subjects and calculate the total and the
average and print it.

10. Take the radius of the circle and claculate the area of the circle.

EXERCISE 2
============

DECISIONS (IF - ELSE)

1. Take the marks of five subejcts calculate the total and the
average and on the basis of average decide the grade of the student.
0 - 34 % Fail
35 - 45 % Third grade
45 - 60 % Second grade
60 - 75 % Third grade
75 onwards Distinction.

2. Check whether given number is even or odd.

3. Check whether given number is positive or negative.

4. Find out the Largest among three numbers without using the
logical operators.

5. Find out the largest among three numbers using the logical operator.

6. Take number of items and the price per item from the user and
calculate the bill, if total amount is more than 1000 then
give 10% discount else no discount, Display the bill.

7. Take the basic salary from the user if basic salary is less
than or equal to 2000 then
DA=40% and HRA is 20%
if basic salary is greater than 2000 then
DA=60% and HRA is 40%,
Calculate the gross salary.

8. Calculate the total electricity bill.


Take number of units consumed from the user.
Units Rate
0-100 2.25
101-500 5.65
501-1000 7.85
1001 onwards 9.30

9. Calculate the total wages of the month.


Take working hours from the user.
Working Hours Wages
Less than or equal to 200 2000
More than 200 100 Rs./hr. overtime.

EXERCISE 3
============

SWITCH - CASE

1. Take the number from the user upto 10 and print it in words.

2. Take the character from the user and print whether the
entered character is vowel or consonent. (Programme should be
applicable for both the cases i.e. Upper and Lower case);

3. Take two numbers from the user and show him the menu of the
operations to be performed on these two numbers and ask his
choice, operate and display the result.

4. Modify the above programme, instead of showing the menu to the user
ask him to enter the operator, and operate accordingly.

5. Modify the above programme, instead of asking the operator to the


user ask him to input the expression and show the result.

6. Take any four digit number from the user and print it in words.
(Programme should be applicable for all the numbers upto 9999).

7. Take the month number from the user and print the corresponding month.

8. Take the month number from the user and print the season occuring
in that month.

EXERCISE 4
============

WHILE / DO - WHILE / FOR

1. Take the number from the user and print it in reverse order.

2. Take the number from the user and print the sum of the digits.

3. Print the sum of first 10 natural numbers.

4. Print the sum of first 100 even numbers.

5. Take the number from the user and check whether the entered number
is prime or not.

6. Print the series first 100 prime numbers.

7. Print the Fibonancii series.

8. Take the number from the user and check whether the given number
is an Armstrong number or not.
(Armstrong number is the number whose sum of the cube of digits
is equal to the number itself).

9. Print the series of Armstrong numbers upto 1000.

10. Take the number from the user and generate the table of given number.

11. Generate the tables from 2 - 10.

12. Take the number from the user and reverse it and check whether
it is same as the number.

13. Take ten numbers from the user and print the smallest and the
largest among them.

14. Print the series of numbers upto 10000 whose sum and the product
of the digits is same.

EXERCISE 5
============

ARRAYS

1. Take the input of 10 numbers from the user and print those numbers.

2. Take the input of 10 numbers from the user and print those numbers
in the reverse order.

3. Take the input of 10 numbers from the user find the smallest
and the largest number among these numbers.

4. Take the input of 10 numbers from the user and print those numbers
in the ascending order.

5. Take two arrays from the user and add them and store the result
in the third array.

6. Take the input of 10 numbers from the user and print square
of the numbers in the same array.

7. Take two numbers from the user and find the HCF of the numbers.

8. Take the input of 10 numbers from the user and print how many
positive, negative, even and odd numbers are present in the
given array.

9. Take an array of 10 elements and put 7 elements in that, then


ask the user at which position does he want to insert the element
and what element, then insert the new element at the given position.

10. Take an array of 10 elements and put 10 elements in that, then


ask the user which element does he want to delete, then find out
the position of the element and delete it.

11. Take the number from the user and convert it into it's
binary equivalent.

EXERCISE 6
============

TWO DIMENSIONAL ARRAYS

1. Take two matrices of 3 x 3 order and add them and store in the
third matrix.

2. Take two matrices of 3 x 3 order and subtract them and store in the
third matrix.

3. Print the unit matrix of 8 x 8 order.

4. Take two matrices of 3 x 3 order and multiply them and store in the
third matrix.

5. Take one matrix of 3 x 3 order and print it in the ascending


order.

6. Take one matrix of any order and print the transpose of the
given matrix.

EXERCISE 7
============

STRINGS

1. Take two strings from the user and concatenate these two strings
using the inbuilt function.

2. Take two strings from the user and compare these two strings
whether they are equal or not using the inbuilt function.

3. Take a string from the user and print the reverse of the string
using the inbuilt function.
4. Take one string from the user and copy it into another string
variable and print the copied string.

4. Take one string from the user and check whether the given string
is palindrome or not.

6. Take two strings and check whether they are of equal length or
not.

EXERCISE 8
============

POINTERS

1. Create a variable and assign it some value then print the value
address of that variable and the value at that address.

2. Take two numbers from the user and add them using the pointers
and print the result.
(Don't use name of variables even in scanf and printf statements
only use pointers.)

3. Take two numbers from the user and swap them using the pointers.

4. Take an array of 10 numbers and sort the array in ascending order


using the pointers.
(Use only pointers, don't use array name).

6. Take the string from the user and reverse that string with the
help of the pointers.

7. Take two strings from the user and concatenate these strings
using pointers.

8. Take two strings from the user and compare these strings whether
they are equal or not using pointers.

EXERCISE 9
============

FUNCTIONS

1. Send the number into the function and print the Cube of a number
in the function itself.

2. Send the number into the function and print the Cube of a number
in the main function.

3. Send the radius of the circle in the function and print the area
area of that circle in the main function.

4. Take an array of 10 elements from the user and pass it in the


function and print it inside the function.

5. Take an array of 10 elements from the user and pass it in the


function and print square of every element in the main function.
6. Take an array of 10 elements from the user and pass it in the
function and print sorted array in the main function.

7. Take two 3 x 3 matrices from the user and send it to the


function and print the addition of the matrices in the function.

8. Take two 3 x 3 matrices from the user and send it to the


function and print the subtraction of the matrices in the function.

9. Take two 3 x 3 matrices from the user and send it to the function
and print the multiplication of the matrices in the function.

10. Take two numbers from the user and swap them in the function and print
the swapped values in the function.

11. Take two numbers from the user and swap them in the function and print
the swapped values in the main function.

EXERCISE 10
=============

STRUCTURES

1. Create the structure of a student and take all details and print
it on the screen with the help of the normal variable.

2. Create the structure of an employee and take all details and print
it with the help of the pointer variable of the structure.

3. Create the structure of a book and take all details and print
it with the help of the array varaible of the structure.

4. Demonstrate the functioning of the book shop. Take list of 5 books


from the user, then ask the user which book he wants and how many,
if the book is present display all the details of the book and the
total price of the required books, else display the message, the
book is not present.

EXERCISE 11
=============

FILE HANDLING

1. Create a file on the DOS using dos commnads and write few lines
in that file.
Read the file through a C program.

2. Create a file with the C program and read the contents with the
help of C program.

3. Create a file, write few lines in the file and the contents into
another file.

4. Generate a table of the given number and store it in the file


and read it with the help of C programme.
5. Take the input of name, age and roll of 5 students and store it
it in the file "STUD.DAT". Then print the contents of the file.

6. Create a structure of an employee containing name of employee,


id_number, and basic salary.
Store record of 5 employees and read it back on the screen.

7. Take the name of book, name of author, number of pages and price of
the book for five different books and store it in the file.
Ask the user which book he wants, then check in the file whether the
book is present, if present display all the details of the book, else
display the message, book not present.

EXERCISE 12
=============

DATA STRUCTURE

1. Create the STACK and demonstrate the operation of PUSH and POP
in it.

2. Create a structure of an employee having the name, code, designation


and the basic salary.
Store such records in the form of the SINGLY LINKED LIST.

3. Write the above program for DOUBLY LINKED LIST.

4. In the above programme list all the employees whose basic salary is
more than 5000.

5. For the above programme take the name of employee from the user
and check whether the given employee is present in the list or
not, if present display all the details, else give message
emoployee not present.

=============================================================================

You might also like