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

C Programming Assignment PDF

The document outlines a comprehensive programming assignment focused on C programming. It includes a variety of tasks such as finding the largest number, performing arithmetic operations, converting units, calculating salaries and bonuses, and implementing data structures like arrays and strings. Additionally, it covers advanced topics like file handling, command line arguments, and graphics programming.

Uploaded by

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

C Programming Assignment PDF

The document outlines a comprehensive programming assignment focused on C programming. It includes a variety of tasks such as finding the largest number, performing arithmetic operations, converting units, calculating salaries and bonuses, and implementing data structures like arrays and strings. Additionally, it covers advanced topics like file handling, command line arguments, and graphics programming.

Uploaded by

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

Programming Assignment

C PROGRAMMING
1. Write a program to find the largest number between two numbers using
Ternary operator.
2. Write a program, which take two values, and print their sum.
3. Write a program, which take two values, and print their Multiplication.
4. Write a program, which take two values, and print their sum of their square.
5. Write a program, which take three values, and print Max. Value (use Ternary
Operator)
6. Write a program to convert kilogram into Grams.
7. Write a program to convert inches into centimeters.
8. Write a program that accept Basic salary of employee and compute the bonus
@20% of Basic. Print Bonus and gross salary too.
9. Write a program, which accept length and breadth of a rectangle and print
the Area and perimeter of it.
10. Write a program, which accept the arm of triangle and print the Area and
perimeter of it.
11. Write a program to read following numbers from your keyboard, round them
to their nearest integer and print the result in integer format.
37.5 50.123 -25.5649 -56.8877 123.0

12. Write a program that accept sale price and cost price and find the profit and
loss.
13. Write a program to accept a four digit number and print the sum of first and
last digit and product of mid digits.
14. Write a program to accept the time in 24 hour format and print message
according to time. Like(good morning ,good evening, good afternoon, good
night)
15. Write a program to accept a number <10 print its in word , e.g.
1=>.One,2=>Two
16. Write a program to accept a character and convert it Upper case to Lower
case and lower to upper.
17. Write a program to accept a character from user and process it like this:
a. If character is alphabets then print next successive character e.g. a then b, x
then y, z then a.
b. If it is not alphabets then print that character as is:
18. Write a program to accept the basic salary of an Employee and
Calculate the gross and Net pay as per following rules.
Basic HRA DA CA PF
4500 to 6000 @12% @33% @15% @9%
6001 to 7000 @15% @33% @18% @9%
7001 to 8000 @17% @33% @20% @9%
8001 to 10000 @20% @33% @25% @9%

19. Write a program to accept the percentage of marks of student and


evaluate the grade as per following rules:
Percentage >=85 ----------------------------------- grade=‟S‟

Percentage>=75 and percentage<85 grade=‟A‟

Percentage>=65 and percentage<75 grade=‟B‟

Percentage>=55 and percentage<65 grade=‟C‟

Percentage>=50 and percentage<55 grade=‟D‟

Percentage>=0 and percentage<50 grade=‟F‟


20. Write a program to find all composite and prime no between 1 to 100
21. A post office charges parcel senders according to the weight of the
parcel.
For each parcel charges weighting 2Kg or less the charge is Rs. 32.50 and for
each Kg of part of there is an additional charge of Rs. 10.50. Calculate charges
after accepting weight of the parcel.

22. Write a program, which will accept the no of units of calls made and print the
amount payable, using following condition. First 200 calls are Free.

Next 300 calls are @ 1 Rs. /unit.

And rest calls are @ 2 Rs. /unit.

23. Write a program, which will accept the amount and compute the net amount
for the purchase made. The program must calculate the discount given on
these purchase and display the net customer has to pay. The Discount rates
are follows:
Amount Discount

>100 & <200 5%

>200 & <400 10%

>400 & <800 20%

>800 25%
24. Write a program, to compute the wage of labor (working on the daily basis) as

per the Following wage structure.

Hours Worked Rate Applicable

Up to first 8 Hours Rs. 50.00

For next 4 Hours Rs. 10.00 per hour


extra

For next 4 Hours Rs. 20.00 per hour


extra

For next 4 Hours Rs. 25.00

per hour extra For next 4 Hours

Rs. 40.00 per hour extra

The output of the program should be like this:

