Welcome To GDB Online
Welcome To GDB Online
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
*******************************************************************************/
#include <stdio.h>
int main()
int size=sizeof(arr)/sizeof(arr[0]);
int n=4;
for(int i=0;i<n;i++){
int first=arr[0];
for(int j=0;j<size-1;j++){
arr[j]=arr[j+1];
arr[size-1]=first;
for(int i=0;i<size;i++){
printf("%d ",arr[i]);
return 0;
}
/******************************************************************************
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
*******************************************************************************/
#include <stdio.h>
int main()
int size=sizeof(arr)/sizeof(arr[0]);
int n=4;
for(int i=0;i<n;i++){
int last=arr[size-1];
for(int j=size-2;j>=0;j--){
arr[j+1]=arr[j];
arr[0]=last;
for(int i=0;i<size;i++){
printf("%d ",arr[i]);
return 0;
/*
* C program to delete an element from array at specified position
*/
#include <stdio.h>
int main()
int arr[MAX_SIZE];
scanf("%d", &size);
scanf("%d", &arr[i]);
scanf("%d", &pos);
/* Invalid delete position */
else
size--;
printf("%d\t", arr[i]);
return 0;
/******************************************************************************
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <stdio.h>
int main()
int arr[]={1,2,1,3,5,6,4};
int start=0,end=sizeof(arr)/sizeof(arr[0]);
while(start<end){
int mid=start+(end-start)/2;
if(arr[mid]>arr[mid+1]){
end=mid;
else{
start=mid+1;
printf("%d ",end);
return 0;
/******************************************************************************
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
replace the peak number by adding it neighbour elements (example:- input: 1 2 4 3 output: 1 2 9
3 )
*******************************************************************************/
#include <stdio.h>
int main()
int arr[]={1,2,4,3};
int start=0,end=sizeof(arr)/sizeof(arr[0]);
while(start<end){
int mid=start+(end-start)/2;
if(arr[mid]>arr[mid+1]){
end=mid;
else{
start=mid+1;
int size=sizeof(arr)/sizeof(arr[0]);
arr[end]=arr[end-1]+arr[end+1]+arr[end];
for(int i=0;i<size;i++){
printf("%d ",arr[i]);
return 0;
/******************************************************************************
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Given an Array print only the Positive numbers Sample Input: [1,3,-4,-5,2,3] Sample Output: [1,3,2,3]
*******************************************************************************/
#include <stdio.h>
int main()
int arr[]={1,3,-4,-5,2,3};
int size=sizeof(arr)/sizeof(arr[0]);
int ans[size],k=0;
for(int i=0;i<size;i++){
if(arr[i]<0){
continue;
ans[k]=arr[i];
k++;
for(int i=0;i<;i++){
printf("%d ",ans[i]);
return 0;
/******************************************************************************
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Sample Output1: 2
Sample Input 2: [22,22,4,12,2,4]
Sample Output 2: 4
*******************************************************************************/
#include <stdio.h>
#include <limits.h>
int main()
int arr[]={22,22,4,12,2,4};
int number=0,index=INT_MIN;
int size=sizeof(arr)/sizeof(arr[0]);
for(int i=0;i<size;i++){
for(int j=i+1;j<size;j++){
number=arr[j];
index=j;
printf("%d ",number);
return 0;
/******************************************************************************
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Print the sum of first element, second element,last element,second last element in an array
Example : [1,2,4,5,5] Output: 1+2+5+5 = 13, [1,2,3] Output : 4
*******************************************************************************/
#include <stdio.h>
int main() {
if (n < 4) {
int sum = arr[0] + (n == 2 ? arr[1] : arr[n-1]); // Sum first element and second element (if exists)
} else {
int sum = arr[0] + arr[1] + arr[n - 1] + arr[n - 2]; // Calculate sum for larger arrays
return 0;
/******************************************************************************
Write your code in this editor and press "Run" button to execute it.
*******************************************************************************/
#include <stdio.h>
#include <stdbool.h> // for boolean data type
if (num <= 1) {
if (num % i == 0) {
return true; // Prime if not divisible by any number up to its square root
int main() {
if (!isPrime(arr[i])) {
printf("\n");
return 0;
/******************************************************************************
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
*******************************************************************************/
#include <stdio.h>
#include<stdbool.h>
int count=0;
for(int i=1;i<=a;i++){
if(a%i==0)
count++;
if(count!=2){
return false;
return true;
int main()
int size=sizeof(arr)/sizeof(arr[0]);
for(int i=0;i<size;i++){
if(!primenumber(arr[i])){
printf("%d ",arr[i]);
return 0;
https://www.geeksforgeeks.org/median-of-two-sorted-arrays/