c++ program to check odd or even | to find size of data types | to sum of three numbers | increment and decrement operators | learnig cpp
/* Write a c++ program to print the of n natural number.
int n, table;
cout<<"Enter the number that you want to print the table of : ";
cin>>n;
for (table = 1; table <11; table++){
int sum = n*table ;
cout<<sum<<endl;
} */
/*Write a program to check whether the number is odd or even?
int n, remainder;
cout<<"Enter your number to check: " <<endl;
cin>>n;
remainder =n%2;
if (remainder == 0 ){
cout<<"Your number is even";
}
else{
cout<<"Your number is odd";
} */
/* //Pointers
int a = 3;
int* b=&a;
cout<<"The address of a is : "<<&a<<endl;
cout<<"The address of a is : "<<b<<endl;
cout<<"The value of a is : "<<*b<<endl;
//poiters to pointers
int ** c = &b;
cout<<"The address of b is : "<<c<<endl;
cout<<"The value of b is : "<<*b<<endl; */
//Test round
/*Q - Write a c++ program to print the welcome text in a separate line;
cout<<"Welcome";
// Q - Write a c++ program to print the sum of three numbers??
int a , b,c;
a = 56;
b = 8;
c = a+b;
cout<<c;
//Q - Write a c++ program to find size of fundamental data types.
int a ;
char b;
long c;
double d ;
float e ;
cout<<"The size of int is : "<<sizeof(a)<<" byte "<<endl;
cout<<"The size of char is : "<<sizeof(b)<<" byte "<<endl;
cout<<"The size of long is : "<<sizeof(c)<<" byte "<<endl;
cout<<"The size of double is : "<<sizeof(d)<<" byte "<<endl;
cout<<"The size of float is : "<<sizeof(e)<<" byte "<<endl;
//Q - Write a c++ program to display the operation of pre and post increment and decrement?
int a = 5;
cout<<"This will display the pre increment : " <<++a<<endl;
cout<<"This will display the post increment : " <<a++<<endl;
cout<<"This will display the pre decrement: " <<--a<<endl;
cout<<"This will display the post decrement: " <<a--<<endl;
cout <<"After operation the value of a is : "<<a; */
Comments
Post a Comment