5 Best Online Compilers

Here you will get list of 5 best online compilers. Are you getting bored of using c, c++, java or any other compilers in your computer? If yes then here I come with a solution. In this article I am going to share some websites that provide facility to compile and run programs of different …

5 Best Online Compilers Read More »

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(); }

C program to count number of words in a string

#include<stdio.h> #include<conio.h> void main() { int i,words=1; char str[100]; clrscr(); printf(“Enter a string:”); gets(str); for(i=0;str[i]!=’’;++i) if(str[i]==’ ‘) words++; printf(“No. of words are %d”,words); getch(); }

C++ program to swap two numbers using pointers

#include<iostream.h> #include<conio.h> void main() { clrscr(); int *a,*b,*temp; cout<<“Enter value of a and b:”; cin>>*a>>*b; temp=a; a=b; b=temp; cout<<“nAfter swapingna=”<<*a<<“nb=”<<*b; getch(); }