Answers:
We can use void main() to indicate to the OS that it will not return value back. To be on the safer side, we write int main(), to indicate all has gone well by returning 0 (convention of the Operating System).
#include<stdio.h>
void main()
{
int n,square;
clrscr() ;
printf ("enter the value of n") ;
scanf("%d", &n) ;
square=n*n;
printf ("square=%d") ;
getch() ;
}
#include<stdio.h>
int mun(int num)
{
int square=num*num;
}
int main()
{
int square;
square=mun(16);
printf("square is %d\n", square);
return 0;
}
#include<iostream>
using namespace std;
int mun(int num)
{
int square=num*num;
}
int main()
{
int square;
square=mun(16);
cout<<"square is %d\n"<<square;
return 0;
}
#include<stdio.h>
void main()
{
int n,square;
clrscr() ;
printf ("enter the value of n") ;
scanf("%d", &n) ;
square=n*n;
printf ("square=%d") ;
getch() ;
}
Output is as follows
n= 9
square=81
//Assignment 4
// c program of square of number
#include<stdio.h>
void main()
{
int n, square ;
printf("enter the value of n \n");
scanf("%d", &n);
square=n*n;
printf("square=%d", square);
getch();
}
Output is as follows
n=6
square=36
#include<stdio.h>
void main()
{
int n, square;
printf("enter the value of n \n");
scanf("%d", &n);
square=n*n;
printf("square=%d", square);
getch();
}
Output is as follows
n=4
square=16
#include<stdio.h>
void main ()
{
int n, square;
printf("enter the value of n \n");
sang("%d",&n);
square=n*n;
printf("square=%d",square);
getch ();
}
Output of this program will be
n=5
square =25
#include<studio.h>
void main()
{
int n, square;
printf("Enter the value of n");
scand("%d",&n);
square=n*n;
printf("\n square=%d", square);
getch();
}
*****Output*****
n=9
square=81
#include<studio.h>
Void main()
{
int n,square;
Printf("Enter the value of n ");
Scanf("%d",&n);
Square=n*n;
Printf("\n square=%d", square);
getch();
}
Output of this program wii be
n=5
Square=25
<font size="4">Program in c to find the square of a number:</font>
#include <stdio.h>
int square(int x)
{
int sq=x * x;
}
int main()
{
int a;
printf("Enter the value of a:\n");
scanf("%d",&a);
int s =square(a);
printf("Square of %d is %d ",a,s);
return 0;
}
Output:
Enter the value of a:
4
Square of 4 is 16
<font size="4">Program in cpp to find the square of a number:</font>
#include <iostream>
using namespace std;
int square(int x)
{
int sq=x * x;
}
int main()
{
int a;
cout<<"Enter the value of a:\n";
cin>>a;
int s =square(a);
cout<<"Square of "<<a<<" is " <<s;
}
output:
Enter the value of a:
4
Square of 4 is 16
Login to add comment