Simple C program to Print hello world

Sunday, March 13, 2016 Unknown 0 Comments



  • First program in c programming

#include<stdio.h>
#include<conio.h>

void main()
{
      clrscr();
      printf("HELLO WORLD");
      getch();
}

Output:

HELLO WORLD

0 comments:

Interchange or swapping of two variable's without third variable

Sunday, March 13, 2016 Unknown 0 Comments


  • TO INTERCHANGE THE VALUE WITHOUT WITHOUT THIRD VARIABLE

#include<stdio.h>
#include<conio.h>

void main()
{
      int a,b;
      clrscr();
      printf("Enter value of A and B : ");
      scanf("%d %d",&a,&b);
      a=a+b;
      b=a-b;
      a=a-b;
     printf("Value after interchangge are :");
     printf("\nA = %d\nB = %d",a,b);
     getch();
}

Output:

Enter value of A and B : 10 20
Value after interchange are:
A = 20
B = 10

0 comments:

TO INTERCHANGE THE VALUE WITHOUT USING THIRD VARIABLE

Sunday, March 13, 2016 Unknown 0 Comments


  • TO INTERCHANGE THE VALUE USING THIRD VARIABLE
#include<stdio.h>
#include<conio.h>

void main()
{
      int a,b,c;
      clrscr();
      printf("Enter value of A and B : ");
      scanf("%d %d",&a,&b);
      c=a;
      a=b;
      b=c;
     printf("Value after interchangge are :");
     printf("\nA = %d\nB = %d",a,b);
     getch();
}

Output:

Enter value of A and B : 10 20
Value after interchange are:
A = 20
B = 10

0 comments:

Addition of two number

Sunday, March 13, 2016 Unknown 0 Comments


  • FIND THE ADDITION OF TWO VARIABLES


#include<stdio.h>
#include<conio.h>

void main()
{
         float a,b,c;
         clrscr();
         printf("Enter the first number:");
         scanf("%f",&a);

         printf("Enter the second number:");
         scanf("%f",&b);

         c=a+b;

         printf("Your Answer is:%f",c);
         getch();
}


OUTPUT
Enter the first number:10
Enter the second number:20
Your Answer is:30

0 comments:

TO CONVERT THE GIVEN TEMPERATURE IN CELSIUS TO FAHRENHEIT

Sunday, March 13, 2016 Unknown 0 Comments

  • TO CONVERT THE GIVEN TEMPERATURE IN CELSIUS TO FAHRENHEIT

#include<stdio.h>
#include<conio.h>

void main()
{
          float f,c;
          clrscr();
          printf("Enter the temperature in Celsius:");
          scanf("%f",&c);

          f=(c*1.8)+32;

          printf("fehranhit is:%f",&f);
          getch();
}

0 comments:

Convert temperature in Fahrenheit to Celsius

Sunday, March 13, 2016 Unknown 0 Comments


  • TO CONVERT THE GIVEN TEMPERATURE IN FAHRENHEIT TO CELSIUS 


#include<stdio.h>
#include<conio.h>

void main()
{
          float f,c;
          clrscr();
          printf("Enter the fahrenheit:");
          scanf("%f",&f);

          c=(f-32)/1.8;

          printf("Celcius is:%f",&c);
          getch();
}

0 comments:

Find number is odd or even

Sunday, March 13, 2016 Unknown 0 Comments


  • TO FIND ODD OR EVEN FROM GIVEN NUMBER


#include<stdio.h>
#include<conio.h>

void main()
{
         int a;
         clrscr();
         printf("Enter the number:");
         scanf("%d",&a);

         if(a%2==0)
         {
                  printf("\n Number is even");
         }
         else
         {
                   printf("\n Number is Odd");
          }
          getch();
}

Output: 

Enter the number:5
Number is Odd

0 comments:

Find number is prime or not

Sunday, March 13, 2016 Unknown 0 Comments

  • TO FIND THAT NUMBER IS PRIME OR NOT


#include<stdio.h>
#include<conio.h>

void main()
{
          int no,a=2;
          printf("Enter any no:");
          scanf("%d",&no);

          while(a<no)
          {
                   if(no%a==0)
                   {
                            a=0;
                            break;
                   }
                   else
                   {
                            a++;
                    }
           }

           if(a==0)
                    printf("no. is prime");
           else
                    printf("no is not prime");
           getch();
}

