Docsity

Frequently Asked Question for C Programming, Exercises of C programming

Toggle sidebar
bg1
LAB SHEET:- 1
1.WAP to print the “Hello world” on the screen.
2.WAP to print the name, address and roll no. on the screen. (Use different escape sequences to format the output on the
screen like: \n, \t).
3. WAP to find sum, difference, product and division (quotient & remainder) of two any numbers and display the results.
4.WAP to convert temperature given in Fahrenheit to Celsius. [C/100= (F-32)/180].
5.WAP to calculate the area of circle.(without taking input from the user)
6. WAP to input the radius of a circle, and calculate the area and circumference of the circle.
7. WAP to input the length & breadth of a rectangle, and calculate the area of the rectangle.
8. WAP to input principle amount, no. of years and rate of interest from user and calculate the simple
interest.[SI=PNR/100]
9.WAP to input the temperature from the user and convert temperature given in Fahrenheit to Celsius. [C/100= (F-
32)/180].
10. WAP to input the values of a & b and calculate the cube of (a + b).
11. WAP to input the radius and height of the cylinder and find the total surface area.[S=2 * PI * r * (r + h)]
12. WAP to read three sides of a triangle. Calculate the area.
[Hint: ∆2= s(s-a) (s-b) (s-c), 2s= (a + b + c)]
13. Find the square root of a number given by user.
[Hint: Use function sqrt (variable name) and #include<math.h>]
14. WAP to read and b. Calculate (ab), a to the power b.
[Hint: Use function pow(variable name, power), and #include<math.h>]
15. WAP to calculate compound interest for the given principle, no. of years and rate of interest.[Hint:
n
C=P[(1 + r/100) -1] ]
16. WAP to exchange two numbers.
17. WAP to calculate: [A] (a + b) / (c + d) [B] √(a b) / ( c + d ) [C]
[D] ( ( a + b ) / c ) / ( a-( b / d ) )
5
( (a-b) /(c*c*d) )
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Frequently Asked Question for C Programming and more Exercises C programming in PDF only on Docsity!

LAB SHEET:- 1

1. WAP to print the “Hello world” on the screen. 2. WAP to print the name, address and roll no. on the screen. (Use different escape sequences to format the output on the screen like: \n, \t). 3. WAP to find sum, difference, product and division (quotient & remainder) of two any numbers and display the results. 4. WAP to convert temperature given in Fahrenheit to Celsius. [C/100= (F-32)/180]. 5. WAP to calculate the area of circle.(without taking input from the user) 6. WAP to input the radius of a circle, and calculate the area and circumference of the circle. 7. WAP to input the length & breadth of a rectangle, and calculate the area of the rectangle. 8. WAP to input principle amount, no. of years and rate of interest from user and calculate the simple interest.[SI=PNR/100] 9. WAP to input the temperature from the user and convert temperature given in Fahrenheit to Celsius. [C/100= (F- 32)/180]. 10. WAP to input the values of a & b and calculate the cube of (a + b). 11. WAP to input the radius and height of the cylinder and find the total surface area.[S=2 * PI * r * (r + h)] 12. WAP to read three sides of a triangle. Calculate the area. [Hint: ∆2= s(s-a) (s-b) (s-c), 2s= (a + b + c)] 13. Find the square root of a number given by user. [Hint: Use function sqrt (variable name) and #include<math.h>] 14. WAP to read and b. Calculate (ab), a to the power b. [Hint: Use function pow(variable name, power), and #include<math.h>] 15. WAP to calculate compound interest for the given principle, no. of years and rate of interest.[Hint:

C=P[(1 + r/100)^ n -1] ]

16. WAP to exchange two numbers. 17. WAP to calculate: [A] (a + b) / (c + d) [B] √(a b) / ( c + d ) [C] [D] ( ( a + b ) / c ) / ( a-( b / d ) )

( (a-b) /(ccd) )^5

18. A computer manufacturing company has the following monthly compensation policy to their sales person: Minimum base salary=1500. Bonus for every computer sold=200. Commission on the total monthly sales=2% Since the prices of computers are changing, the sales price of each computer is fixed at the beginning of every month. Given the base salary, bonus and commission rate, the inputs necessary to calculate the gross salary are, the price of each computer and the number sold during the month. The gross salary is given by the equation: Gross salary = Base salary + (quantity * bonus rate) + (quantity * price) * commission rate. 19. In inventory management, the economic order quantity for a single item is given by: EOQ =√ (2* demand rate * setup costs)/ (holding cost per item per unit time) And the optional time between orders is given by: TBO = √ (2 * setup costs)/ (demand rate * holding cost per item per unit time) WAP to compute EOQ and TBO, given demand rate, setup costs and the holding cost. 20. The straight- line method of computing the yearly depreciation of the value of an item is given by: Depreciation = (Purchase price-salvage value) / Years of service. 21. Solve the quadratic equation A x^2 + b x + c=0. [Assume all roots are real only]

LAB SHEET:- 2

1. WAP to read a 3 digit no. and print each digit separately. 2. WAP to read four digit no. & print the sum of each digit. 3. WAP to read 3 digit no. & find sum of square of digits. 4. WAP to read 3 digit no. & find if it is palindrome or not. Hint: use ternary operator. 5. WAP to read no. of days & print in terms of year, months & days. 6. WAP to read total no. of seconds and print it in hours, minutes and second. 7. WAP to read a no. & find out if it is Armstrong no. or not. Hint: N=a^3 +b^3 +c^3 8. WAP to input two points A(x1,y1) & B(x2,y2) and find the distance between them. Hint: AB= sqrt [ (x1-x2)^2 - (y1- y2)^2 ]. 9. WAP to input the coefficient of simultaneous equation and find the values of x, y.

15. WAP to read Annual Salary of an employee and decide tax withheld as follows: Salary tax Up to 100000 0% Up to 150000Above 150000 15%25% LAB SHEET:-4 (Looping)

  1. WAP that prints the numbers from 201 to 300(use while loop, do while loop, for loop).
  2. WAP that finds the sum of odd numbers from 0 to 100.(use do- while loop) i.e. sum=1+3+….+
  3. WAP which display the average & sum of nth no input by the user.
  4. WAP to read a number and display the multiplication table of that number.
  5. WAP that reads two numbers x and y from user and calculates the value of x to the power y. (while loop, for loop)
  6. WAP that reads a number (n) from user and calculates the factorial of that number.(using while, for)
  7. WAP that checks whether the given number(x) is prime or not.[Hint: prime no. is that number which is NOT divisible by numbers other than 1 and itself. (Using while, for)
  8. WAP to solve the quadratic equation.
  9. WAP to input the number and find the sum of each digits of number.
  10. WAP to read number and find whether the given number is Armstrong or not.
  11. WAP to read a number and find whether the given number is palindrome or not.
  12. WAP to find the leap year between 1900 and 2000.
  13. WAP to accept any number „n‟ and print the cube of all numbers from 1 to n which is exactly divisible by 3. 14.WAP to find all the prime numbers between 1 to 100. 15.WAP to find all the Armstrong number between 100 to 500. 16.WAP to read the age of 20 persons and count the number of persons in the age group 50 to 60. 17.WAP to generate the Fibonacci series.[0 1 1 2 3 5 8………….]
    1. WAP that generates the multiplication as shown below. [Use nested looping] (Using while, for) 1 2 3 4 5 6 7 8 9 10 2 4 6 7 8 10 14 16 18 20 …………………………………
  1. WAP to generate the following output

a) 1 12 1 2 3 1 2 3 4 1 2 3 4 5

b) 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 c) 1 1 0 1 0 1 1 0 1 0

