"Z Code Writer" is an Online Blog for Programmer & Beginner. Here, You will Find tech, Build your Programming Skills and other Programming Language Like C, C++, HTML, Java Script Java Code, Web Designing and University Of Sialkot (USKT) CGPA / GPA Calculator etc.

Saturday, 6 July 2019

Program

Write a program that perform all arithmetic operation on two variable in C.

#include < stdio.h >
#include < conio.h >
void main()
{
     int x , y ;

     x = 2 ;
     y = 3 ;

     printf ( " %d + %d = %d \n " , x , y , x + y );
     printf ( " %d - %d = %d \n " , x , y , x - y );
     printf ( " %d * %d = %d \n " , x , y , x * y );
     printf ( " %d / %d = %d \n " , x , y , x / y );
}

Write a program that perform all arithmetic operation on two variable in C++.

#include < iostream >
using namespace std;
int main()
{
     int x , y ;

     x = 2 ;
     y = 3 ;

     cout << x << " + " << y << " = " << x + y ;
     cout << x << " - " << y << " = " << x - y ;
     cout << x << " * " << y << " = " << x * y ;
     cout << x << " / " << y << " = " << x / y ;
     return 0 ;
}
 
Output of the program
2 + 3 = 5
2 - 3 = -1
2 * 3 = 6
2 / 3 = 0


Write a program that converts 3.5 miles into kilometers and display the result on screen in C.

               ( Hint: 1 mile = 1.609 kilometers )

#include < stdio.h >
#include < conio.h >
void main()
{
     float miles , km ;

     miles = 3.5 ;
     km = miles * 1.609 ;
     printf ( " %f miles = %f  kilometers " , miles , km );
}

Write a program that converts 3.5 miles into kilometers and display the result on screen in C++.

               ( Hint: 1 mile = 1.609 kilometers )

#include < iostream >
using namespace std;
int main()
{
     float miles , km ;
     miles = 3.5 ;
     km = miles * 1.609 ;
     cout << miles << " miles = " << km << " kilometers " ;
     return 0 ;
}


Output of the program
3.5 miles = 5.6315 kilometers



Write a program that interchanges value of two variables using assignment values on the screen in C.

#include < stdio.h >
#include < conio.h >
void main()
{
     int x , y , temp ;
       x = 155 ;
    y = 40 ;
    printf ( " Values Before Interchange \n " ) ;
    printf ( " Value X = %d \n " , x ) ;
    printf ( " Value Y = %d \n " , y ) ;
    temp = x ;
    x = y ;
    y = temp ;
    printf ( " Values After Interchange \n " ) ;
    printf ( " Value X = %d \n " , x ) ;
    printf ( " Value Y = %d \n " , y ) ;
}

Write a program that interchanges value of two variables using assignment values on the screen in C++.


#include < iostream >
using namespace std;
int main()
{
     int x , y , temp ;
     x = 155 , y = 40 ;
     cout << " Values Before Interchange \n " ;
     cout << " Value X = " << x ;
     cout << " Value Y = " << y ;
     temp = x ;
     x = y ;
     y = temp ;
     cout << " Values After Interchange \n " ;
     cout << " Value X = " << x ;
     cout << " Value Y = " << y ;
     return 0 ;
}


Output of the program
Values Before Interchange
Value X = 155
Value Y = 40
Value After Interchange
Value X = 40
Value Y = 155


No comments:

Post a Comment

Thanks For Visiting Here...!! I will Reply you as soon as possible.