Showing posts with label Basic C Programs. Show all posts
Showing posts with label Basic C Programs. Show all posts

Sunday, September 13, 2015

Graphic program to design calculator

In this program I used C graphics.
Not a big task, Only we need to know how to initialize Graphics then we can use inbuilt functions to design anything.
initgraph() is the function used to initialize graphics available in graphics.h library. It takes three parameter first one is reference to graphic driver, second one is reference to graphic mode and the last one is BGI library path.
Other functions I used are rectangle() to draw input box and buttons, line() for design, setcolor() to give color to shapes and outtextxy() to display text at specific x and y coordinates.

It looks like this :

Program to make arithmetic operations on complex numbers

Program to make arithmetic operation on rational numbers

Program to create a file in a C

Program to convert upper case to lower case using strlwr

Program to convert lower case to upper case using strupr

Program to convert upper case to lower case

Program to convert lower case to upper case

Program to concatenate string

Program to reverse a string

Program to count number of vowels in a string

Program to check leap year

Program to reverse a number

Program to check palindrome number

Program to find length of string without using predefined functions

Program to check difference between prefix & postfix

Program to find repeated characters in a string

Program to sort string

Program to use string array

Program to read file in a program

File reading:
It requires understanding of two functions fopen and fgetc

fopen():
This function takes two parameters first one is file path and second one is file opening mode. there are six file modes in C language, those are r,w,a,r+,w+ and a+. Here we are using r for reading file.
fopen() returns a FILE pointer.

fgetc():
This function reads and returns one character at a time and moves pointer to the next character.

Powered by Blogger.