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

Programming in C_aarya

The document outlines important questions and programming tasks related to C language fundamentals, including operators, control statements, arrays, strings, functions, structures, pointers, and file handling. Each module contains specific exercises aimed at reinforcing concepts such as data types, program structure, and storage classes. The questions encourage practical coding skills through examples and program implementations.

Uploaded by

disalfinksunny
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Programming in C_aarya

The document outlines important questions and programming tasks related to C language fundamentals, including operators, control statements, arrays, strings, functions, structures, pointers, and file handling. Each module contains specific exercises aimed at reinforcing concepts such as data types, program structure, and storage classes. The questions encourage practical coding skills through examples and program implementations.

Uploaded by

disalfinksunny
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

PROGRAMMING IN C (Important questions)

Module 1 – C Fundamentals and Control Statements

1. List and explain the different types of operators in C with examples


(Arithmetic, relational, logical, assignment, bitwise, unary, conditional, etc. Show
how they work in expressions.)
2. Convert a nested if-else structure into a conditional (ternary) operator form
(Practice compact syntax: condition ? true-part : false-part and handle
nested conditions too.)
3. State and justify whether the following are valid C identifiers: 9marks, Mark
2020, v4vote, _csdept, @cse, AxB
(Explain rules for identifiers and point out why some are invalid.)
4. Explain the structure of a basic C program and write a sample program that
uses input/output statements
(Cover #include, main(), printf(), scanf(), and return statements.)
5. Write a program to check whether a number is a Strong Number or not
(Use loops and factorial logic to compare sum of factorial of digits to original
number.)
6. Write a program to evaluate the expression result = 5 * (6 + 2) / 4 - 3
and explain how operator precedence and parentheses affect the result
(Break down step-by-step how the expression is evaluated.)
7. Differentiate between primitive and derived data types in C with examples
(Include int, float, char for primitive; arrays, pointers, structures for derived.)

Module 2 – Arrays, Strings, and Typedef

1. Write and explain different ways to declare and initialize a one-dimensional


array in C
(Cover static initialization, loop-based input, and partial initialization.)
2. Write a program to reverse the elements of an array without using a second
array
(Use a loop to swap elements from start to end in-place.)
3. How can a list of strings be stored using a two-dimensional character array?
Show how to input, store, and display them
(Explain using char cities[5][20] and usage with scanf, gets, or fgets.)
4. Write a program that allows the user to enter a string and displays it in reverse
order
(Use arrays and loops to read and display characters backward.)
5. Write a program to sort a list of cities lexicographically and resolve duplicates
using literacy level and population
(Use structures and nested if conditions with string comparison.)
6. Explain enumerated data types and typedef with examples
(Show how enums simplify code and typedef creates type aliases.)

Module 3 – Functions, Structures, Storage Class

1. Define a function that compares two dates and returns which is earlier. Then
write code that prints the result using that function
(Use a struct date and compare year, month, day fields.)
2. Does the order of function definitions in a C program matter? How does a
function prototype help?
(Explain compiler flow and importance of prototypes for forward referencing.)
3. Write a program that defines and uses a macro and also accepts command-line
arguments
(Define a simple macro for PI or SQUARE(x) and use argc, argv.)
4. Define a structure named Vehicle and write a program to store data for 10
vehicles and sort them in descending order of price
(Use arrays of structures and sorting logic.)
5. Explain different storage classes in C with code examples: auto, static, extern,
register
(Show scope, lifetime, and where each is used.)
6. Define a structure for a hotel and write a function to print all hotels below a
specified room charge
(Use structure array, function, and if condition for filtering.)
Module 4 – Pointers and File Handling

1. Declare and explain how pointers are used in C. Write a program to access array
elements using a pointer
(Use int *ptr and pointer arithmetic like *(ptr + i).)
2. Write a program that processes strings using pointers, including pointer to
pointer and array of pointers
(Show string arrays and char *str[], char **ptr usage.)
3. Write a code snippet to open a file in write mode, check if it opened successfully,
and print an error if it fails
(Use FILE *fp = fopen("file.txt", "w"); and check with if(fp == NULL).)
4. Write programs for two people to access sample.txt, one for reading and
another for reading and writing simultaneously
(Use modes "r" and "r+"; show both operations with fopen, fgets, fprintf.)
5. Write a function that calculates roots of a quadratic equation using pointers to
pass coefficients a, b, c
(Use pointer parameters and apply the quadratic formula.)
6. Write a program to create a file for employee data, append data, delete a record
by making salary zero, and update salary
(Use file handling functions fopen, fprintf, fscanf, and handle logic for
update/delete.)

You might also like