Comments are used in C programming language to provide information about lines of code.
There are two types of comments in C programming language.
Single Line Comments: -
Single line comment is used for single line and are represented by double slash i.e \\
Example of Single line comment
Write a program to print sum of two numbers
#include<stdio.h>
#include<conio.h>
int b;
void main()
{
int a,c;//Local variable
clrscr();
printf("enter the two number ");
scanf("%d %d",&a, &b);
c=a+b;
printf("sum of two number = %d ",c);
getch();
}
OUTPUT:-
Enter the number 6
7
Sum of two number = 13
Multi Line Comments:-
Multi line comments is used for multi lines and are represented by slash asterisk i.e /* .............*/
Example of Multi line comment
Write a program to print sum of two numbers
#include<stdio.h>
#include<conio.h>
int b;
void main()
{
int a,c;//Local variable
clrscr();
printf("enter the two number ");/* printf() and scanf() functions are used for input and output in C language. Both functions are inbuilt library functions, defined in
stdio.h(header file).*/
scanf("%d %d",&a, &b);
c=a+b;
printf("sum of two number = %d ",c);
getch();
}
OUTPUT:-
Enter the number 6
7
Sum of two number = 13
Escape sequence in C
No comments:
Post a Comment