Ad Code

Responsive Advertisement

Model questions for c programming

Basics:

1.1. What is the purpose of the main function in a C program?

1.2. Explain the difference between a compiler and an interpreter in the context of C programming.

1.3. How do you comment out multiple lines of code in C?

2. Variables and Data Types:

2.1. Declare an integer variable num and assign the value 42 to it.

2.2. What are the basic data types in C? Provide examples for each.

2.3. Explain the difference between int and float data types.

3. Input and Output:

3.1. How can you take user input in C?

3.2. Write a C program to read two integers from the user and print their sum.

3.3. What is the printf function used for, and how do you format output using it?

4. Control Structures:

4.1. Write a C program that checks if a given number is positive, negative, or zero.

4.2. What is the purpose of the if-else statement in C? Provide an example.

4.3. Explain the purpose of a switch statement in C and provide an example.

5. Loops:

5.1. Write a C program to print the numbers from 1 to 10 using a for loop.

5.2. What is the difference between while and do-while loops in C? Provide examples.

 

5.3. How can you use the break and continue statements in a loop?

6. Functions:

6.1. Define a function in C that takes two integers as parameters and returns their product.

6.2. What is a function prototype, and why is it necessary?

6.3. Write a C program that uses a function to find the maximum of three numbers.

7. Arrays:

7.1. Declare an integer array numbers with 5 elements and initialize it with values 10, 20, 30, 40, and 50.

7.2. How do you access elements in an array in C?

7.3. Write a C program to calculate the average of the elements in an array.

8. Pointers:

8.1. Declare a pointer variable in C and explain its purpose.

8.2. Write a C program that swaps the values of two integers using pointers.

8.3. What is the difference between pass by value and pass by reference in function arguments?

9. Strings:

9.1. How are strings represented in C? Explain the concept of null-terminated strings.

9.2. Write a C program to find the length of a string without using any library function.

9.3. Implement a function in C to concatenate two strings.

10. File Handling:

 

10.1. How can you open a file in C for reading and writing?

10.2. Write a C program that reads text from one file and writes it to another.

10.3. Explain the purpose of file modes like "r," "w," and "a" when opening files. 

Post a Comment

0 Comments