Advertisement
Guest User

Untitled

a guest
Oct 18th, 2018
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. //function definition
  4. int square(int num){
  5. //returns square of num
  6.     int numSquared;
  7.  
  8.     numSquared = num * num;
  9.     return numSquared;
  10. }
  11.  
  12. int main(void){
  13.  
  14.     int input;
  15.     int answer;
  16.  
  17.     printf("Enter a number to be squared!\n");
  18.     scanf("%d", &input);
  19. //stores square of input into var answer (function declaration)
  20.     answer = square(input);
  21.     printf("%d squared is %d!\n",input, answer);
  22.  
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement