error

I am getting error in this code
main must return int==

#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,c;
cout<<"enter the number";
cin>>a>>b;
c=a+b;
cout<<"required sum is"<<c;
getch();
}
void main should be int main

So you example should be
1
2
3
4
5
6
7
8
9
10
11
12
#include<iostream.h>
#include<conio.h>
int main()
{
int a,b,c;
cout<<"enter the number";
cin>>a>>b;
c=a+b;
cout<<"required sum is"<<c;
getch();
return 0;//should be return int
}
Last edited on
I am using Devc++ but i am not familiar with this. Please give me any link so that i can download Any other c++ compiler such that white screen turbo.
I think you just have to edit your source file.
adding to my above post...
I am again getting two errors this time after using codes provided by you.
These are the errors which i am getting now.

In file included from C:/Dev-Cpp/include/c++/3.4.2/backward/iostream.h:31,
from C:\Documents and Settings\Admin\My Documents\Untitled1.cpp:1:
C:/Dev-Cpp/include/c++/3.4.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.

/mingw/lib/crt2.o(.text+0x37):crt1.c: undefined reference to `__cpu_features_init'
collect2: ld returned 1 exit status

Execution terminated
Try it again
1
2
3
4
5
6
7
8
9
10
11
12
13
#include<iostream>

int main()
{
    std::cout << "enter the number\n";
    int a(0);
    int b(0);
    std::cin>>a>>b;

    std::cout << "required sum is " << a+b << '\n';

    return 0;
}
Actually i am starting c++ again.
This time I am getting problem By using codes provided by you.
[Linker error] undefined reference to `__cpu_features_init'
ld returned 1 exit status
It seems that your compiler doesn't support C++ standard.

Please try g++4.x under Linux or VS 2008 express edition under Windows(also you can try MinGW)
VS 2008 express edition under Windows

I will try this one.
U mean that visual studio 2008.
I had that, as I am doing .NET. Can i use this for c++. coding.
shure
can you plaese tell me how can i make use of that for c++..........I means in which option i have to go for writng source code.
try find in google by "how to create new console project in VS"
file>new>project>visualc++>win32console applicatio

I had followed this path. Sir is it correct. and there i found this page.

// 3.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
Topic archived. No new replies allowed.