2.Comment,Character And Variables in C | C Tutorials for Beginners #2

2.Comment,Character And Variables in C | C Tutorials for Beginners #2

https://harshaup.blogspot.com/2021/05/


 * Comment :-

1.Single Line Comment

you can understand the single line comment by seeing the below example.

It  Can be placed anywhere.
Single Line Comment starts with //
Any Symbols written after // are ignored by the compiler

 Example :

#include<stdio.h>
void main()
{
printf("Hello codeharsh"); //Single line comment 
           // channel name codeharsh

}

2.Multi Line Comment

It  can be placed anywhere. 1.Single Line Comment

you can understand the single line comment by seeing the below example.

It  Can be placed anywhere.
Single Line Comment starts with //
Any Symbols written after // are ignored by the compiler

 Example :

#include<stdio.h>
void main()
{
printf("Hello codeharsh"); //Single line comment 
           // channel name codeharsh

}

It starts with /*.
It ends with */.
Any symbols written between '/'  and '/' are ignored by Compiler.
It can be split over multiple lines.

#include<stdio.h>
void main()
{
printf("Hello codeharsh");
/* you can watch
       our video
  on you tube channel name : codeharsh
*/
}

Q.Difference Between Single Line and Multi line Comment ?
A. Multiline Comment  :-1.Single-line Comments
It Starts with /* and ends with */  2.e.g /* This is Multiline Comment */ 
B.Single-line Comment:- 1. It Starts with //
All Words and Statements written between /* and */ are ignored Statements after the symbol // upto the end of line are ignored 2.e.g // Single line Comment

*C Token:-


In C Programming punctuation,individual words,characters etc are called tokens.
Keywords in C Programming Language :

Keywords are those words whose meaning is already defined by Compiler
Cannot be used as Variable Name
There are 32 Keywords in C
C Keywords are also called as Reserved words .
Keywords in C Programming
auto break      case          char
const         continue   default do
double        else     enum extern
float                for          goto if
int           long      register return
short     signed      sizeof   static
struct     switch        typedef union
unsigned   void         volatile while


*C Identifier :-

An identifier is a string of alphanumeric characters that begins with an alphabetic character or an underscore character that are used to represent various programming elements such as variables, functions, arrays, structures, unions and so on.


*Character Set :-

 character:-          It denotes any alphabet, digit or special symbol used to represent information. 

Use:-                      These characters can be combined to form variables. C uses constants, variables, operators, keywords and expressions as building blocks to form a basic C program. 

Character set:-    The character set is the fundamental raw material of any language and they are used to represent information. Like natural languages, computer language will also have well defined character set, which is useful to build the programs. 

The characters in C are grouped into the following two categories:

1.      Source character set
                                a.      Alphabets
                                b.      Digits
                                c.      Special Characters
                                d.      White Spaces

2.      Execution character set
                                a.     Escape Sequence

 Q.What is Variable in C Programming

A variable is nothing but a name given to a storage area that our programs can manipulate. Each variable in C has a specific type, which determines the size and layout of the variable's memory; the range of values that can be stored within that memory; and the set of operations that can be applied to the variable.

Type       Description
char           Typically a single octet(one byte). This is an integer type.
int          The most natural size of integer for the machine.
float          A single-precision floating point value.
double  A double-precision floating point value.
void          Represents the absence of type.

 Q.What is variable declaration?

ans: A variable is nothing but it provides assurance to the compiler that there exists a variable with the given type

Example:

#include<stdio.h>

 // Variable declaration:

extern int a, b;

extern int c;

extern float f;

void main ()

{

 /* variable definition: */

 int a, b;

int c;

float f;

/* actual initialization */

a = 10;

b = 20;

c = a + b;

printf("value of c : %d \n", c);

f = 70.0/3.0;

printf("value of f : %f \n", f);

}

# C programs :-

1.# include<stdio.h>
/*
This is our first c program
which is awesome!
*/
int main(){
    int tom;
    int Tom;
    // Declaring variables to store error codes
    int error_code;
    // 'J' --> a character
    printf("Hello I am learning C with Harsh");
    return 0;
}

2.#include<stdio.h>

int main(){
    int length=3, breadth=8;
    int area = length*breadth;
    printf("The area of this rectangle is %d", area);
    return 0;
}

3.#include<stdio.h>

int main(){
    int length, breadth;
    printf("What is the length of the rectangle\n");
    scanf("%d", &length);

    printf("What is the breadth of the rectangle\n");
    scanf("%d", &breadth);

    printf("The area of your rectangle is %d", length*breadth);
    return 0;
}

3.#include<stdio.h>

int main(){
    int length, breadth;
    printf("What is the length of the rectangle\n");
    scanf("%d", &length);

    printf("What is the breadth of the rectangle\n");
    scanf("%d", &breadth);

    printf("The area of your rectangle is %d", length*breadth);
    return 0;
}

4.#include <stdio.h>

int main()
{
    int radius = 3;
    float pi = 3.14;
    printf("The area of this circle is %f\n", pi * radius * radius);
    int height = 3;
    printf("Volume of this cylinder is %f\n", pi * radius * radius * height);
    return 0;
}

5.#include <stdio.h>
/*
This is our first c program
which is awesome!
*/
int main()
{
    int a = 4;
    // int b = 8.5; // Not recommended because 8.5 is not an integer
    float b = 8.5;
    char c = 'u';
    int d = 45;
    int e = 45 + 4;
    printf("The value of a is %d \n", a);
    printf("The value of b is %f \n", b);
    printf("The value of c is %c \n", c);
    printf("Sum of a and d is %d \n", a - d);
    printf("Sum of a and d is %d \n", e);
    return 0;
}

Thanku.


No comments

Comments system

Powered by Blogger.