Skip to main content

Posts

Showing posts from July, 2018

Tokens in C++

Tokens are basic building blocks of C++ program. They are made of single character or group of characters. They are recognized as a basic meaningful unit of C++ program by C++ compiler while translating the source code into machine code. They can not be divided into more meaningful units. C ++ language has following types of tokens:
Token C++ program के basic building blocks होते है। ये एक character या character के समूह के बने होते है।  इन्हें C++ Compiler के द्वारा source code को machine code में translate करते समय प्रोग्राम के basic meaningful unit के रूप में पहचाना जाता है। इन्हें और अधिक meaningful unit में विभाजित नहीं किया जा सकता है। C++ Language में  निम्नलिखित प्रकार के tokens होते है—
1. Keywords 2. Identifiers 3. Constants 4. Operators 5. Strings

1. Keywords
Keywords are predefined words for performing various tasks in C++. They are also called reserved words or commands of C++. They are always written in small letters. There are about 63 keywords in C++. 
C++-Language में व…

Tokens in C

Tokens are basic building blocks of C program. They are made of single character or group of characters. They are recognized as a basic meaningful unit of C program by C compiler while translating the source code into machine code. They can not be divided into more meaningful units. C language has following types of tokens:
Token C program के basic building blocks होते है। ये एक character या character के समूह के बने होते है।  इन्हें C-Compiler के द्वारा source code को machine code में translate करते समय प्रोग्राम के basic meaningful unit के रूप में पहचाना जाता है। इन्हें और अधिक meaningful unit में विभाजित नहीं किया जा सकता है। C-Language में  निम्नलिखित प्रकार के tokens होते है—
1. Keywords
2. Identifiers
3. Constants
4. Operators
5. Strings


1. Keywords

Keywords are predefined words for performing various tasks in C. They are also called reserved words or commands of C. They are always written in small letters. There are total 32 keywords in C. 
C-Language में विभिन्न प्रकार के कार्यो…

Write a C C++ program to check whether given year is leap or not

Flowchart

Coding in C

#include<stdio.h>
int main()
{
    int y;
    printf("Enter an year: ");
    scanf("%d",&y);
    if(y%4==0&&y%100!=0||y%400==0)
    {
        printf("Leap year");
    }
    else
    {
        printf("Not a leap year");
    }
    return 0;
}

Coding in C++

#include<iostream>
using namespace std;
int main()
{
    int y;
    cout<<"Enter an year: ";
    cin>>y;
    if(y%4==0&&y%100!=0||y%400==0)
    {
        cout<<"Leap year";
    }
    else
    {
        cout<<"Not a leap year";
    }
    return 0;
}

Output

Write a C C++ program to find total and percent from marks obtained

Flowchart



Coding in C

#include<stdio.h>
int main()
{
    int s1,s2,s3,s4,s5,t;
    float p;
    printf("Enter marks of five subjects: ");
    scanf("%d%d%d%d%d",&s1,&s2,&s3,&s4,&s5);
    t=s1+s2+s3+s4+s5;
    p=t/5.0;
    printf("Total = %d Percent = %f",t,p);
    return 0;
}


Coding in C++

#include<iostream>
using namespace std;
int main()
{
    int s1,s2,s3,s4,s5,t;
    float p;
    cout<<"Enter marks of five subjects: ";
    cin>>s1>>s2>>s3>>s4>>s5;
    t=s1+s2+s3+s4+s5;
    p=t/5.0;
    cout<<"Total = "<<t<<" Percent = "<<p;
    return 0;
}

Output