logo

Organizing Input Output in a Programming Language

   

Added on  2020-10-12

11 Pages3656 Words107 Views
Week 03===============================Problem 301:===============================#include <iostream> // it’s header file for organizing input-output in a programming languageusing namespace std; // that means weuseall the things with in “std”namespaceint main(){ // main functionfloat x,y,z; // to choose x,y,z as floatcin>>x>>y>>z; // to input x, y, zif(x<y && y<z) // program enters a section of code on whethever a given condition is true or falsecout<<"YES"; // to output reply if condition is trueelse //cout<<"NO"; // to output reply if condition is false} // end of main function===============================Problem 302:===============================#include <iostream> // it’s header file for organizing input-output in a programming language#include <cmath> // that means weusethe things from cmath library (for abs)using namespace std; //that means weuseall the things with in “std”namespaceint main(){ double a,b,c; // to choose a,b,c as doublecin>>a>>b>>c; // to input a,b,cif (a<=b && b<=c) { // to compare 3 valuescout<<a*2<<" "<<b*2<<" "<<c*2<<" "; // to output reply if condition is true}elsecout<<abs(a)<<" "<<abs(b)<<" "<<abs(c)<<" "; // to output reply if condition is false} // end of main function===============================Problem 303:===============================#include <iostream> // it’s header file for organizing input-output in a programming language#include <cmath> // that means weusethe things from cmath libraryusing namespace std; // that means weuseall the things with in “std”namespaceint main() // main function{double a,b,c,k=0,k1=0;double f;cin>>a>>b>>c; // to input a,b,cf=b*b-4*a*c; // to write a functionif(f<0) cout<<"no solution"; // to output reply if condition is true

else {k=((-b+sqrt(f))/(2*a)); k1=((-b-sqrt(f))/(2*a)); if(k!=k1) cout<<max(k1,k)<<" "<<min(k,k1);else cout<<k; // to output reply if condition is false } return 0;} // end of main function===============================Problem 304:===============================#include <iostream> // it’s header file for organizing input-output in a programming languageusing namespace std; // that means weuseall the things with in “std”namespaceint main(){ // main functiondouble x,y,z; // to choose x,y,z as doublecin>> x>>y>>z; // to input 3 valuesif (x<y && x<z) // if x less than y,zcout <<x<<endl; // to output xelse if (y<x && y<z) // if y less than x,zcout <<y<<endl; // to output yelse if (z<x && z<y) // if z less than y,xcout <<z<<endl; // to output zif (x>y && x>z) // if x more than y,zcout<<x<<endl; // to output xelse if (y>x && y>z) // if y more than x,zcout<<y<<endl; // to output yelse if (z>x && z>y) // if z more than y,xcout <<z<<endl; // to output z} // end of main function===============================Problem 305:===============================#include <iostream> // it’s header file for organizing input-output in a programming languageusing namespace std; // that means weuseall the things with in “std”namespaceint main(){ // main functiondouble x,y,z;int main(){cin>>x>>y>>z;if(x+y>z&&y+z>x&&x+z>y) cout<<"YES";else cout<<"NO";return 0;} // end of main function===============================

Problem 306:===============================#include<iostream> // it’s header file for organizing input-output in a programming languageusingnamespacestd; // that means weuseall the things with in “std”namespaceint main(){ // main functionintx,y,z;intmain(){cin>>x;if(x%400==0||(x%4==0&&x%100!=0))cout<<366;elsecout<<365;return0;} // end of main function===============================Problem 307:===============================#include<iostream> // it’s header file for organizing input-output in a programming languageusingnamespacestd; // that means weuseall the things with in “std”namespaceint main(){ // main functioninta,b,c; // to choose a,b,c as integercin>>a>>b>>c;if(b>=1&&b<=12&&c>0){if(b==1){if(a>1&&a<=31)cout<<"yes";elsecout<<"no";}if(b==2){if((c%400==0||(c%100!=0&&c%4==0))&&a>0&&a<=29)cout<<"yes";elseif(a>0&&a<=28)cout<<"yes";elsecout<<"no";}if(b==3){if(a>1&&a<=31)cout<<"yes";elsecout<<"no";}if(b==4){if(a>1&&a<=30)cout<<"yes";elsecout<<"no";}if(b==5){if(a>1&&a<=31)cout<<"yes";elsecout<<"no";

}if(b==6){if(a>1&&a<=30)cout<<"yes";elsecout<<"no";}if(b==7){if(a>1&&a<=31)cout<<"yes";elsecout<<"no";}if(b==8){if(a>1&&a<=31)cout<<"yes";elsecout<<"no";}if(b==9){if(a>1&&a<=30)cout<<"yes";elsecout<<"no";}if(b==10){if(a>1&&a<=31)cout<<"yes";elsecout<<"no";}if(b==11){if(a>1&&a<=30)cout<<"yes";elsecout<<"no";}if(b==12){if(a>1&&a<=31)cout<<"yes";elsecout<<"no";}}elsecout<<"no";} // end of main function===============================Problem 308:===============================#include<iostream> // it’s header file for organizing input-output in a programming languageusingnamespacestd; // that means weuseall the things with in “std”namespaceintmain()// main function{inta,b,c;cin>>c;a=3;b=2010;if(c>b){for(b;b<(c+1);b++){

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
ROBOTICS C++. 1. Robotics C++ Name of Student Instituti
|5
|482
|24

Assignment On Basic Mathematical Operations
|5
|460
|16

new features of this C++ programming
|12
|1032
|16

OOPS Concepts: C++
|10
|1216
|314

Fundamentals of Programming
|9
|1287
|62

Error Checking And Handling
|12
|2453
|21