Basic Program Using C Language

What is the meaning of i+=2 in C programming language?

  • It is the same as i=i+2;
  • It makes the code a little bit shorter. No effect on execution time.

C program to find area of square using default argument

#include <stdio.h>
using namespace std;
int squareD(int i=8,int l=7)//we have two default argument
{
    return (i*i);
};
int main()
{  int result;
    printf("Program for area of square using default argument");
    result=squareD(5);// here 5 is argument that we have pass
    printf("\nThe square is");
    printf("\n%d",result);
    result=squareD();// here we have not pass anything[ Default argument]
    printf("\nThe square is");
    printf("\n%d",result);// We have not used the value of L

    return 0;
}

Output:

Program for area of square using default argument
The square is
25
The square is
64

Leave a Reply

Your email address will not be published. Required fields are marked *