0% found this document useful (0 votes)
0 views

Coding Part

The document contains a series of programming tasks and exercises in C, covering various topics such as variable initialization, control structures, functions, data structures, file handling, and mathematical computations. Each task specifies requirements for writing C code to achieve specific outputs or calculations, with some tasks focusing on user-defined functions and structures. The exercises are designed to enhance programming skills and understanding of C language concepts.

Uploaded by

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

Coding Part

The document contains a series of programming tasks and exercises in C, covering various topics such as variable initialization, control structures, functions, data structures, file handling, and mathematical computations. Each task specifies requirements for writing C code to achieve specific outputs or calculations, with some tasks focusing on user-defined functions and structures. The exercises are designed to enhance programming skills and understanding of C language concepts.

Uploaded by

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

C programming(Coding part)

1 . For the following variable initialization (20)

int i=123; float x=25.0, y = 3.3;

write C statements to print out the above initial values in the following manner using print f function. Use field width,
precision and flag features.

(i) : 00000123:
(ii) :25
(iii) :-3.3e+00:

2 . Write a switch statement that will examine the value of an integer variable called flag and print one of the following
messages depending on the value assigned to flag. (20)

(i) Hot, if flag has a value of 1

(ii) Luke, if flag has a value of 2

(iii) Out of range, if flag has any other value.


C programming(Coding part)
3 . Price of mango is 60 Tk/kg, orange is 180 Tk/kg, and apple is 160 Tk/kg. Write a program to calculate the money a
buyer will spent for any amount of fruits in kg he bought. Read the amounts from terminal in the program. (20)

4 . Given a triangle with sides a, b, c ; whose area can be computed using the Heron's formula (20)

Provided that the following two conditions are true:

(i) a>0,b>0,c>0

(ii) a+b>c, b+c>a,c+a>b

Read the sides in the C program, check the conditions and calculate the area. Write appropriate comments if the
conditions are not met.

5 . Write a program that will generate every third integer beginning with i= 2, and continuing for all integers that are less
than 100. Calculate the sum of those integers that are evenly divisible by 5. (20)
C programming(Coding part)
6 . Given 100 integer values, write a program to create two sets, viz, set A and set B, depending on the values. If the value
is less than or equal to 65 put it into set A else put it into set B. Also, calculate the average of each set. Write necessary
print statements. (20)

7 . The combinational coefficient C(n, r) is defined as -

where 0 ≤r≤n
Write a user defined function which return factorial of a number first. Now call the UDF in main function to determine
the value of C(n,r).

8 . Every student of 2nd year Mechanical has attended 4 class tests in computer programming course. The scores of the
exam ranges from 0 to 20 for all the class test. Write a C program using arrays to calculate the total class test marks out
of 60 by taking the best three, neglecting minimum one. (20)

9 . A cricket team comprised of 15 members is formed from the 2nd year mechanical engineering students. Given the
names and roll numbers of the 15 students read from the terminal, write a program to sort them by name
alphabetically. (20)
C programming(Coding part)
10 . Define a structure consisting of a cricket players' name, batting average, total runs scored. Include the tag name
'record' within the definition. Now define a user- defined data-type called 'player' to make a records of the team
conveniently. Finally declare an array of 20 elements using the above definitions. (20)

11 . The KUET authority wants to store the information of every student. Each student has an unique ID, Name, Hall, birth
date. Choose an appropriate data structure to store the information of each student. Write a program to store and search
the information using ID as key and print the information of the required student. (20)

12 . Write a program to show a menu to create, and display a linked list. (20)

13 . The surface area and volume of a sphere can be calculated using the formulas: (20)

V =4/3πr3 A=4πr² where r = radius.

Write a program to calculate A and by passing argument as reference to a user- defined function. Use pointer concept.

14 . Write a program to create data file called 'alphabet.txt' where A to Z is written in it. Now show the ,

(i) 11th character,


(ii) last character,
(iii) alternate characters on the screen reading from the data file. (20)
C programming(Coding part)
15 . Determine the purpose of each of the following statements in a C program. Identify all input and output statements,
all assignment statements, and any other special features. (17)
Main()
{
float gross , tax , net;
printf(“Gross Salary: “);
scanf("%f",& gross);
tax=0.14*gross;
Net=gross-tax;
printf ("Taxes withheld: %.2f\n", tax);
printf(“Net saary: %.2f”,net);
}

16 . The maximum shearing stress in spring is , (17)

where m = 30, d=0.02, R= 0.075. Develop a C program for user provided value of P to calculate the shearing stress.
C programming(Coding part)
17 . Write a C program to evaluate the value of the series: (17)

assume any value of n.

18 . Write a loop in a C program that will generate every third integer, beginning with i = 2 and continuing to 100.
Calculate the sum of those integers that are evenly divisible by 5. (17)

19 . Write a C program using 2D array to compute and print the information from the data table, which shows that sales
of three items by four sales persons. (17)
(i) Total value of sales by each person
(ii) Grand total sales.

20 . Write a C program to convert lowercase string to uppercase. (17)

21 . Write a C program to find prime numbers between any two intervals using user defined function.

22 . Write a program using user defined function and structure to calculate the batting average of a cricket player after
finishing a match. Display the player's name, total run and updated average on output screen. (17)
C programming(Coding part)
23 . A C program contains following variable declarations: (17)
int i =123;
float x=12.0, y= - 3.3;
Show the output resulting from each of the following printf statement:

(i) printf(":%6d %7.0f %10.1e:\n", i, x, y):


(ii) printf(":%7.0f %#7.0f %7g %#7g: \n", x,x,y,y);
(iii) printf (":%+d +7.0f %+10.le:\n" i,x,y);

24 . Write a program to make an information database of bank customer using structure. Store the customer's name,
account number and type, current balance in the database. Distinguish between malloc and calloc function. (17)

25 . Write a program to calculate the area and perimeter of a circle by passing arguiment as reference to a user defined
function. Use pointer concept in your program. (17)

26 . Write a program to open a file named "info.doc" and store the information (Name, Roll no., CGPA) of 120 students of
your class. (17)

27 . Write a program in C using 'do-while' to read 100 numbers and calculate the average of the numbers which are
greater than 35. (16)
C programming(Coding part)
28 . Find the sun of the series: (16)

using C program.

29 . Write a function to calculate the factorial of a manber and use this function to calculate the factorial of n
numisers.(16)

30 . Write a C program that will print 10 numbers in ascending order. (16)

31 . From a list of 1000 names five character each, find how many are 'KARIM’ using C program . (16)

32 . Write a C program to reverse string. (16)

33 . Write a C function to cheek whether a number is prime. Now display the prime numbers between 2 and 50 by calling
it within a loop in the main() function. (16)

34 . Create a function to compute the area of a-ircle and use the function to find the area of 20 circles with radii given
using C program. (16)
C programming(Coding part)
35 . Write a C program ustag 20 array to compute and print the following information from the data table, which shows
the value of sales of three items by four sales persons.

(i) Total value of sales by each person,(ii) Total value of each item sold, (iii) Grand total of sales.

36 . Use recursive call to evaluate the sine of x detine by the series- (16)

Input the value of x and number of terms in your program. Compare the results with the built-in sine function.

37 . Write a C program to store information of n numbers of account holders in a bank using structure. (16)

38 . Write a C programa to read marks of students and stere it in a tite. (16)


C programming(Coding part)
39. Write a program using structure to calculate the total marks of it student. From the Corresponding marks of
attendance, class tests, and final exam marks Print a table to show the name, roll umber an total marks obtained by each
of 10 students.(16)

40 . Write a C program to find the sum of any 100 numbers which are integer and divisible by 5 only. (15)

41 . Write down a C program to get the summation of the following series, (15)

Where x and'n are provided by the user.

42 . Write a C program to get the electricity bill according to the following rates (15)

43 . Write a function to calculate the factorial of a number and use this function to calculate the finetion of 50 numbers.
(15)
C programming(Coding part)
44 . Write a C program that will print 10 numbers in descending order. (15)

45 . Write a C program to display prime numbers between twn intervals and recalculate the program using goto
statement. (15)

46 . Write a C program to multiply two nx matrix using pointer variabies, where all elements of matrices must be provided
by the user. (15)

47 . Write a C program to calculate the factorial of a number using recursion. (15)

48 . Write a C program to reverse a sentence by recursion. (15)

49 . Write a C program that will convert uppercase word to lower case word and storing the result in a file. (15)

50 . Write a source code to calculate Greatest Common Divisor by user defined function. (15)

51 . Write down a C program algorithm to find Armstrong number in an interval using user defined function. (15)

52 . Write a C program to open a file and store information (eg. roll, name, and grade) of n number of students. (15)

53 . Write a C program to reverse digits of a given number and print it in a (doc) tile. (15)
C programming(Coding part)
54 . Write a C program which will read n integer pushers and it will show the middle position and positioned data.

N.B: if n is even there are two middle numbers. (12)

55 . Write a C code which will solve the equation of ax2+bx+c=0. for any value of a, b and c. (12)

56 . Write a C program which will evaluate the series value of tan-1x . (12)

57 . Write a C program which will read a square matrix and will print the diagonal elements only. (12)

58 . A series expansion of the term ln(1+x)/e can be expressed by ,

Write a C program using tua user define function where one user define function wil evaluate the series of numerater and
other will evaluare denominator when they are called. (12)
C programming(Coding part)
59 . Write a program in C using while statement to read 100 numbers and calculate the maximum and minimum values.
(11)

60 . Write a program in C using "do-while to read 100 numbers and calculate the average of the even numbers only. (11)

61 . Given 100 numbers, write a C program to print the numbers which are less than the mean of all the values. (11)

62 . Given name of 100 persons (more than 5 characters), write a C program to print the names those begin with 'a', 'm'
and ‘z’. (11)

63 . Write a function to calculate the factorial of a number and use this function to calculate the factorial of 100 numbers.
(11)

64 . Write a program to read the name and age of 100 persons from an input file called "data.txt". Sort them in
alphabetical order and write the sorted data into "result.txt" .file. (11)

65 . Write a C program to convert unit year , Months , days, hours, minutes and seconds. For example, if 176523 seconds is
given as input, the required output will be 2 days 1 hour 2 minutes and 3 seconds. (11)

66 . Write a C program using pointer variable to find the transpose of matrix A (n x m). (11)
C programming(Coding part)
67 . Write a FORTRAN progrant to sum the series 1+1+2+3+5+8... Up to n terms. (11)

68 . Given 1000 values lying between 0 and 100. Write a FORTRAN program to sort the value into a frequency distribution
with five equal class interval. (11)

You might also like