d)




e)



Lab Sheet for BCA II Sem. for GM College Prepared by Krishna Acharya[BCA/MCA] 2011

d) to find if the given no. is palindrome or not.

13. WAP that calls a function whose name is power(). This function takes two arguments(x and y) and returns the value of x to the power y. 14. WAP that use a function called isprime(). This function takes a no. as an argument and returns either 0 or 1. The function returns 1 if the given argument is prime otherwise 0. 15. WAP that calls a function whose name is mul(). This function takes one argument(x) and prints the multiplication table of that no. 16. WAP that use a function called factorial(). This function takes a no. as an argument and returns the factorial value of that no. 17. WAP that use function swap two given values. The swap() should returns nothing (void). Hint: use (a)call by value and (b) call by reference. Recursive Method 18. WAP to find the factorial of the no. using recursive function. 19. WAP to find the sum of given non-negative integer using a recursive function. 20. WAP to find the value of x to the power y using recursive function. 21. WAP to print “Hello” „n‟ times using recursive function.

LAB SHEET:-6 (array)

1.WAP to enter values in array called myarray of size 15 and display the elements of array. 2.WAP to sum and average of all the elements of array. 3.WAP to add two arrays and put in third array. 4.WAP to find largest and smallest element in an array. 5.WAP to print Fibonacci series. 6.WAP to separate odd and even elements of array.

7.WAP that initialize ten numbers and search the key (a number given by the user)from the list .If the key is found then it displays the index(subscript of an array)otherwise it displays the proper message i.e. "key is not found". 8.WAP to sort the given list of numbers. 9.WAP that reads two matrices of size NN and prints the sum and difference of those matrices. 10.WAP that reads two matrices of size NN and prints the product of those matrices.

11.WAP that reads a matrix and identify if the given matrix is symmetric or not.(array contd with functions)

1.WAP to read arry of 10 no.s and display it using array and function. 2.WAP to read array of 5 no.s and display: (a) the largest no. using function and array. (b) the smallest no. using function and array. 3.WAP to read two arrays, add two array and store the result in third array and print it using function. 4.WAP to read an array and sort it in ascending order. 5.WAP to read age of 'n' students and display the second lowest age.(array contd. with 2d and 3d matrix)

