Skip to main content

Posts

Showing posts from August, 2018

Control Statements in C

Control statements or programming constructs are those statements that determine order in which other statements of program are to be executed by computer. Generally execution of statements within program happens sequentially in order they are written. This execution starts from first statement of main and executing all statements stops at last statement of main. But in many cases we need not to execute all statements within main and we have to execute some statements or skip some statements or execute some statements more than once. In such cases we have to use control statements. There are following three types of control statements available in C-Language

Control statements या programming constructs उन statements को कहा जाता है जो यह निर्धारित करते है कि प्रोग्राम के अन्य statements किस क्रम में कम्प्यूटर के द्वारा execute होंगे। सामान्यतः प्रोग्राम में statements का execution उसी क्रम में होता है जिस क्रम में वे लिखे होते है। यह execution main के पहले statement से start होता है औ…

Data Types in C++

Data type is a well defined collection of data (values). In any program variables are used to store data. These variables are associated with a particular data type which determines what type and upto what range of data can be stored in it and what operations can be performed. C++ Language has following three types of data type:
Data Type, data(values) का सुपरिभाषित (well defined) संग्रहहोता है। किसी भी प्रोग्राम में data को स्टोर करने के लिए variables का प्रयोग किया जाता है। ये variable किसी विशेष data type से संबंधित होते है जो यह निर्धारित करता है कि इन variables में किस type का एवं कितने range तकका data स्टोर किया जाता सकता है और क्या-क्या operations किए जा सकते है।C++ Language में निम्नलिखित तीन प्रकार के data types होते है—
1. Fundamental Data Types - int, char, float, double, void 3. Derived Data Types - array, function, pointer 4. User Defined Data Types - class, struct, union, enum, typedef
Fundamentals Data Types Fundamentals data types are also called built in data types or primi…

Data Types in C

Data type is a well defined collection of data (values). In any program variables are used to store data. These variables are associated with a particular data type which determines what type and upto what range of data can be stored in it and what operations can be performed. C-Language has following three types of data type:
Data Type, data(values) का सुपरिभाषित (well defined) संग्रहहोता है। किसी भी प्रोग्राम में data को स्टोर करने के लिए variables का प्रयोग किया जाता है। ये variable किसी विशेष data type से संबंधित होते है जो यह निर्धारित करता है कि इन variables में किस type का एवं कितने range तकका data स्टोर किया जाता सकता है और क्या-क्या operations किए जा सकते है।C-Language में निम्नलिखित तीन प्रकार के data types होते है—
1. Fundamental Data Types - int, char, float, double, void 3. Derived Data Types - array, function, pointer 4. User Defined Data Types - struct, union, enum, typedef
Fundamentals Data Types Fundamentals data types are also called built in data types or primitive data t…

Write a C C++ program to generate series of even numbers and their sum

Flowchart


Coding in C

#include<stdio.h>
int main()
{
    int num=2,n,sum=0;
    printf("Enter n: ");
    scanf("%d",&n);
    while(num<=n)
    {
        printf("%d\n",num);
        sum=sum+num;
        num=num+2;
    }
    printf("Sum of series = %d",sum);
    return 0;
}

Coding in C++

#include<iostream>
using namespace std;
int main()
{
    int num=2,n,sum=0;
    cout<<"Enter n: ";
    cin>>n;
    while(num<=n)
    {
        cout<<num<<"\n";
        sum=sum+num;
        num=num+2;
    }
    cout<<"Sum of series = "<<sum;
    return 0;
}

Output