Online C Compiler | Online C++ Compiler

bOtskOOl Online C++ Compiler

Online C Compiler | Online C++ Compiler - Login Required


You need to login or register in order to access our Free Online C Compiler | Online C++ Compiler.

Online Compiler - Register for free

 

 

Some recent program(s) compiled by bOtskOOl user(s) :-

Comments

Member since:
13 November 2009
Last activity:
7 years 15 weeks

#include<iostream>
using namespace std;

int main ()
{
cout  << "Hello World!";
return 0;

}

not only for the above program, i am going through these below error,

if anyones about these errors, please help me

 

expected constructor, destructor, or type conversion before '<<' token

 expected declaration before '}' token
Member since:
18 February 2009
Last activity:
1 year 8 weeks

Hello selturk,

Your program is working fine.

//Program to search an element in a Dynamic Array 

#include <iostream> 


using namespace std; 


int search(int a[], int size, int key); 


int main () 

int arraySize; 

cout<<"Enter the size of the array you want to create:"<<endl; 

cin>>arraySize; 


int *a;//a is declared as a pointer to an array 

a=new int[arraySize]; 


cout<<"Enter the numbers to fill in the array:"<<endl; 

for(int i=0;i<arraySize;i++) 

cin>>a[i]; 


int key; 

cout<<"Enter a value to search for:"<<endl; 

cin>>key; 


int location=search(a, arraySize, key);//function "location" is called 


if(location==-1) 

cout<<key<<" is not in the array."; 

else 

cout<<key<<" is element "<<location<<" in the array."; 


delete [] a; 


cin.ignore(255, '\n'); 

cin.get(); 


return 0; 



int search(int a[], int size, int key) 

int i=0; 

while((a[i]!=key) && (i<size)) 

i++; 


if(i==size)//if target is not in a 

i=-1; 


return i; 

}  

Sample input to your program - 

4

2

3

5

6

5

Output of the program with the above mentioned input parameters is shown below -

Output of C Program

 

Founder and Admin

Member since:
2 November 2009
Last activity:
1 year 35 weeks

hey guys !

Check out a new  input feature added to the c/c++ compiler.

To enable this option check the instructions just below the editor(box).  

its simple and amazing!...Now compile your c/c++ codes online just like your PC compiler. 

Please post your errors so that bOtskOOl can make it even better for you.

cheers

Member since:
21 February 2009
Last activity:
7 years 1 week

Thank You.

Now you can also use our input feature to give input(s) to your program and interact with it.  

Member since:
27 November 2009
Last activity:
7 years 16 weeks

its really amazing

Member since:
24 November 2009
Last activity:
7 years 17 weeks

SUPERRRRRRRRRRRRRRRRRRRRRRRRRRRRJJ

Member since:
18 February 2009
Last activity:
1 year 8 weeks

Hello jie_2366,

Upon executing this program you will get in the output the address of the integer xyz depending upon where it has been stored in memory. Every time upon compiling this program you will get a different output since variables are randomly allocated memory space. Output is shown below - 

#include <iostream.h>

using namespace std;


int main()

{

int xyz;

cout<<&xyz;

C program output

0x in the output indicates that the number is in hexadecimal format. Try it out now! 

Founder and Admin

Member since:
18 February 2009
Last activity:
1 year 8 weeks

Hello itnkigotcha,

To calculate the sizes of user-defined types, the compiler takes into account any alignment space needed for complex user-defined data structures. This is why the size of a structure in C/C++ can be greater than the sum of the sizes of its members. For example, this following code will print 8:

 

 

#include <iostream.h>

using namespace std;


int main()

{

struct student{

  char grade; /* char is 1 byte long */

  int age; /* int is 4 bytes long */

};

cout<<sizeof(student);

return 0;

}

 

 

The reason for this is that most compilers, by default, align complex data-structures to a word alignment boundary. In addition, the individual members are also aligned to their respective alignment boundaries. By this logic, the structure student gets aligned on a word boundary and the variable age within the structure is aligned with the next word address. This is accomplished by way of the compiler inserting "padding" space between two members or to the end of the structure to satisfy alignment requirements. This padding is inserted to align age with a word boundary. 

Founder and Admin

Member since:
22 November 2009
Last activity:
7 years 17 weeks

if int xyz = 5,what is the output for cout << &xyz;

 

Member since:
18 February 2009
Last activity:
1 year 8 weeks

Hello itnkigotcha,

Sorry but usage of #define is not allowed. 

 

Founder and Admin