Enter the Name of Employee: XXXXXXXX

Enter the total hours worked: 99

Total Wage: 9999.99

Loops
1. Write a program to print the following series :
a) 1,2,3,4,5,6 ----------------------------------up to N
b) 1,4,9,16,25----------------------------------up to N
c) 0,2,6,12,20----------------------------------up to N
d) 0,1,1,2,3,5,8,13---------------------------- up to N
e) 1,8,27,64------------------------------------up to N
f) 1,2,4,7,11,16------------------------------- up to N
2. Write a program to print ASCII value of a given character.
3. Write a program to print table of a given number.
4. Write a program to print the sum of even position & product of odd position
digit of any inputted Number.
5. Accept a Number from user and find reverse of it.
6. Accept a Number from user and check whether it is Prime or Not.
7. Accept a Number from user and check whether it is Palindrome or Not.
8. Accept a Number from user and check whether it is Armstrong or Not.
9. Write a program to print all Odd numbers from 1 to N terms 10. Write a
program to print all Even numbers from 1 to N terms
11. Write a program to find Factorial of a given number.
12. Write a program to print the sum of digit of any inputted Number.
13. Write a program to print the product of digit of any inputted Number.
14. Write a program to calculate total no of digit in a given number.
15. Accept a Number from user and check whether it is Perfect No. or Not.
(A perfect number is a number which factor‟s sum is equals to Number e.g
6 (3+2+1))

16. Accept a Number from user and print its equivalent Binary Number.
17. Accept a Number and Base from user and print its equivalent Base Number.
18. Print the table form n1 to n2 (n1(starting point) and n2(ending point) )
19. Write a program to print all factors of a given Number.
20. Write a program to print all prime number form 1 to 100
21. Write a program to print all Armstrong number form 1 to 100
22. Write a program to print all Perfect number form 1 to 100
23. Write a program to accept a number and print it in Words. E.g 125 as One
Two Five.
24. Write a program to print the following Triangle up to n terms:
*
**
***
25. Write a program to print the following Triangle up to n terms:
***
**
*
26. Write a program to print the following Triangle up to n terms:
*
***
*****
27. Write a Program to print the following triangle.

*****
***
**
*
28. Write a program to print the following Triangle

A
ABA
ABCBA
ABCDCBA

29. Write a program to print the following Triangle up to n terms:

1
1 1
1 2 1
1 3 3 1
1 4 6 4 1

30. Write a program to print the following Triangle up to n terms:

1
121
12321
1234321
123454321

Array and String


1. Write a program to read 10 Element in an array and print them.
2. Write a program to read N Element in an array and print them.
3. Write a program to read 10 Element in an array and print greatest and
smallest among them.
4. Write a program to read 10 Element in an array and count all even and
odd.
5. Write a program to read 10 Element in an array and print in reverse
order.
6. Write a program to reverse an array and after print it.
7. Write a program to read 10 Element in an array and sort it in ascending
order using Bubble sort. 8. Write a program to read 10 Element in an array and
sort it in ascending order using Selection sort. 9. Write a program to read 10
Element in an array and sort it in Descending order using Bubble sort. 10. Write
a program to read 10 Element in an array and sort it in Descending order using
Selection sort.
11.Write a program to read 10 Element in an array and print 2nd greatest and 2nd
smallest among them.
12.Write a program to read value in 2 matrix and print their Sum and Minus.
13.Write a program to read value in a matrix and print its value along with its
Row Total , Column Total and whole Total.
14.Write a program to read value in two Array A and B and put common
elements in to third Array C. and also print all array.
15.Write a program to read value in two Array A and B and merge elements into
third Array C in ascending order. and also print all array.
16.Write a program to read value in two Array A and B and merge elements into
third Array C in Descending order. and also print all array.
17.Write a program to read 10 values in integer array and print all value stored
at even position.

STRING
1. Write a program to input String using following functions and print it.
a) scanf() b) gets() c) at declaration time
2. Write a program to read a String and print its length (without using library
function)
3. Write a program to read a string and copy it into another string.(Do not use
Library Function) 4. Write a program to read two String and concatenate
it.(without using library function)
5. Write a program to print given string in reverse order.
6. Write a program to read a string and a character. After that print the final
string by replacing all vowel characters of the string with given character.
7. Write a program to count the following in a given sentence.
[A] Upper case character [B] Lower case character

