You are on page 1of 11

# C lab programs - solutions

## C programs on Number logics

c program to calculate simple interest c program to calculate simple interest c program to calculate compound interest c program to find factorial of a given number c program to find a number is even or odd c program to find a number is perfect or not c program to find a number is prime or not c program to find a factors of integer c program to find prime factors c program to find a number is armstrong or not c program to print armstrong number c program to find a number is amicable or not c program to find sum of n numbers c program to find average of n numbers c program to find largest of two numbers c program to find largest of n numbers c program to find LCM of two numbers c program to find GCD of two numbers c program to print numbers in word format c program to print pascal Triangle c program to find roots of quadriatic expression c program to find addition and subtraction of complex numbers c program to find multiplication of complex numbers c program to print pyramid of numbers c program to convert demical number to binary c program to convert demical number to octal c program to convert demical number to hexadecimal c program to print sum of digits of positive integer c program to implement towers of hannoi c program to check a number is palindrome number or not c program to check a number is strong number or not c program to to find biggest of three numbers c program to find largest & smallest values in array c program to find no. of possible combinations c program to find no. of digits in a number c program to find no. of permutations c program to find prime numbers below 100 c program to find result of power value c program to find reverse of a number c program to find smallest number in an array c program to find sum of Digits of a number c program to Implement Floyds Triangle c program to check a number is even or odd c program to swap two numbers without using temp

C Programs on Functions

c program to implement function with arguments and no return value c program to implement Function with arguments and a return value c program to implement Function with no arguments and a return value c program to implement function with no arguments and no return value

C Programs on Matrices
c program to find addition of two matrices c program to find multiplication of two matrices c program to find transpose of a given matrix c program to find inverse of a given matrix c program to print lower triangle of a matrix c program to print upper triangle of a matrix c program to represent sparse matrix c program to find addition of sparse matrix c program to find multiplication of sparse matrix

C Programs on Macros
c program to find simple interest using macros c program to find maximum and minimum values using macro's

C Programs on Recurrsion
c program to find gcd of two numbers using recurrsion c program to print fibonacci numbers using recurrsion c program to find factorial of a number using recurrsion c program to find sum of factorial series using recurrsion

## C Programs on Data Types

c program to find size of various data types

## C Programs on Storage classes

c program showing automatic variable scope c program showing external variable scope c program showing static variable scope c program showing register variable scope

## C Programs on Structs & unions

c program to add delete modify employee data

C Programs on Strings
c program to find reverse a string using strrev c program to find reverse a string using pointers c program to find reverse a string using arrays c program to find length of a string using strlen c program to find length of a string using arrays c program to find length of a string using pointers c program to concatinate two strings using strCat function c program to concatinate two strings using arrays c program to check status of a character c program to convert string to lowercase c program to convert a string to uppercase c program to convert string to uppercase c program to convert string to lowercase c program to find a string is substring or not c program to find no, of words in a string c program to find no, of vowels in a string c program to find first occurance of character in a string c program to compare two strings using arrays c program to compare two strings using pointers c program to compare two strings using strcmp

c program to check if a string is palindrome or not c program to find position of a substring c program to find Various combinations of string c program to show acromatic string c program to show rain drop character

C Programs on Files
c program to copy one file into another file c program to write student records in a file

C Programs on Graphics
c program to show different line styles c program to show various fill styles c program to show various font styles

C Programs on Others
c program to show escape operators

## C Programs on Data structures

Find programs on stacks, linked lists, queues, trees, searching & sorting in c language c programming language c programming language is first general purpose programming lanuage used for developing system as well as application software The advantages of using c language are: Low level instruction mapping Requires minimum run time support Support cross platform programming Helps in developing efficient programs

Various features of c programming language are Implementation pointers first genral pupose programming language later lead in development of object oriented languages like c++ & java C is portable Due to its thin layer of abstraction and low overhead, C allows efficient implementations of algorithms and data structures Writing c programs For various c programs: http://www.itstudentjunction.com/c-programs.htm Any c program begins with pre processor directory A preprocessor is a program that processes the C program before the compiler. for example the statement #include<stdio.h> effectively inserts the file studio' into the c program making functions contained in the stdio.h' file available to the programmer After including files The program may define macros example: #define max 3 defining macros are optional and their usage depends on program. Macros help in writing efficient programs for faster computation. The next part of c program is main() : The execution of the C program begins from main(). Without this function, C program does not execute Main() has block of code inserted between "{" and "}" (flower brackets) Inside main() contains variables are functions that are basic building blocks of any program AIM of learning c programs:is To develop programming skills in design and implementation of c applications. AIM of learning c programming Here are some of examples of c programs that can help you in learning basics of c programming: Implementing various number logic programs such as calculation of simple interest, compound interest, finding factorial of a given number in c, Finding a number is even or odd , number is perfect or not, number is prime or not, find a factors of integer,find prime factors check a number is armstrong or not, print armstrong number,find a number is amicable or not, Find sum of n numbers, average of n numbers, find largest of two numbers, largest of n numbers, LCM of two numbers, GCD of two numbers in c language, print numbers in word format, print pascal Triangle Find roots of quadriatic expression ,find addition and subtraction of complex numbers, multiplication of complex numbers, print pyramid of numbers , convert demical number to binary ,demical number to octal, demical number to

