Uploaded by pavansaieducation

ipc

advertisement
Write a program in C++ to find Size of fundamental data types.
#include <iostream>
using namespace std;
int main()
{
cout <<" Size of Integer data type= " <<sizeof(int)<<endl;
cout<<" Size of Character data type= " << sizeof(char)<<endl;
cout<<" Size of Float data type= " <<sizeof(float)<<endl;
cout<<" Size of double data type= "<<sizeof(double)<<endl;
cout <<" Size of void data type= "<<sizeof(void)<<endl;
return 0;
}
Write a program in C++ to check the upper and lower limits of all data types
#include <iostream>
using namespace std;
int main()
{
cout<<"Maximum and Minimum of Data type Integer " <<INT_MAX<<" ,"<<INT_MIN<< endl;
cout<<"Maximum and Minimum of Data type Unsigned Integer " << UINT_MAX<<" ,"<< endl;
cout<<"Maximum and Minimum of Data type Signed Short integer " << SHRT_MAX<<" ,"<<SHRT_MIN<< endl;
cout<<"Maximum and Minimum of Data type Unsigned Short integer " << USHRT_MAX<< endl;
cout<<"Maximum and Minimum of Data type unsigned long " << ULONG_MAX<<endl;
cout<<"Maximum and Minimum of Data type Character " <<CHAR_MAX<<" ,"<<CHAR_MIN<< endl;
cout<<"Maximum and Minimum of Data type Signed Character " << SCHAR_MAX<<" ,"<<SCHAR_MIN<< endl;
cout<<"Maximum and Minimum of Data type Unsigned Character " << UCHAR_MAX<< endl;
return 0;
}
Write a program in C++ to swap two numbers
#include <iostream>
using namespace std;
int main()
{
int n1,n2,n3;
cout<<"Input Number 1: ";
cin>>n1;
cout<<"Input Number 2: ";
cin>>n2;
n3=n2;
n2=n1;
cout<<"Number 1 is: "<<n3<<endl;
cout<<"Number 2 is: "<<n1<<endl;
return 0;
}
Write a C++ program to convert specified days into years, weeks and days.
#include <iostream>
using namespace std;
int main()
//Write a C++ program to convert specified days into years, weeks and days
{
int days,years,weeks;
cout<<"Enter Days: ";
cin>>days;
years= days/365;
weeks=days/7;
cout<<"Number of Years: "<<years<<endl;
cout<<"Number of Weeks: "<<weeks<<endl;
cout<<"Number of days: "<<days<<endl;
return 0;
}
Write a C program to enter two numbers and perform all arithmetic
operations
#include <iostream>
using namespace std;
int main()
{
int add,sub,mul,a,b;
float div;
cout<<"Enter Two numbers";
cin>>a>>b;
add=a+b;
sub=a-b;
mul=a*b;
div=a/b;
cout<<"Addition is performed = "<<add<<endl;
cout<<"Subtraction is performed = "<<sub<<endl;
cout<<"Multiplication is performed = "<<mul<<endl;
cout<<"Division is performed = "<<div<<endl;
return 0;
}
Download