SQL PHP HTML ASP JavaScript articles and free scripts to download

Interchanging two numbers.

We can enter two numbers and the code will display the values by interchanging them. By developing this simple code we will learn how to enter data by scanf and how to display them after swapping them using printf command.

Here is the code

#include <stdio.h>
int main(void){
int num1,num2,num3; // declaring variables as integers

printf("Enter the two numbers ");
scanf("%d %d",&num1,&num2); // Enter two numbers
num3=num2; // Storing the value of num2 in num3
num2=num1; // Shifting the value of num1 to num2
num1=num3; // Assign the value of num3 ( original num2 value) to num1

printf(" Two numbers are %d,%d " ,num1, num2); // printng outputs
return 0;

We can ask users to enter two data and then display them in reverse order.

Post Comment This is for short comments only. Use the forum for more discussions.
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked

Sample code
C Sections
HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2015 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer