Skip to main content

Comments in C

 Comment is the code which is not executable means compiler will not compile the comments and that’s why comments are not visible on output screen.


Two types of Commenting:

Type 1: double slash ‘//’ method the whole statement after double slash is not executed by compiler
Example: try to run below code its output will be blank screen

#include <stdio.h>
void main(){
// printf (“Hello World!”);
}
#include<stdio.h>
void main ( ){ //Comments
// Comment
printf (“Hello World!”);//abc
}
#include<stdio.h>
//Comments
void main(){
//Comments
printf(“Hello World”);
}
o/p: blank screen
O/p: Hello World!
O/p: Hello World

In this way you can give multiple comments anywhere in the program but double slash is used to 
comment only single line for commenting multiple lines use type 2. 

Type 2: For multiline commenting or for commenting a whole paragraph from the program we have 
to add /* at the start of comment and */ at the end of comment as shown in examples:

#include <stdio.h>
void main(){
/*
printf (“Hello World!”);
printf (“Hello World!”);
*/
}
#include<stdio.h>
void main ( ){ //Comments
/* Comment*/
printf (“Hello World!”);//abc
}
#include<stdio.h>
/*
Comments*/
void main(){
//Comments
printf(“Hello World”);
}
o/p: blank screen
O/p: Hello World!
O/p: Hello World

In above example at a time // and /**/ comments you can use in code.

Uses of Comments: Comments are optional in program but it is very helpful to write our own notes 
inside the program just for our convenience.










Comments

Popular posts from this blog

Why should I learn Computer language (Programming)? And why C language good for beginners?

1. Software is the spirit  ( आत्मा )  of hardware . 2. Just by joining some hardware (Electronics  Components) we can’t make our  Computers, Laptops, Mobiles, Tablets, etc. so programming is essential to make this hardware functional. 3. Program instructs and controls the hardware and C is the very basic language to start. 1. By learning a computer language you'll able to build your own software, OS, Virus, Antivirus. For example, WhatsApp, Hike, Calculator,  Media  Player, Facebook, Twitter. 5. After learning the C language you'll be able to build your own computer applications. 6. C language Helps to learn more advanced languages like Java, Dot Net, MATLAB. because this all language depends upon C language. 7. It is good for starters because it is just like the English language and easy to understand.

C-Compiler for Mobile Phone

Run your C language programs on Android Mobile I hope you may aware of the C language compiler. For more information, you may visit on Compilers Page  on my blog. So many C language programmer uses Android but they are not aware of they could run their programs on their phone itself. Even I had the same problem in my first year of Engineering. C-Compiler for Android Mobile Cpp Droid CppDroid is a mobile application that provides an environment to run your C language program this app is installed by  500,000 - 1,000,000  from google play. Download Cpp Droid from here   Steps to run program in CppDroid: Step 1: Download and install CppDroid from play store step2: Open CppDroid step 3: Go to Editor step 4: Type a program step 5: save it as .c extension step 6:  Click on run step 7:Output

Why C language is compulsory for all branches in Engineering

Every student in schools and even I also thinks that why, why, why it is compulsory to learn C for students  other than computer & IT branch? What is the need of C  for  Civil  Engineering, Mechanical  Engineering,  Electrical  Engineering,  Electronics  Engineering, Production Engineering, Instrumentation Engineering, Chemical Engineering?  Let’s see in short use of C in some core Engineering branches: Civil Engineering: Chemical Engineering: Mechanical Engineering: Electrical Engineering: Electronics Engineering:  For  other  branches, I  will  like  to  mention  that  Civil  Engineering,  Mechanical  Engineering and Electrical Engineering are known as core branches means all branches in  engineering have come after these engineering branches then you can think that C is also useful for other engineering branches. That’s why don’t take it easy to be serious about C.