Skip to main content

C programming with practical Questions

Basics


C language is one of the powerful languages. Below are some of the features of C language.

Ø  Reliability

Ø  Portability

Ø  Flexibility

Ø  Interactivity

Ø  Modularity

Ø  Efficiency and Effectiveness

 

1) C program to calculate Simple Interest.

Given principal (amount), time and interest rate by user, calculate simple interest based on given rate of given time period.

2) Ask the employee details

  Name

  initial---(surname only single letter, take datatype as char)

  Age

  Salary-(take datatype double)

  expected expenditure

  actual expenditure

  and

  display name and remaining balance of salary.

  

Operators

The symbols which are used to perform logical and mathematical operations in a C program are called C operators.These C operators join individual constants and variables to form expressions.Operators, functions, constants and variables are combined together to form expressions.

Consider the expression A + B * 5. where, +, * are operators, A, B  are variables, 5 is constant and A + B * 5 is an expression.

 

Conditional operator- ---expression ? expression : expression

1)given employee ages rama=20 and site=21

 using conditional operator and print the elder employee name and age

2)Find the ASCII value of character 'c'

 

Conditional

In decision control statements (if-else and nested if), groups of statements are executed when condition is true. If condition is false, then else part statements are executed.

There are 3 types of decision making control statements in C language. They are,

Ø  if statements

Ø    if else statements

Ø    nested if statements

1)C Program to Check Whether a Character is Vowel or Consonant

2)C Program to Check Leap Year

3)C Program to Check Whether a Character is an Alphabet or not

 

Loops

Loop control statements in C are used to perform looping

operations until the given condition is true. Control comes out of the loop statements once condition becomes false.There are 3 types of loop control statements in C language. They are,

1.     for

2.     while

3.     Do-while

 

1)print Fibonacci series

2)check whether given number is palindrome

3)c program to reverse a number

 

Arrays

Array is a collection of variables belonging to the same data type. You can store group of data of same data type in an array.

Ø  Array might be belonging to any of the data types

Ø  Arraysize must be a constant value.

Ø  Always,Contiguous (adjacent) memory locations are used to store array elements in memory.

Ø  It is a best practice to initialize an array to zero or null while declaring, if we don’t assign any values to array.

 

1)c program to find the sum of numbers in an array

2)C Program to Calculate Average Using Arrays

3)C Program to Add Two Matrix Using Multi-dimensional Arrays

4)C Program to Find Largest Element of an Array

5)C Program to Sort the Array in an Ascending Order

6)program to reverse a string

 

Functions

C functions are basic building blocks in a program. All C programs are written using functions to improve reusability, understandability and to keep track on them. You can learn below concepts of C functions in this section in detail.

 

1)C Program to Display Prime Numbers Between Intervals Using Function

2)C Program to Check Prime or Armstrong Number Using User-defined Function

3)C Program to Find the Sum of Natural Numbers using Recursion

 

Pointers

Pointers in C language is a variable that stores/points the address of another variable. A Pointer in C is used to allocate memory dynamically i.e. at run time. The pointer variable might be belonging to any of the data type such as int, float, char, double, short etc.

 

1)Adding two numbers using pointer

2)multiplying 3 numbers using pointers

3)Program to Swap Elements Using Call by Reference(using pointer)

4)Access the elements of array using pointer and display the largest number

 

Structures

1)make a structure for employee

   name

   email

   occupation

Ask the user to enter these details for 3 employees

then ask the user whose details he wants to display (1 or 2 or 3) depending on his choice display that employee details.

 

Comments

Popular posts from this blog

C pointers

  C pointers theory C pointers practice 1)Adding two numbers using pointer 2)multiplying 3 numbers using pointers 3)Program to Swap Elements Using Call by Reference(using pointer) 4)Access the elements of array using pointer and display the largest number      

C Functions

  User Defined Function User defined Function return practice 1)C Program to Display Prime Numbers Between Intervals Using Function 2)C Program to Check Prime or Armstrong Number Using User-defined Function 3)C Program to Find the Sum of Natural Numbers using Recursion      

C Control Statements

for Loop while loop do...while loop practice 1)print Fibonacci  series 2)check whether given number is palindrome 3)c program to reverse a number