Output : 

Enter any no:10
no. is prime

0 comments:

Sum of all array element

Sunday, March 13, 2016 Unknown 0 Comments


  •  TO PRINT THE SUM OF 10 ELEMENTS IN 1-D ARRAY


#include<stdio.h>
#include<conio.h>

void main()
{
          int a[10],i,sum=0 //a[10] is a declaration of array

          clrscr();
          printf("Enter the array elements\n");

          for(i=0;i<10;i++)
          {
                   scanf("%d",&a[i]); //it is the initialization of array
          }

          for(i=0;i<10;i++)
          {
                   sum=sum+a[i];
          }

          printf("Sum=%d",sum);
          getch();
}

Output : 

Enter the array elements
1 2 3 4 5 6 7 8 9 10
sum=55

0 comments:

Simple program to assign and print value of variable

Sunday, March 13, 2016 Unknown 0 Comments



  • programs to assign variable and print it


 #include<stdio.h>
#include<conio.h>


void main()
{
     int a;       \\ declaration of intiger type variable

     a=10;    \\it assign value 10 into variable a

     printf("value of a = %d",a);

 \* here printf is library function that use to print  any massage or value of variable,,,,,%d is access specifier that specify intiger type value of variable *\

   getch();
}

Output :

value of a = 10

0 comments:

Find Given number is prime or not

Monday, February 15, 2016 Unknown 0 Comments

Find The Given Number Is Prime or Not


#include<iostream>
#include<conio.h>
void main()
{
  int n,i,flag=0;
  cout<<"Enter a positive integer: ";
  cin>>n; 
  for(i=2;i<=n/2;++i)
  {
      if(n%i==0)
      {
          flag=1;
          break;
      }
  } 
  if(flag==0)

      cout<<"This is a prime number"; 
   }
 else
   {
       cout<<"This is not a prime number"; 
   }
 getch(); 
 }
 
Output

Enter a positive integer: 29
This is a prime number.


0 comments:

Simple Single Inheritance

Sunday, February 14, 2016 Unknown 0 Comments

Simple Single Inheritance


Definition: -
                               A class derived from only one base class is called Single inheritance.



#include<iostream.h>
#include<conio.h>

class A
{
    public:
    void showA()
    {
        cout<<"This is class A";
    }
};
class B:public A
{
    public:
    void showB()
    {
        cout<<"\nThis is class B";
    }
};
void main()
{
    B B1;
    clrscr();
    B1.showA();
    B1.showB();
    getch();
}

OUTPUT:


This is class A
This is class B

0 comments:

Virtual Base Class

Monday, January 11, 2016 Unknown 0 Comments

Virtual Base Class

#include<iostream.h>
#include<conio.h>
class A
{
         public:
         void showA()
         {
                  cout<<"This is Class A";
          }
};
class B:virtual public A
{
       public:
       void showB()
       {
                  cout<<"This is class B";
        }
};
class C:virtual public A
{
       public:
       void showC()
       {
             cout<<"This is class C";
       }
};
class D:public B,pubic C
{
       public:
       void showD()
      {
            cout<<"This is class D";
      }
};
void main()
{
       D D1;
       D1.showA();
       D1.showB();
       D1.showC();
       D1.showD();
       getch();
}

OUTPUT;

This is class A
This is class B
This is class C
This is class D

0 comments:

To Create Simple Calculator

Monday, January 11, 2016 Unknown 0 Comments

 Simple Calculator

#include<iostream.h>
#include<conio.h>

void main()
{
    float a,b,ans;
    int choice;
    clrscr();
    cout<<"\n1.Addition\n2.Subtraction";
    cout<<"\n3.Multiplication\n4.Division";
    cout<<"\nEnter your choice(1 to 4) : ";
    cin>>choice;
    cout<<"Enter value of A & B : ";
    cin>>a>>b;

    switch(choice)
    {
        case 1:ans=a+b;
               break;
        case 2:ans=a-b;
               break;
        case 3:ans=a*b;
               break;
        case 4:ans=a/b;
               break;
        default:cout<<"Wrong Choice....";
    };
    cout<<"Answer = "<<ans;
    getch();
}

OutPut:

1.Addition
2.Subtraction
3.Multiplication
4.Division
Enter your choice(1 to 4) : 1

Enter value of A & B : 5  6
Answer = 11 

0 comments: