# C Language Best Practice Set All Questions C Language Best Practice Set All Questions

# C Programming problems exercises for Beginners

## C Language Practice Set 1 Questions with Answers

Q 1. Write a program area of the rectangle through user input.

 #includeint main(){    int length=3; int breadth=8;    int area = length*breadth;    printf("The area of this rectangle is %d:", area);    return 0;}

Q 2. Write a program to calculate the area of a circle and modify the same program to calculate the volume of a cylinder given its radius and height.

 #include int main(){    int radius = 3;    float pi = 3.14;    printf("The area of this circle is %f\n", pi * radius * radius);    int height = 3;    printf("Volume of this cylinder is %f\n", pi * radius * radius * height);    return 0;}

Q 3. Write a program to convert calculus(centigrade degree temperature to Fahrenheit)

 #includeint main(){    float celsius = 37, far;    far = (celsius * 9 / 5) + 32;    printf("The value of this celsius temperature in Fahrenheit is %f", far);    return 0;}

Q 4. Write a program to calculate simple interest for a set of values representing principle, no of year, and rate of interest.

 #includeint main(){    int principal=100, rate=4, years=1;    int simpleInterest = (principal * rate * years)/100;    printf("The value of simple Interest is %d", simpleInterest);    return 0;}

## C Language Practice Set 2 Questions with Answers

Q 1. Which of the following is invalid in c?

(a) int a; b=a;

(b) int v=3^3;

(c) char dt=21 dec 2022;

Q 2. What data type will 3.0/8-2 return?

Q 3. Write a program to check whether a number is divisible by 97 or not.

Q 4. Explain step by step evaluation of 3*x/y-z+R where x=2, y=3 z=3,R=1

Q 5. 3.0+1 will be?

(a) integer number

(b) floating point number

(c) character

## C Language Practice Set 3 Questions with Answers

Q 1. What will be the output of this program?

int a=10;

if(a=11)

printf("i am 11");

{

printf(" i am not 11");

}

Q 2. Write a program to find out whether a student is pass or fails if the required total of 40% and at least 33% in each subject passes.

Assume 3 subjects and take marks as input from the user.

Q 3. Calculate income tax paid by an employee to the government as per the sales maintained below?

Income  Sales  Tax

2.5L     50.L   5%

5.0L     10.0L  20%

Above    10.0L  30%

Note: There is no tax below 2.5L. Take the income amount as input from the user.

Q 4. Write a program to find whether a year entered by the user is a leap year or not. Take a year as input from the user.

## C Language Practice Set 4 Questions with Answers

Q 1. Write a program to print multiplication take of a given number n.

Q 2. Write a program to print multiplication take of 10 in reverse order.

Q 3. a do while loop is executed:

(a) At least once

(b) At lease Twice

(c) At most once

Q 4. What can be done using one type of loop can also be done using the other two types of loops true or false.

Q 5. Write a program to sum the first ten natural numbers using a while loop.

Q 6. Write a program to implement program 5 using for and do while loop.

Q 7. Write a program to calculate the sum of the numbers occurring in multiplication take of 8(consider 8x1 to 8x10).

Q 8. Write a program to calculate the factorial of a given number using for loop.

Q 9. Repeat 8 using while loops

Q 10. Write a program to check whether a given number is prime or not using a loop?

Q 11. Implement 10 using other types of loops.

## C Language Practice Set 5 Questions with Answers

Q 1. Write a program using a function to find the average of their numbers.

Q 2. Write a function to convert the Celcius temperature into Fahrenheit.

Q 3. Write a function to calculate force attraction on a body of mass earth (g=9.8 m/s2).

Q 4. Write a program using recursion to calculate the nth element of the fabinachi series.

Q 5. What will the following line produce is a C program:Printf("%d%d%d\n",a,++a,a++);

Q 6. Write a recursion function to calculate the sum of first natural numbers.

Q 7. Write a program using functions to print the following pattern(first n lines).

*

* * *

* * * * *

## C Language Practice Set 6 Questions with Answers

