Showing posts with label find. Show all posts
Showing posts with label find. Show all posts
Monday, February 16, 2015
C program to find cube of a number using macros

Also Read: C++ program to swap two numbers using macros
Also Read: C++ Program to find cube of a number using function
#include<iostream.h>
#include<conio.h>
#define CUBE(x) (x*x*x)
void main()
{
clrscr();
int n,cube;
cout<<"Enter a number:";
cin>>n;
cube=CUBE(n);
cout<<"Cube="<<cube;
getch();
}
Friday, February 13, 2015
C program to find sum of two numbers
#include<conio.h>
void main()
{
int a,b,sum;
clrscr(); //to clear the screen
printf("Enter first no:");
scanf("%d",&a);
printf("Enter second no:");
scanf("%d",&b);
sum=a+b;
printf("
Sum=%d",sum);
getch(); //to stop the screen
}
Subscribe to:
Posts (Atom)