Solutions:- 1) W.A.P. to display roots of a quadratic equation where coefficients a,b,c are given ? #include<iostream> #include<cmath> using namespace std; int main() { int a,b,c; float D,r1,r2; cout<<"Enter the Coefficients of the quadratic equation-"; cin>>a>>b>>c; D=pow(b,2) - (4*a*c); if(D<0) {cout<<"\nNo Real Roots"; return 0;} else {if(D>0) { cout<<"\nDistinct Real Roots\n"; r1=(-b + sqrt(D))/(2*a); r2=(-b - sqrt(D))/(2*a); cout<<"Roots ="<<r1<<" "<<r2;} else{ cout<<"\nEqual Roots\n";r1=-b/(2*a); cout<<"Root ="<<r1; }} return 0;} 2) W.A.P. to check whether a given number is prime or not ? #include<iostream> using namespace std; int main() { int n; char p='Y'; cout<<"Enter a number="; cin>>n; if(n==1) p='N'; for(int i=2;i<=n/2;...
Popular posts from this blog
Hello World! This is the basic program in any programming language and I want to start my blogging routine with this basic and simple program. This program doesn't use much of programming skills but tells us how far the technology has reached that a human created machine can respond back to us on the basis of our input. And nowadays computers could also respond physically and sensibly to human action as they are programmed to do so . Programming is a basic term in computers and electronics but it has huge importance and significance if we want to acquire detailed Knowledge in the stream of computer science. Now Lets come back to our topic,our basic C++ or any other programming language programme, but I will use only c++ for coding as the blog name refers.Now Lets Start:- #include<iostream>//basic header file containing basic input/output operation functions using namesspace std; int main()//the program execution starts here { cout << "Hello World" ...
Comments
Post a Comment