Q 1. Write a program to print the address of variables. Use this address to get the value of this variable.

Q 2. write a program having a variable i.print the address of i. Pass the variable to function and print its address.

Q 3. Write a program to change the value of a variable to 10 times its current value. Write a function and pass the value by reference.

Q 4. Write a program using a function that calculates the sum and average of two numbers. Use pointers and print the values of the sum in main().

Q 5. Write a program to print the value of variable I by using the "Pointer to Pointer" type of variable.

Q 6. Try the problem using call by value and verify that it does not change the value of the said variable.

## C Language Practice Set 7 Questions with Answers

Q 1. Create an array of 10 numbers verify using pointer arithmetic that(ptr+2) points to the third element where ptr is a pointer pointing to the first element of the array.

Q 2. If s is a 1-D array of integers then *(s+3) refers to the third element:

(a) True

(b) False

(c) Depends

Q 3. Write a program to create an array of 10 integers and store multiplication take of 5 in it.

Q 4. Repeat problem 3 for a general input provided by the user using scanf.

Q 5. Write a program containing a function that reverses the array passed to it.

Q 6. Write a program containing a function that counts the number of positive integers in an array.

Q 7. Create an array of size 3x10 containing multiplication takes of the numbers 2,7 and respectively.

Q 8. Repeat problem 7 for a custom input given by the user.

Q 9. Create a 3-D array and print the address of its elements in increasing order.

## C Language Practice Set 8 Questions with Answers

Q 1. Which of the following is used to appropriately read a multi-word string

(a) puts()

(b) gets()

(c) printf()

(d) scanf()

Q 2. Write a program to take a string as input from the user using %c and %s to confirm that the string is equal.

Q 3. Write your own version of the strlen function from <string.h>

Q 4. Write a functioning slice() to slice a string. It Should change the original string such that is now the sliced string. Take m and n as the start and end positions for the slice.

Q 5. Write your own version of the strcpy function from <string.h>

Q 6. Write a program to encrypt a string by adding 1 to the Asci value of its characters.

Q 7. Write a program to decrypt the encrypted using encrypt function in problem 6.

Q 8. Write a program to count the occurrence of a given character in a string.

Q 9. Write a program to check whether a given character is present in a string or not.

## C Language Practice Set 9 Questions with Answers

Q 1. Create a 2-D vector using structure in C.

Q 2. Write a function sum vector that returns the sum of two vectors passed to it. the vectors must be 2-D.

Q 3. 20 Integers are to be stored in memory what will you prefer-array or structure.

Q 4. Write a program to illustrate the use of the arrow operator-> in C.

Q 5. Write a program with a structure representing a complex number.

Q 6. Create an array of 5 complex numbers created in problem 5 and display them with the help of a display function. The Values must be taken as input from the user.

Q 7. Write a problem structure using the typedef keyword.

Q 8. Create a structure representing a bank account of a customer. what fields did you use and why?

Q 9. Write a structure capable of storing data. write a function to compare those dates.

Q 10. Write a problem for time using the typedef keyword.

## C Language Practice Set 10 Questions with Answers

Q 1. Write a program to read their integer from a file.

Q 2. Write a program to generate a multiplication take of a given number in text format. Make sure that the file is readable and well formatted.

Q 3. Write a program to read a text file character by character and write its content twice in a separate file.

Q 4. Take the name salary of to employees as input from the user and write them to a text file in the following format:

name1=3300

name2=3700

Q 5. Write a program to modify a file containing an integer to double its value.

## C Language Practice Set 11 Questions with Answers

Q 1. Write a program to dynamically create an array of size 6 capable of storing 6 integer numbers using calloc

Q 2. Create an array dynamically capable of storing 5 integer numbers. use realloc so that it can now store 10 integers number.

Q 3. Create an array of multiplication take of 7 upto(7x10=70). use realloc to make it store 15 numbers(from 7x1 to 7x15).

## Learn Others Programming Language

👉C Language

👉C++ Language

👉Java Language

👉Python Language

👉Php Language