Showing posts with label c basic program. Show all posts
Showing posts with label c basic program. Show all posts

Friday, March 9, 2012

Program to Interchange the value.

//Program to Interchange the value.
#include<stdio.h>
#include<conio.h>
main()
{ int a,b,temp;
 printf("Enter the value of a and b -");
 scanf("%d%d",&a,&b);
 temp=a;
 a=b;
 b=temp;
 printf("The changed value of a and b -%d & %d",a,b);
 getch();
}


Program to print negative no.

//Program to print negative no.
#include<stdio.h>
#include<conio.h>
main()
{
      int i,n;
      printf("Enter any no  ");
      scanf("%d",&n);
      for(i=1;i<=n;i++)
      {
       printf("%d\n",-i);
       }
       getch();
       }

Thursday, March 8, 2012

Enter any charecter and get ASCII value.

//Enter any charecter and get ASCII value.
#include<stdio.h>
#include<conio.h>
main( )
{ char a;
int n;
printf("enter the char--");
scanf("%c",&a);
printf("%d",a);
getch();
}

Program to sum two no

//sum of two no
#include<stdio.h>
#include<conio.h>
main( )
{  int  n,m,s;
   printf("Enter two no --");
   scanf("%d%d",&n,&m);
   s=n+m;
   printf("The sum of two no-%d ",s);
   getch();
}

Wednesday, March 7, 2012

Calculation of simple interest

/* Calculation of simple interest */
#include<stdio.h>
#include<conio.h>
main( )
{
int p, n ;
float r, si ;
printf( "Enter values of p, n(year),r(rate)" ) ;
scanf ( "%d %d %f", &p, &n, &r ) ;
si = p * n * r / 100 ;
printf ("%f",si);
getch();
}

welcome to c

// Welcome to c programming.
#include<stdio.h>
#include<conio.h>
 main()
{
       printf("Welcome to c programming ");
       printf("\n");
       printf("This is our first program");
       getch();
       }
This is basic c program.This program doesn't take any input from the user .