About Me

My photo
Raipur, Chhattisgarh, India
Hi , I am Amit Thakur. I have worked as a QA Engineer for two years and as a Java Developer for one year in NIHILENT TECHNOLOGIES PVT. LTD., Pune.Currently I am working as DEAN (Research & Development) in Bhilai Institute of Technology, Raipur.

Tuesday, September 3, 2013

C Program to Demonstrates binary expressions using integer arithmetic

#include<stdio.h>
main()
{
/* Local Definitions */
int a = 5;
int b = 5;

/*Statements*/

printf("%d + %d = %d\n", a ,b, a + b);
printf("%d - %d = %d\n", a ,b, a - b);
printf("%d * %d = %d\n", a ,b, a * b);
printf("%d / %d = %d\n", a ,b, a / b);
printf("%d %% %d = %d\n", a ,b, a % b);

}
Output :
5 + 5 = 10
5 - 5 = 0
5 * 5 = 25
5 / 5 = 1
5 % 5 = 0
Explanation :
In order to print “%” symbol inside printf, use “%%”. because % symbol has pre-defined meaning inside printf statement.

No comments: