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 Programming Introduction

  hi friends! Before we depth into c program let us understand, what is programming Programming is the process of creating a set of instructions that tell a computer how to perform a task.Programming can be done using a variety of computer programming languages, such as JavaScript, Python, and C++, PHP, react native, etc. ex:- websites are developed using php mobile application can be developed using reactnative etc Depending on application type, we choose different programming languages to develop it. Let us see an example of c programming to print "hello world" on screen program #include <stdio.h> int main() { /* Our first simple C basic program */ printf("Hello World! "); return 0; } output Hello World! run the code on online compiler https://www.onlinegdb.com/online_c_compiler or install c compiler on system and run c programs. C Basic commands Explanation #include <stdio.h> This is a preprocessor command that include...

Software Development Life Cycle

  Hi Friends!! Interested in developing software projects? Need a website for your business? Want to develop an app of your idea? Yes!. So before developing, let us understand what are the different stages to develop software. Below 7 stages will help in developing a quality software product. Requirements Gathering  Analysis Design Coding Testing Implementation Maintenance Requirements gathering If you want to make your product. Understand what product you want to develop. Plan the product. Gather the content required for making the product. Ex: Want to develop a website for school. Plan the website, like website should contain pages for home, about, courses, gallery, contact. Get the content of mission, vision, gallery, etc of school. If you are working for a client(who needs software) product, then understand the client requirement. Ask questions to understand the product like what functionalities should the product contain?collect all his requirements and have a basic plan ...

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