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: