Monday, 4 November 2013

C program to find average of 3 integers ( average of 3 numbers)

C program to find average of 3 integers ( average of 3 numbers)

#include<stdio.h>
#include<conio.h>
main()
{
int n,s,r,avg;
clrscr();
printf("\nEnter 3 numbers : \t"); 
scanf("%d%d%d",&n,&s,&r);
avg=(n+s+r)/3;
printf("\nAverage of 3 numbers is: %d ", avg);
getch();
return 0;
}


OUTPUT:

 Enter 3 numbers: 15 6 8

Average of 3 numbers is: 9

 

Sunday, 3 November 2013

C program to display ASCII code of a character

Program to display ASCII code of a character:

#include<stdio.h>
#include<conio.h>
main()
{
char n;
clrscr();
printf("\nEnter a character: \t");
scanf("%c",&n);
printf("Result: %c",n); 
getch();
return 0;
}


OUTPUT:

Enter a character: A

Result: 65  

C program to print square of a number given by the user

Program to print square of a number given by the user

#include<stdio.h>
#include<conio.h>
main()
{
int n,sq;
clrscr();
printf("\nEnter a number:\t");
scanf("%d",&n);
sq=n*n;
printf("Result: %d",sq);
getch();
return 0;
}


OUTPUT:

Enter a number: 3

Result: 9 

C program to add 2 integers ( program to add 2 numbers)

Program to add 2 integers ( program to add 2 numbers)

#include<stdio.h>
#include<conio.h>
main()
{
int n,i,sum;
clrscr();
printf("\nEnter two numbers:\t");
scanf("Sum=%d",sum);
getch();
return 0;
}


OUTPUT:

Enter two numbers: 5 6

Sum= 11 

C program to print "Good Morning"

Program to print "Good Morning"

#include<stdio.h>
#include<conio.h>
main()
{
clrscr();
printf("Good Morning!");
gect();
}

Output:

Good Morning!

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Lady Gaga, Salman Khan