Saturday, April 11, 2009

Exercise Solving 3

Exercise 3:
If the marks obtained by a student in five different subjects are input through the keyboard, find out the aggregate marks and the percentage marks obtained by the student. Assume that the maximum marks obtained by a student in each subject is 100.
Solution:

#include<stdio.h>
#include<conio.h>

Friday, April 10, 2009

Exercise Solving 2

Exercise 2:
The distance between two cities (in Km) is input through the keyboard. Write a program to convert and print the distance in meters, feet, inches and centimeter.
Solution:

#include<stdio.h>
#include<conio.h>

Thursday, April 09, 2009

Exercise Solving 1

Exercise 1:
Ramesh’s basic salary is input through the keyboard. His dearness allowance is 40% of basic salary, and house rent allowance is 20% of basic salary. Write a C program to calculate his gross salary.


Solution:

#include<stdio.h>
#include<conio.h>

Wednesday, April 08, 2009

Control Instruction in C

Control instruction in a programming language determines the flow of control in a program. In C language there are four types of control instruction, which are as follows:
  1. Sequence Control Instruction.
  2. Selection or Decision Control Instruction.
  3. Repetition or Loop Control Instruction.
  4. Case Control Instruction.

Tuesday, April 07, 2009

A simple program to understand printf() and scanf() function

Now we will see how printf() and scanf() function works together to perform a particular work.
We will write a program to calculate the Simple Interest. where the principle, rate of interest and the time in years will be taken from the user.

#include<stdio.h>
#include<conio.h>
void main()

Monday, April 06, 2009

Utility of scanf() function and how it is used.

Utility of scanf() is to input data from the user. The format string used in the printf() statement is same for scanf() statment, only difference is that we have to space & sign before the variable name, and we can’t print any word or statement to make the input user friendly with the scanf() function, to make the input statement user friendly, we have to pint the statement using printf() function and then we have to use scanf() function to input the data.
Syntax of scanf() function is as follows:
scanf(“<format string>”, &<variable name>);


Sunday, April 05, 2009

Utility of printf() function & how it is used.

In the previous blogs we have learnt about the basic part of programming and we will move further with the different programming syntaxes and logical part of the programming. So, now let’s start with the printf() and scanf() functions.
printf() function is used to print any value or character or variable value on the screen.
Syntax of printf() function is as follows:
printf(“<format string>”, <list of variables>);


<format string> could be,
%f for printing real or float values
%d for printing integer values
%c for printing character values

Tuesday, March 31, 2009

The First C program

Now let us try to write a simple C program, to understand what we have read in our previous blogs.
We will star our program development skill, by writing a simple C program to calculate the average of three numbers. {also see: Rules for writing a C program}


Line No. Program statements
1 /* Calculation of the average of three given number */
2 #include<stdio.h>
3 #include<conio.h>
4 void main()

Monday, January 26, 2009

Rules for writing a C program

In the previous blogs we have learnt about the types of variables, constants and the hierarchy of operations, and now we are ready to write our first C program.
A program consists of series of consecutive steps according to the flowchart of the program or to get the desired result. And in C program each instruction is written as a separate statement and this statements must appear in the same order in which we wish them to execute, unless of course the logic of the program demands a deliberate jump or transfer of the program counter or the control to a statement, which is out of sequence.

There are some specific rules to follow, while writing C programs:

Sunday, January 25, 2009

Hierarchy of operations

In an arithmetic operation, while execution of two or more operators , we some time have some problem as to how does it get executed. Lets take an example to understand the thing more properly, we consider an arithmetic expression:
5*m – 7*n

Now sometimes we face problem regarding the execution of the expression, does it corresponds to (5m)-(7n) or 5(m-7n) ? Thus to solve this kind of problems we have to understand the Hierarchy of operations. The priority or the precedence in which the operations in an arithmetic expression are performed is called the hierarchy of operation.