0% found this document useful (0 votes)
12 views

1) A) This Programme Compares Which Number Is Larger Than The Other

The document contains code snippets that demonstrate basic C++ programs for: 1) Comparing two numbers and printing the larger number 2) Taking user input of a name and printing a greeting 3) Taking user input of two numbers, adding them, and printing the total

Uploaded by

mehrawar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

1) A) This Programme Compares Which Number Is Larger Than The Other

The document contains code snippets that demonstrate basic C++ programs for: 1) Comparing two numbers and printing the larger number 2) Taking user input of a name and printing a greeting 3) Taking user input of two numbers, adding them, and printing the total

Uploaded by

mehrawar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

1)a)this programme compares which number is larger than the other

#include <iostream>
using namespace std;

int main (void)

{
int num1=0.0;
int num2=0.0;

cout << "enter number"<<endl;


cin>>num1;
cout<< "enter second number"<<endl;
cin>>num2;

if (num1>num2)

cout<<" Larger to smaller number is:\t" <<num1 <<" \t"<< num2


<<endl;

else if (num2>num1)
cout <<" Larger to smaller number is:\t" << num2<<" \t"<< num1
<<endl;
system ("pause");

1b) # include <iostream>


using namespace std ;

int main ()

{
int a=1, b=1, c ;
if (c = (a-b))
cout << " The value of c is : " << c ;
return 0 ;

}
Q2)a)
#include <iostream>
using namespace std;
int main(void)

{
cout<<"enter your name"<<endl;
char name[10];
cin >> name;
cout << " Hello:\t " << name << endl;

system ("pause");

Q2)b)
#include <iostream>
using namespace std;

int main (void)

{
int N=0.0;
float X=0.0;
int total=0.0;

cout << "enter number"<<endl;


cin>>N;
cout <<"enter second number"<<endl;
cin>>X;
total=(N+X);

cout<< "The total of the numbers:"<<total<<endl<<endl;


system ("pause");

}
Q2)c)

#include <iostream>
using namespace std;

int main (void)

{
int inches=0.0;
double cm=0.0;

cout << "enter the length in inches"<<endl;


cin>>inches;
cm=(inches*2.5);

cout<< "The length in centimetres:" <<cm<<endl<<endl;


system ("pause");

}
Q3)

#include <iostream>
using namespace std;

int main (void)

{
double f;
double c;
int pi=3.14;
double Xc;

cout << "enter the frequency value"<<endl;


cin>>f;
cout <<"enter the capacitance value"<<endl;
cin>>c;

Xc= 1/(2*pi*c*f);

cout<< "The capacitive reactance:"<<Xc<<endl;


system ("pause");

You might also like