Structure of C/C++ Program

Posted on at


 

Structure of C/C++

   The structure of program have group of element which is called member these group of elements combine and make a strong program,In structure use number of variables under the same name the structure of any program is like as

 #include<studio.h>

#include<string.h>

struct boy

{

  int rollno;

  char name[200];

  float percentage;

 };

int main()

  {

    struct boy record=0;

    record.rollno=1;

    stropy(record.name,"bashir");

    record.percentage =90;

    printf("rollno :is  \n",record.rollno);

   printf("name:is \n",record.name);

   printf("percentage:is \n",record.percentage);

        }

 

C/C++ comment

  Is basically not a part of program but it really very help full for a program because in at the end of eachline of program the programer write the comments for to understand.This comments are in text form it can be */, /*, // etc.

C/C++ libraries

In library the data ,information and detail of global variable or pre defined class or file stored like studio.h,  string.h  ,math.h,local.h etc,these all the library files

C/C++ data type

Before the use of any thing we need to define like if we use any variable we first defined it like whats this variable which used and whats its data type .like int,float,char etc

 Size of Operator

  The basically give the storage size in bytes and operand type object can store.like sizeof(type-name)

 Declaring variable and constant

 These variables are store in reserve storage called EGL program and the constant can not change during run time.we declare the variables and constant before use in program like we tell the data type and its function .

 Assignment and multiple Assignment operator 

  Assignment operator assign value from right side like = mean  if a=1 is right but 2=x is wrong because the value not assigned from right side.while multiple assignment operator also use for assign values but assign multiple like a=b=c=3 etc

 How to assign String data?

 Basically string are use to arrange the characters in sequence from 1 ,2 and up to so on for to print the string like we use output command like ...count<<"my name is bashir"<<endl;and also use like to arrange the character we use like so
#include<string.h>

char str[20];

char str1[20]="i am bashir"

char str2[]="call me";

  Priority of Operations

   well the operation must perform according to priority like high priority first and low priority next and if priority equal then evaluate from left to right side the priorities are define as in picture below

Types Casting operator 

casting basically use to convert one type scalar into other type like

float a=5.3

int=b;

b=(int)a// the value of b know 5 

Increment(++) and  Decrement(--) operators

Increment are use to increase the value one by one mean after each step the value increase once and decrement use for to decrease the value one by one means after each step the value goes minus.

Compound Assignment operator

It is use to assign the shorter syntax result of any arithmetic and bitwise operator 

 



160