0% found this document useful (0 votes)
39 views12 pages

Welcome To GDB Online

Uploaded by

VEERAPAKURAJA T
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
39 views12 pages

Welcome To GDB Online

Uploaded by

VEERAPAKURAJA T
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 12

/******************************************************************************

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.

Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/

#include <stdio.h>

int main()

int arr[] = { 10, 20, 30, 40, 50, 60, 70};

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;

}
/******************************************************************************

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.

Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/

#include <stdio.h>

int main()

int arr[] = { 10, 20, 30, 40, 50, 60, 70};

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>

#define MAX_SIZE 100

int main()

int arr[MAX_SIZE];

int i, size, pos;

/* Input size and element in array */

printf("Enter size of the array : ");

scanf("%d", &size);

printf("Enter elements in array : ");

for(i=0; i<size; i++)

scanf("%d", &arr[i]);

/* Input element position to delete */

printf("Enter the element position to delete : ");

scanf("%d", &pos);
/* Invalid delete position */

if(pos < 0 || pos > size)

printf("Invalid position! Please enter position between 1 to %d", size);

else

/* Copy next element value to current element */

for(i=pos-1; i<size-1; i++)

arr[i] = arr[i + 1];

/* Decrement array size by 1 */

size--;

/* Print array after deletion */

printf("\nElements of array after delete are : ");

for(i=0; i<size; i++)

printf("%d\t", arr[i]);

return 0;

/******************************************************************************

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.
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;

/******************************************************************************

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.

Code, Compile, Run and Debug online from anywhere in world.

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;

/******************************************************************************

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.

Code, Compile, Run and Debug online from anywhere in world.

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;

/******************************************************************************

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.

Code, Compile, Run and Debug online from anywhere in world.

Given an Array print the last Repeated element

Sample input 1: [1,2,3,4,3,2]

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++){

if(arr[i]==arr[j] && j>index){

number=arr[j];

index=j;

printf("%d ",number);

return 0;

/******************************************************************************

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.

Code, Compile, Run and Debug online from anywhere in world.

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() {

int arr[] = {1, 2, 3}; // Replace with your array

int n = sizeof(arr) / sizeof(arr[0]); // Get array size

// Handle arrays with less than 4 elements

if (n < 4) {

int sum = arr[0] + (n == 2 ? arr[1] : arr[n-1]); // Sum first element and second element (if exists)

printf("Sum: %d\n", sum);

} else {

int sum = arr[0] + arr[1] + arr[n - 1] + arr[n - 2]; // Calculate sum for larger arrays

printf("Sum: %d\n", sum);

return 0;

/******************************************************************************

Online Java Compiler.

Code, Compile, Run and Debug java program online.

Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/

#include <stdio.h>
#include <stdbool.h> // for boolean data type

bool isPrime(int num) {

if (num <= 1) {

return false; // 0 and 1 are not prime

for (int i = 2; i * i <= num; i++) {

if (num % i == 0) {

return false; // Divisible by a number other than 1 and itself

return true; // Prime if not divisible by any number up to its square root

int main() {

int arr[] = {1, 2, 3, 4, 6, 8, 11, 13};

int n = sizeof(arr) / sizeof(arr[0]);

printf("Non-prime numbers: ");

for (int i = 0; i < n; i++) {

if (!isPrime(arr[i])) {

printf("%d ", arr[i]);

printf("\n");

return 0;

/******************************************************************************

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.

Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/

#include <stdio.h>

#include<stdbool.h>

bool primenumber (int a){

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 arr[] = {1, 2, 3, 4, 6, 8, 11, 13};

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/

You might also like