hexadecimal print sum of digits of positive integer, implement towers of hannoi, addition of two matrices multiplication of two matrices, find transpose of a given matrix, inverse of a given matrix in c print lower triangle of a matrix , print upper triangle of a matrix, represent sparse matrix, find addition of sparse matrix, find multiplication of sparse matrix Implementing macros such as calculating simple interest using macros, find maximum and minimum values using macro's, Learn Implemention of recursion using some examples like gcd of two numbers, print fibonacci numbers, find factorial of a number using recursion, find sum of factorial series, To find reverse of a number using recurrsion Learn about various data types and their sizes Showing automatic variable scope, external variable scope, static variable scope, showing register variable scope Implementing structures example:delete modify employee data Learn about various operations performed on strings such as finding reverse a string using strrev, reverse a string using pointers, reverse a string using arrays, Finding length of a string using strlen, length of a string using arrays, length of a string using pointers, To concatinate two strings using strCat function , to concatinate two strings using arrays, To convert string to uppercase , convert string to lowercase , To find a string is substring or not, Find no, of words in a string, Find no, of vowels in a string, Finding first occurance of character in a string using c program, To compare two strings using arrays, compare two strings using pointers, to compare two strings using strcmp, to check if a string is palindrome or not Learn various operations performed on file such as to copy one file into another file, to write student records in a file

c program to calculate compound interest c program to find factorial of a given number c program to find a number is even or odd c program to find a number is perfect or not c program to find a number is prime or not c program to find a factors of integer c program to find prime factors c program to find a number is armstrong or not c program to print armstrong number c program to find a number is amicable or not c program to find sum of n numbers c program to find average of n numbers c program to find largest of two numbers c program to find largest of n numbers c program to find LCM of two numbers c program to find GCD of two numbers c program to print numbers in word format

c program to print pascal Triangle c program to find roots of quadriatic expression c program to find addition and subtraction of complex numbers c program to find multiplication of complex numbers c program to print pyramid of numbers c program to convert demical number to binary c program to convert demical number to octal c program to convert demical number to hexadecimal c program to print sum of digits of positive integer c program to implement towers of hannoi c program to check a number is palindrome number or not c program to check a number is strong number or not c program to to find biggest of three numbers c program to find largest & smallest values in array c program to find no. of possible combinations c program to find no. of digits in a number c program to find no. of permutations c program to find prime numbers below 100 c program to find result of power value c program to find reverse of a number c program to find smallest number in an array c program to find sum of Digits of a number c program to Implement Floyds Triangle c program to check a number is even or odd c program to swap two numbers without using temp

C Programs on Functions
c program to implement function with arguments and no return value c program to implement Function with arguments and a return value c program to implement Function with no arguments and a return value c program to implement function with no arguments and no return value

C Programs on Matrices
c program to find addition of two matrices c program to find multiplication of two matrices c program to find transpose of a given matrix c program to find inverse of a given matrix c program to print lower triangle of a matrix

c program to print upper triangle of a matrix c program to represent sparse matrix c program to find addition of sparse matrix c program to find multiplication of sparse matrix

C Programs on Macros
c program to find simple interest using macros c program to find maximum and minimum values using macro's

C Programs on Recurrsion
c program to find gcd of two numbers using recurrsion c program to print fibonacci numbers using recurrsion c program to find factorial of a number using recurrsion c program to find sum of factorial series using recurrsion

## C Programs on Data Types

c program to find size of various data types

## C Programs on Storage classes

c program showing automatic variable scope c program showing external variable scope c program showing static variable scope c program showing register variable scope

## C Programs on Structs & unions

c program to add delete modify employee data

C Programs on Strings
c program to find reverse a string using strrev c program to find reverse a string using pointers c program to find reverse a string using arrays c program to find length of a string using strlen c program to find length of a string using arrays c program to find length of a string using pointers c program to concatinate two strings using strCat function c program to concatinate two strings using arrays c program to check status of a character c program to convert string to lowercase c program to convert a string to uppercase c program to convert string to uppercase c program to convert string to lowercase c program to find a string is substring or not c program to find no, of words in a string c program to find no, of vowels in a string c program to find first occurance of character in a string c program to compare two strings using arrays c program to compare two strings using pointers c program to compare two strings using strcmp c program to check if a string is palindrome or not c program to find position of a substring c program to find Various combinations of string c program to show acromatic string c program to show rain drop character

C Programs on Files
c program to copy one file into another file c program to write student records in a file

C Programs on Graphics
c program to show different line styles c program to show various fill styles c program to show various font styles

C Programs on Others
c program to show escape operators

## C Programs on Data structures

Find programs on stacks, linked lists, queues, trees, searching & sorting in c language