online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
/****************************************************************************** Online C Compiler. Code, Compile, Run and Debug C program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <stdio.h> #define BITS2SHIFT(mask) (mask&-mask) // Calculates leftshift for given mask (e.g BITS2SHIFT(0x30) = 16, where log2 16 = 4, to shift 4) #define MOV2MASK(val,mask) (val*BITS2SHIFT(mask))&mask // Places a value within the given mask #define MASK2VAL(val,mask) (val&mask)/BITS2SHIFT(mask) // Returns values written in mask int main() { unsigned char val = 0x02; unsigned char mask = 0x30; unsigned char en = MOV2MASK(val,mask); unsigned char de = MASK2VAL(en,mask); printf("Val:\t\t\t%d\n",val); printf("Mask:\t\t\t%d\n",mask); printf("Shift multiplier:\t%d\n",BITS2SHIFT(mask)); printf("Encoded Number:\t\t%d\n",en); printf("Decoded Number:\t\t%d\n",de); return 0; }
#include <stdio.h> int main() { int a = 1; if (a) printf("All is Well "); printf("I am Well\n"); else printf("I am not a River\n"); }
name = input("what your name : ") print ("my name is " +name) age = int(input("How old are you :"))
#include <stdio.h> #include <stdlib.h> /* Structure of a node */ struct node { int data; // Data struct node *next; // Address }*head; /* * Functions to create and display list */ void createList(int n); void traverseList(); int main() { int n; printf("Enter the total number of nodes: "); scanf("%d", &n); createList(n); printf("\nData in the list \n"); traverseList(); return 0; } /* * Create a list of n nodes */ void createList(int n) { struct node *newNode, *temp; int data, i; head = (struct node *)malloc(sizeof(struct node)); // Terminate if memory not allocated if(head == NULL) { printf("Unable to allocate memory."); exit(0); } // Input data of node from the user printf("Enter the data of node 1: "); scanf("%d", &data); head->data = data; // Link data field with data head->next = NULL; // Link address field to NULL // Create n - 1 nodes and add to list temp = head; for(i=2; i<=n; i++) { newNode = (struct node *)malloc(sizeof(struct node)); /* If memory is not allocated for newNode */ if(newNode == NULL) { printf("Unable to allocate memory."); break; } printf("Enter the data of node %d: ", i); scanf("%d", &data); newNode->data = data; // Link data field of newNode newNode->next = NULL; // Make sure new node points to NULL temp->next = newNode; // Link previous node with newNode temp = temp->next; // Make current node as previous node } } /* * Display entire list */ void traverseList() { struct node *temp; // Return if list is empty if(head == NULL) { printf("List is empty."); return; } temp = head; while(temp != NULL) { printf("Data = %d\n", temp->data); // Print data of current node temp = temp->next; // Move to next node } }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue