C Programming Examples with Output Part – 1
Program

2) Write a program to accept two numbers & swap them without an extra (third) variable.
#include <stdio.h>
#include <conio.h>
void main()
{
int a, b;
printf("Enter two numbers : ");
scanf("%d%d", &a, &b);
printf("nOriginal values are a = %d b = %d", a, b);
a = a + b;
b = a - b;
a = a - b;
printf("nAfter exchange a = %d b = %d", a, b);
getch();
}
Output:
Enter two numbers: 10 20
Original values are a = 10 b = 20
After exchange a = 20 b = 10
3) What is the output of the following program? – 3 Number value equation
void main()
{
int intN = 55;
int intM = 10;
char X = 'A' ;
intN +=50;
printf("1. Updated value of intN ID % FN", X);
printf("2. Updated value of X is % dn", X);
X='B';
printf("3. Updated value of X is % cn", X);
intN -=8;
printf("4. Updated value of intN is %dn",intN);
intN++;
printf("5. Updated value of intN is %dn", intN);
intN= intN++ + ++ItM;
printf("6. Updated value of intN is ;%d intM is;%dn", intN, intM);
}
Output:
1. Updated value of intN is 105
2. Updated value of X is 65
3. Updated value of X is B
4. Updated value of intN is 97
5. Updated value of intN is 98
6. Updated value of intN is:110 intM is:11