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...

Frontend Vs Backend Coding

Frontend Vs Backend Coding Let us understand how this development is done.Development is divided into two parts frontend development and backend development. The front end, also called “ client-side ” programming, is what happens in the browser. It’s everything the user sees and interacts with. The back end, also called “ server-side ” programming, happens on the server and the database. It’s the machinery that works behind the scenes. developing a website Front-end Development Part of a website that the user interacts. Everything that users experience directly: text colors and styles, images, graphs and tables, buttons, colors, and navigation menu. HTML, CSS, and Javascript are the languages used for Front End development. HTML ( HyperText Markup Language) adds content on the web page with the help of HTML elements CSS  (Cascading Style Sheets)  adds styles to HTML elements Javascript adds behavior in the webpage   Ex: calculate, manipulate, and validate d...

Project in C Tic Tac Toe Game

  Tic Tac Toe Game Development using C While making a Tic Tac Toe game using C language, it is important to make use of arrays. The Xs and Os are kept in different arrays, and they are passed between several functions in the code to keep track of how the game goes. With the code here you can play the game choosing either X or O against the computer. This Tic Tac Toe C game is such that you will have to input a numerical character, from 1 to 9, to select a position for X or O into the space you want. For example: if you are playing with O and you input 2, the O will go to first row – second column. If you want to place O in third row – first column, you have to enter 7. And, it is similar for the other positions.