Tuesday, November 07, 2017

Write a Program (WAP) to print the cube of the given number.


//Program

#include<stdio.h>  
#include<conio.h>  
void main()
{  
    int number;  
    clrscr();  
    printf("enter a number:");  
    scanf("%d",&number);  
    printf("cube of number is:%d ",number*number*number);  
   getch();  

}  

Output
enter a number:5
cube of number is:125

Explanation:
¾     In int number; int is the data type and number is the variable name (both discuss later).
¾     The scanf() function is used for input. It reads the input data from the console.
¾     The scanf("%d",&number) statement reads integer number from the console and stores the given value in number variable.
¾     The syntax of scanf() function is given below:

scanf("format string",argument_list)

The printf("cube of number is:%d ",number*number*number) statement prints the cube of number on the console.
Post a Comment

C language Introduction

The C Language is developed for creating system applications that direct interacts to the hardware devices such as drivers, kernels etc. C...