Q. If sum of two integer is 14 and if one of them is 8 then find other integer. Ans: Well, this is very simple. Simply, one integer is 8 and sum of two integers is 14. So, we need to subtract the number 8 from their sum of 14 to get the second number. So, the second number is: 14 - 8 = 6 C-Program of this task Code---> #include<stdio.h> int main () { int num1 = 8 , num2 , sum = 14 ; num2 = sum - num1 ; printf ( "The second number is: %d" , num2 ); return 0 ; }
In this C-program we will take two integers(decimal number) as input from user and print the swapped values of the integers.
input:
Two numbers(i.e : 5,6,3 etc.)output:
Swapped values of the two integers
CODE---->
#include<stdio.h>
int main()
{
int a,b,s;
printf("Enter 1st number: ");
scanf("%d",&a);
printf("Enter 2nd number: ");
scanf("%d",&b);
s=a;
a=b;
b=s;
printf("After swapping the 1st number is = %d\n",a);
printf("After swapping the 2nd number is = %d",b);
return 0;
}
Download the C-Program file of this Program.
RESULT :
Enter 1st number: 45 Enter 2nd number: 78 After swapping the 1st number is = 78 After swapping the 2nd number is = 45 -------------------------------- Process exited after 4.06 seconds with return value 0 Press any key to continue . . .
Images for better understanding :
Comments
Post a Comment