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

Web Front-End Development

Web Front-End Development Web pages can be developed using languages  HTML,CSS,JAVASCRIPT,BOOTSTRAP. html( HyperText Markup Language ) HTML is the standard markup language for Web pages HTML  elements  are the building blocks of HTML pages HTML elements are represented by  <> tags HTML adds content to webpage. ex:- paragraphs,tables,images,buttons etc.. CSS(Cascading Style Sheets) CSS describes how HTML elements are to be displayed CSS adds styles to the webpage Ex:- colors,alignments,font-size,background-image etc.. Javascript JavaScript is the  Programming Language  for the Web. JavaScript can update and change both  HTML  and  CSS. JavaScript can  calculate ,  manipulate , and  validate  data. Bootstrap CSS Framework for developing responsive and mobile-first websites. Bootstrap includes HTML and CSS based design templates for typography, forms, buttons, tables, navigation, modals, im...

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