[C] Digits [D] Vowels

[E] Space character [E] Words

[F] Lines [G] Consonant


8. Write a program to count number of occurrences of each character in the
given string. if input is : “BANANA” then output will be following.

B1

[A] 3

N 2
9. Write a program to remove all extra spaces in a given String.
10. Write a program to sort given string in ascending order.
11. Write a program to sort given string in descending order.
12. Write a program to find the No. of Characters with space and without space in
a given String.
13. Write a Program that read Name of Person and print it in following Format.
If User Input “
Sabab Ali Khan” then it Print :
[A] S.A.K. [B] S.A.Khan [C] Khan S.A.

Structure And Union


1. Write A Program to define a structure with Members : Name,Address and
Mob No. of a person. Now Create it‟s Variable, read records and print it.
2. Write A Program to define a Union named Size with Members : int nsize ,
char csize[5] . Now
Create it‟s Variable, read Shirt Size and print it.
3. Write a Program to Create an array of structure. And Store and print 5
records of student.

FUNCTION
1. Write a Function that take 2 numbers and return smaller Value.
2. W.A.F. that take 2 numbers and return larger Value.
3. Write a recursive Function for calculate Factorial of a received Number. And
return to the calling function.
4. Write a recursive Function for Binary search.
5. W.A.F. that takes an integer type array of size 10 and return the greatest
number.
6. W.A.F. that takes an integer type array of size 10 and return the smallest
number.
7. W.A.F. that takes an integer type array of size 10 and return Sum of All
numbers.
8. W.A.F. that takes an integer type array of size 10 and return Sum of All Even
numbers.
9. W.A.F. that takes an integer type array of size 10 and return Sum of All ODD
numbers.
10. W.A.F. that takes an integer type array of size 10 and return Sum of All Even
position‟s numbers.
11. W.A.F. that takes an integer type array of size 10 and return Sum of All ODD
position‟s numbers.

POINTER
1. Write a Function that receive the base address of integer type array and print
their values using Pointer.
2. Write a Program that receive a String and print it in reverse Form using
Pointer.
3. Write a Function that receive the base address of integer type array and print
greatest value using Pointer.
4. Write a Function that receive the base address of integer type array and print
Smallest Value using Pointer.
5. Write a Function that receive the Last Block address of integer type array and
print their values using Pointer in Reverse Order.
6. Write a Function that receive the base address of integer type array and print
Sum of All values using Pointer.

FILE HANDLING

1. Write a program to display content of file on screen. File name given by user
2. Write a program to display content of Specified file on screen in the following
way.
[A] Upper Case [B] Lower Case [C] Title or Proper Case

3. Write a program to Create and display content of file on screen. File name
given by user
4. Write a program to display No. of Line, Space, Non- Alphabet, Alphabet of
file on screen. File name given by user.
5. Write a program that accept two file names first as a Source and second as
destination then copy first file content in second file.
6. Write a program to Combine two file content into Third file.
7. Write a program to Combine two file content into third file. And also add Line
Number at beginning of each line.
8. Write a program to print 1 to 100 and redirect output in a file.
9. Write a program that accept two file names first as a Source and second as
destination then copy first file content in second file in reverse Order.
10. Write a program to find out the size of given file.
11. Write a program to print Nth character of a file. Value of N is given by user.

COMMAND LINE ARGUMENT


1. Write a program to display No. of argument and value passed to main()
function using command line argument.
2. Write a program to read 1 Number as a command line argument and check
for even/Odd.
3. Write a program to read 1 Number as a command line argument and check
for Prime.
4. Write a program to read 1 Number as a command line argument and check
for Palindrome or Not.
5. Write a program to read 2 Number as a command line argument and print
their Sum.
6. Write a program to read 3 Number as a command line argument and print
the greatest number using Ternary Operator.

Graphics Programming
1. Write a program to draw a line from upper left to center of the screen.

2. Write a program to draw the following in center of the screen with orange
color.

3. Write a program to draw the following… that animate from one point to another.
4. Write a program to draw the following 3-D ractangle…

5. Write a program that draw the following TEXT on Center of the screen that change color
of TEXT for each 2 second.

You might also like