Posts

Showing posts with the label Intermediate

ShowCurrenttime gives a program that displays the current time in GMT. Revise the program so that it prompts the user to enter the time zone offset to GMT and displays the time in the specified time zone.

Image
(Current time) ShowCurrenttime gives a program that displays the  current time in GMT. Revise the program so that it prompts the user to enter the time  zone offset to GMT and displays the time in the specified time zone.  #Beginner #Intermediate In gcc c++ compiler using namespace std; #include<iostream> #include<ctime> using namespace std; int main() { int totalsec = time(0); int currentsec = totalsec % 60; int totalminutes= totalsec / 60; int currentminutes=totalminutes % 60; int totalhrs=totalminutes / 60; int currenthrs=totalhrs % 24; int gmt; cout<< "enter GMT zone -12 to +12 :" ; cin>>gmt; int currentgmthrs=(totalhrs+gmt)%24; cout<< "main time  " <<currenthrs<< " :" <<currentminutes<< " :" <<currentsec<< " GMT +0" <<endl; cout<< "your time " <<currentgmthrs<< " :" <<currentm...

Write a program that prompts the user to enter three points (x1, y1), (x2, y2), (x3, y3) of a triangle and displays its area. The formula for computing the area of a triangle is

Image
(Geometry: area of a triangle) Write a program that prompts the user to enter three  points (x1, y1), (x2, y2), (x3, y3) of a triangle and displays its area. The formula  for computing the area of a triangle is s = (side1 + side2 + side3)/2; area = 2√ s(s - side1)(s - side2)(s - side3) #Beginner In gcc c++ compiler using namespace std; #include<iostream> #include<cmath> using namespace std; int main() { float x1,y1,x2,y2,x3,y3; cout<< "Enter three point of triangle:" <<endl; cout<< "point1 x1 and y1 :" ; cin>>x1>>y1; cout<< "point2 x2 and y2 :" ; cin>>x2>>y2; cout<< "point3 x3 and y3 :" ; cin>>x3>>y3; float side1=sqrt(pow(x2-x1,2)+pow(y2-y1,2)); float side2=sqrt(pow(x3-x2,2)+pow(y3-y2,2)); float side3=sqrt(pow(x1-x3,2)+pow(y1-y3,2)); float s=(side1+side2+side3)/2; float area=sqrt(s*(s-side1)*(s-side2)*(s-side3)); cout<< "...

Variable limits and size of variable in byte program cpp

Image
Limit of variable and size of variable #Beginner #Intermediate In gcc c++ compiler using namespace std; #include<iostream> #include<limits> using namespace std; int main() { cout<< "-------------------signed variable------------------------" <<endl; cout<< "variable | minimum value  | maximum value  |  size in byte" <<endl; cout<< "Char \t\t" <<CHAR_MIN<< "\t\t" <<CHAR_MAX<< "\t\t\t" << sizeof ( char )<<endl; cout<< "short int \t" <<SHRT_MIN<< "\t\t" <<SHRT_MAX<< "\t\t\t" << sizeof ( short int )<<endl; cout<< "int \t\t" <<INT_MIN<< "\t" <<INT_MAX<< "\t\t" << sizeof ( int )<<endl; cout<< "long int \t" <<LONG_MIN<< "\t" <<LONG_MAX<< "\t\t...