Skip to content
Utopper skill
  • ProgrammingExpand
    • Programming Examples
  • Interview QuestionsExpand
    • DevOps Interview Questions
    • Android Interview Questions
  • How to
  • Tools
  • Top 10
  • Book Summaries
Utopper skill

Comments in C Programming

C Programming Course

Page Index


C Overview

C Environmental Setup

C Program Structure

C Basic Syntax

C Programming Blocks

C Printf and Scanf

C Data Type

C Variables

C Constant

C Keywords

C Operators

C Comments

C Identifier

C Literals

C Tokens

C Format Specifier

ASCII Value in C

C If Statement

C If Else Statement

C Nested If Statement

C Switch Case

C Nested Switch

C If Else vs Switch

C Loops

C For Loop

C While Loop

C Do While Loop

Nested Loop in C

Infinite Loop in C

C Break

C Continue

C goto

Typecasting in C

C Function Basic

Call By Value

Call By Reference

Recursion in C

Storage Classes

C Array Basics

1-D Array in C

2-D Array in C

Passing Array to Function

Return Array from a Function

Multi-Dimensional Array in C

Pointer to an Array in C

C Pointer

Pointer Arithmetic

Array of Pointers

C Pointer to Pointer

Passing Pointer to Function in C

Return Pointer From Function in C

Dangling Pointer in C

sizeof() Operators in C

Const Pointers in C

Void Pointer in C

C Deference Pointer

Null Pointer in C

C Function Pointer

C String Basics

C gets() and puts()

C String Function

C Structure Basics

typedef in C

C Bit Fields

C Array of Structure

C Nested Structure

Structure Padding in C

C Union

C File Handling Basics

C fprintf() fscanf()

C fputc() fgetc()

C fputs() fgets()

C fseek()

C rewind()

C ftell()

C Preprocessor Basics

C Macros

C #include

C #define

C #undef

C #ifdef()

C #ifndef()

Comments In C programming language are used to add notes or explanations to the code that are not interpreted by the compiler. Comments are meant to be read by other programmers, rather than by the computer.

There are two types of comments in C:

  1. Single line comments: These comments begin with two forward slashes (//) and continue until the end of the line. Single-line comments are typically used to provide brief explanations or to temporarily disable a line of code. For example:
// This is a single-line comment in C
  1. Multi line comments: These comments begin with /* and end with */. Multi-line comments are used for longer explanations or to comment out multiple lines of code. For example:
/* This is a multi-line comment in C
   It can span multiple lines
   and provide more detailed explanations */

Comments are useful for providing context and improving the readability of code. Good comments can help other programmers understand what the code does, how it works, and why certain decisions were made. It is important to use comments sparingly and to keep them up-to-date, as outdated or incorrect comments can be misleading.

Code to Explain the Comments in C Programming

/*
This is a multi-line comment in C.
It can span multiple lines and is useful for longer explanations or for temporarily disabling multiple lines of code.
In this example, the comment explains that the program prints "Hello, world!" to the console.
*/

#include <stdio.h>int main() {
    // Print "Hello, world!" to the console
    printf("Hello, world!\\n");

    return 0;
}

In this example, the multi-line comment spans four lines and explains the purpose of the program: to print “Hello, world!” to the console. The comment is enclosed in /* and / characters, and each line of the comment starts with an asterisk (). The comment provides additional context and makes the code easier to understand for other programmers who might be reading the code.

It’s important to note that comments are not executed by the computer and do not affect the behaviour of the program. They are only meant to be read and understood by other programmers.


Our Latest Posts

  • Git Interview Questions
    35 + GIT Interview Questions
  • Book Summary of Why We Sleep By Matthew Walker
    Book Summary of Why We Sleep By Matthew Walker
  • C Program to Print Your Own Name
    C Program to Print Your Own Name with Example
  • Facebook
  • Instagram
  • YouTube
  • Telegram
  • LinkedIn
  • Twitter

Mail : [email protected]

Privacy Policy | DISCLAIMER | Contact Us

Learn Development

learn HTML

learn CSS

learn JavaScript

Examples

C Examples

C++ Examples

Java Examples

Study Material

Interview Questions

How to

Hosting

SEO

Blogging

© 2023 Utopper.com

All Rights Reserved with Copyright & Registered TradeMarks
OWNED BY : GROWTH EDUCATION SOLUTIONS PRIVATE LIMITED

Scroll to top
  • Programming
    • Programming Examples
  • Interview Questions
    • DevOps Interview Questions
    • Android Interview Questions
  • How to
  • Tools
  • Top 10
  • Book Summaries
Search