questions in cpp of variables and data types

  /* //Write a program to take input from user and add and find product also

   int num1,num2,sum,product;
   cout<<"Enter the first operands : ";
   cin>>num1;
   cout<<"Enter the second operands : ";
   cin>>num2;
   sum = num1+num2;
   product = num1*num2;
   cout<<"The Sum of these numbers is : "<<sum<<endl;
   cout<<"The Product of these numbers is : "<<product<<endl;
   return  0;

   // Write a cpp in the area of rectangle is calculated.
   int length,breath,area;
    cout<<"Enter the length of rectangle : ";
   cin>>length;
   cout<<"Enter the breath of rectangle : ";
cin>>breath;
area=2*(length+breath);
cout<<"The area of given rectangle is : "<<area;  

//Write a cpp program to find the ASCII value of given character ?
char h;
cout<<"Enter the character that you want to fint the ASCII value of : ";
cin>>h;
cout << "ASCII value of  is " << int(h) << endl;

// Write a cpp program to convert a double value to int :
double d = 100.235;
cout<<"the double value is : "<<d<<endl;
cout<<"the integer value of given double  is : "<<(int)d;

// Write a program to add 3 to the ASCII value of the character 'd' and print it .
 
 cout << "ASCII value of  is " << (int)'d' << endl;
 char x = 'd'+3;
 cout<<"Sum is : "<<x;
 
 
  //Write a program to add an integer variable having value 5 and a double variable
   //having value 6.2.
    int a = 5;
    double b = 6.2;
    double sum = a+b;
    cout<<"sum is : "<<sum;

    //Write a program to find the square of the number 3.9.
    double d = 3.9*3.9;
    cout<<"square of given number is : " <<d;


    //Take value of length and breath of a rectangle from user as float. Find its     //area and print it on screen after type casting it to int.

    float length,breath,area;
    cout<<"Enter the length of rectangle : ";
   cin>>length;

   cout<<"Enter the breath of rectangle : ";
cin>>breath;

area=2*(length+breath);
cout<<"The area of given rectangle is : "<<area<<endl;
   cout<<"The area of given rectangle is : "<<(int)area;  

//Take a char input from user and print it's ASCII value.
char c;
cout<<"Enter the character : ";
   cin>>c;
   cout << "ASCII value of  is " << int(c) << endl; */

Comments

Popular posts from this blog

swapping the alternate values in given array's element ! 17/11/2022

Learning stage | c++ programs

c++ basic question