1.WAP to input a 2d matrix and print it. 2.WAP to input two 2d matrix, add, subtract and print it. 3.WAP to input two 2d matrix, multiply and print it. 4.WAP to find transpose of 2d matrix. 5.WAP to input a 3d matrix and print it LABSHEET-7(Pointers)

1.WAP using pointer to compute sum and average of elements of array. 2.(a)WAP that takes two numbers from user and evalutes the sum,difference and product using pointer. (b)WAP that takes two numbers from user and evalutes the sum,difference and product using pointer and function. 3.WAP using DMA and pointer to read n numbers from user and display sum and average. 4.(a)WAP to find largest and smallest number from list of number using pointer. (b)WAP to find second and third largest number using pointer. 5.(a)WAP to sort n numbers in ascending order using pointer. (b)WAP to sort n numbers in ascending order using pointer and function. 6.WAP to sort n numbers in ascending order using DMA and function. 7.WAP to merge two sorted array into third array using pointer. 1.WAP to read 2D-array (size 33) using pointer and diaplay it. 2.WAP to read two matrix of(size 33),add it and store in 3rd marix using pointer& function. 3.WAP to read two matrix of(size 33),multiply it and store in 3rd marix using pointer& function. 4.WAP to read 3D-array of size 22*2 and print it.

2.WAP to read a record of 5 students and print the records of student according to the roll number (in ascending order). The record should include:Name,Age,Roll no. 3.Repeat the Question no.1 and print the record according to name in alphabetical order. 4.WAP to make nested structure.put a structure(date of birth) within structure record. 5.WAP to pass a structure to a function. 6,WAP to read record of 5 employee of an office and print the record of person who have 2nd higest salary.

1.WAP to make a record of 5 students & print.(name,roll,age) 2.WAP to make record of 5 student.(name,follno marks of 3 subjects &print total) 3.WAP to make nested structure .put structure DOB within 1st structure. 4.WAP to read record of 5 employee & print the record of person which have highest & lowest salary.(Include:name,salary,address) 1.WAP to make a record of a a student using pointer to structure.( p->name,(*p).name) 2.WAP to make a record of 5 students using structure array and pointer. 3.WAP to use pointer as a member of structure. 4.WAP to pass structure to function (no pointer). 5.WAP to pass structure to function using pointer. Lab 10(files) 1.WAP to read character from keyboard and store in file, read it from file and display it on the screen 2.WAP to read character until the enter key is pressed and change all character to upper case and display it. 3.WAP to read name and age from the user in the user defined file and print it. 4.WAP to copy characters from one file to another file.

(1)WAP to read a simple structure and put it into a file and display on screen. (2)WAP to make a record and put it into a file and display on screen. (3)WAP to make menu-based program using file to append,read,delete data in file. Use switch for append,read,delete,quit.

Candidates are required to give their answers in their own words

as far as practicable. Figure in the margin indicate Full marks.

Attempt any two Questions 2X12=

1. What is array? Write a program to input name, rollno, and

1. Result [pass or failed] based on marks. if marks Greater

than 40 in each subject considered as passed else failed.

2. Grade is based on percentage.

Per grade

>=80 A

>=60 and <80 B

>=50 and <60 C

>=40 and <50 D

2. Write a program to create a structure cricketer with name,

country, bat_avg, ball_avg property and input data for ‘n’

players then display the information of top 10 cricketer based

on their batting average in descending order.

3. Write a menu driven program with following menu option.

****************My Menu*******************

1. Add Record.

2. Display all Records

3. Search a Record

4. Exit

Enter your Choice [1...4]

Criteria:

1. While user select option 1 it should stored the

information into data file called student.dat in append

mode.

2. While user select option 2, it should display all record

in screen reading from file if not available then sensible

message should be displayed like “Record does not

exist”

3. While user select option 2, it should able to search the

item and display into screen.

4. Option 4 is to exit program.

Group B

Answer any six 6X6=

4. What do you mean by operator? Discuss the different types of

operator with example.

5. Differentiate between iteration and recursion. Write a program to

calculate sum of following series with use of recursion for

factorial.

X+X^2 / 2! +X^3 /3! + ………………. +n term.

6. Differentiate between function call by value and function call

by reference with suitable diagram and list down the

disadvantage of pointer.

7. Write a program to input line of text and then count the

following with use of pointer.

1. Number of alphabets

2. Number of vowels.

3. Number of consonants.

4. Number of digits

5. Number of space

6. Number of special characters.

8. What do you mean by static and dynamic memory management

in c programming? Write a program to find out the minimum

and maximum of number from list of 15 items using DMA.

9. Write a program for following output.

Bachelor of Computer Application (BCA)/First semester/End-term

Examination

Time: 3:00 Hrs. Full marks: 60/Pass: 24

Subject: C programming

marks in five subjects into arrays and calculate total,

percentage, result, grade and display corresponding result into

screen. It should obey the following rules.

xyz Multiple College 2013

BscCSIT 1stSem