Q 1. Write a program to display any message on the screen.

#include<iostream.h>
#include<conio.h>
using namespace std;
int main()
{
   cout<<"Welcome to Coding Smash!";
   return 0;
}

OUTPUT:






Q2. Write a program to find sum, difference, product and division

  of two numbers.

#include<iostream.h>
#include<conio.h>
using namespace std;
int main()
{
   int a, b, sum, sub, mul, div;
   cout<<"Enter any two numbers: "<<endl;
   cin>>a>>b;
   sum= a+b;
   sub= a-b;
   mul= a*b;
   div= a/b;
   cout<<"Sum of the two no.s: "<<sum<<endl;
   cout<<"Difference of the two no.s: "<<sub<<endl;
   cout<<"Product of the two no.s: "<<mul<<endl;
   cout<<"Division of the two no.s: "<<div<<endl;
   return 0;
}

OUTPUT:





Q3. Write a program to check whether a number is even or odd.

#include<iostream.h>
#include<conio.h>
using namespace std;
int main()
{
   int n;
   cout<<"Enter any number: ";
   cin>>n;
   if(n % 2 == 0)
   {
      cout<<"It is an even number.";
   }
   else
   {
       cout<<"It is an odd number.";
    }
    return 0;
}

OUTPUT:




Q4. Write a program to get the smaller of two numbers.

#include<iostream.h>
#include<conio.h>
using namespace std;
int main()
{
   int a, b;
   cout<<"Enter the first number: ";
   cin>>a;
   cout<<"Enter the second number: ";
   cin>>b;
   if (a<b)
   cout<<"Smaller no. is: "<<a;
   else
   cout<<"Smaller no. is: "<<b;
   return 0;
}

OUTPUT:





Q5. Write a program to swap two numbers.

#include<iostream.h>
#include<conio.h>
using namespace std;
int main()
{
   int a, b;
   cout<<"Enter the first number: ";
   cin>>a;
   cout<<"Enter the second number: ";
   cin>>b;
   a= a+b;
   b= a-b;
   a= a-b;
   cout<<"After swapping,"<<endl;
   cout<<"First no. is: "<<a<<endl;
   cout<<"Second no. is: "<<b;
   return 0;
}

OUTPUT:




Q6. Write a program to find factorial of a number.

#include<iostream.h>
#include<conio.h>
using namespace std;
int fact(int n)
{
  if (n==0)
  return 1;
  else
  return n*fact(n-1);
}
int main()
{
   int n;
   cout<<"Enter any no.: "<<endl;
   cin>>n;
   cout<<"Factorial of the entered no. is: "<<fact(n);
   return 0;
}

OUTPUT:



Q7. Write a program to find sum of first 'n' natural numbers.

#include<iostream.h> 
#include<conio.h>
using namespace std;
int main()
{
   int n, sum ; 
   cout << "Enter total numbers: ";
   cin >> n;
   sum= n*(n+1)/2;
   cout<<"The Sum of first "<<n<<" natural numbers is "<< sum;
   return 0;
}

OUTPUT:



Q8. Write a program to display fibonacci series.

#include <iostream.h>  
#include<conio.h>
using namespace std;  
int main() 
{  
   int t1=0, t2=1, t3, i,total;    
   cout<<"Enter total number of terms: ";    
   cin>>total;    
   cout<<t1<<" "<<t2<<" ";   
   for(i=2; i<total; ++i) 
   {    
      t3= t1 + t2;    
      cout<<t3<<" ";    
      t1=t2;    
      t2=t3;    
   }    
   return 0;  
}

OUTPUT:



Q9. Write a program to check whether a number is palindrome or not.

#include <iostream.h>
#include<conio.h>  
using namespace std;  
int main()  
{  
   int num, r, res=0, temp;    
   cout<<"Enter any Number: ";    
   cin>>num;    
   temp=num;    
   while(num>0)    
   {    
      r=num%10;    
      res=(res*10) + r;    
      num=num/10;    
   }    
   if(temp==res)    
   cout<<"It is Palindrome.";    
   else    
   cout<<"It's not Palindrome.";   
   return 0;  

OUTPUT:



Q10. Write a program create multiplication table.

 #include <iostream.h>
#include <conio.h>
using namespace std;
int main()
{
    int n=1;
    cout << "Enter any number: ";
    cin>>n;  
    for(int i=1; i<=10; i++)
   {
      cout<<n<<" * "<<i<<" = "<<n*i<< endl;;
   }
   return 0;
}

OUTPUT:



Q11. Write a program to make a simple calculator.

#include<iostream.h>
#include<conio.h>
using namespace std;
int main()
{
    char op;
    int a, b;
    cout << "Choose an operator: +, -, * or /: ";
    cin >> op;
    cout << "\nEnter any two numbers: ";
    cin >> a >> b;
    switch(op)
    {
        case '+':
            cout <<"\nSum: "<< a+b;
            break;
        case '-':
            cout <<"\nDifference : "<< a-b;
            break;
        case '*':
            cout <<"\nProduct: "<<a*b;
            break;
        case '/':
            cout <<"\nDivision: "<<a/b;
            break;
        default:
            cout<<"An error occurred. ";
            break;
    }
    return 0 ;
}

OUTPUT: