Now you will be able to program in C, C++, Java, PHP, Python, JavaScript, and more! Thanks to the Techie Delight and GDB Online for their esteemed support. Select any language from the drop-down menu, write your code, and click run (or press F9) to execute it. There are two IDE that complement each other.
For best experience use, Mozilla Firefox if using desktop;
Google Chrome or Mozilla Firefox if using mobile:
Run C, C++, Java, PHP, Python, JavaScript Codes Just from This Forum!
- Eli
- Senior Expert Member
- Reactions: 189
- Posts: 5925
- Joined: 10 years ago
- Location: Tanzania
- Contact:
Here is another IDE for Team collaborations powered by CP Initiative:
C++
Python 3
Try the following codes:
C:
C++:
Java:
Python:
Given the list of integers, X, write code to count how many integers are strictly larger than all the integers to their right. Exclude the last digit since it doesn’t have a number to its right. E.g. for [2,3,1] the answer should be 1 while for [12,4,4,2,2,3] the answer is 2.
In Python the code may look like (Use other languages):
C++
Python 3
Try the following codes:
C:
- #include<stdio.h>
- long factorial(int n)
- {
- if (n == 0)
- return 1;
- else
- return(n * factorial(n-1));
- }
- void main()
- {
- int number;
- long fact;
- printf("Enter a number: ");
- scanf("%d", &number);
- fact = factorial(number);
- printf("Factorial of %d is %ld\n", number, fact);
- return 0;
- }
- #include<stdio.h>
- int main()
- {
- int i,fact=1,number;
- printf("Enter a number: ");
- scanf("%d",&number);
- for(i=1;i<=number;i++){
- fact=fact*i;
- }
- printf("Factorial of %d is: %d",number,fact);
- return 0;
- }
C++:
- #include <iostream>
- using namespace std;
- int main() {
- int numbers[2][3];
- cout << "Enter 6 numbers: " << endl;
- // Storing user input in the array
- for (int i = 0; i < 2; ++i) {
- for (int j = 0; j < 3; ++j) {
- cin >> numbers[i][j];
- }
- }
- cout << "The numbers are: " << endl;
- // Printing array elements
- for (int i = 0; i < 2; ++i) {
- for (int j = 0; j < 3; ++j) {
- cout << "numbers[" << i << "][" << j << "]: " << numbers[i][j] << endl;
- }
- }
- return 0;
- }
Java:
- public class GCD {
- public static void main(String[] args) {
- int n1 = 366, n2 = 60;
- int hcf = hcf(n1, n2);
- System.out.printf("G.C.D of %d and %d is %d.", n1, n2, hcf);
- }
- public static int hcf(int n1, int n2)
- {
- if (n2 != 0)
- return hcf(n2, n1 % n2);
- else
- return n1;
- }
- }
Python:
Given the list of integers, X, write code to count how many integers are strictly larger than all the integers to their right. Exclude the last digit since it doesn’t have a number to its right. E.g. for [2,3,1] the answer should be 1 while for [12,4,4,2,2,3] the answer is 2.
In Python the code may look like (Use other languages):
- X = [7,9,5,3,2,4,5,0]
- def current_max(X):
- m = 0
- for i in X[::-1]:
- m = max(m, i)
- yield m
- N_int = sum([x>y for x,y in zip(X[-2::-1], current_max(X))])
- print(N_int)
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
- Eli
- Senior Expert Member
- Reactions: 189
- Posts: 5925
- Joined: 10 years ago
- Location: Tanzania
- Contact:
Copy and paste this template into the editor above and start learning HTML5, CSS, and JavaScript:
- <!DOCTYPE html>
- <html lang='en'>
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <!-- The above 3 meta tags must come first in the head; thereafter
- other head content may follow -->
- <title>Document</title>
- </head>
- <body>
- <h1>Hello World</h1>
- </body>
- </html>
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
- Eli
- Senior Expert Member
- Reactions: 189
- Posts: 5925
- Joined: 10 years ago
- Location: Tanzania
- Contact:
- import java.util.Date;
- public class Main {
- public static void main(String[] args) {
- byte age = 45;
- Date now = new Date();
- System.out.println(now);
- System.out.println("Hello TSSFL ODF");
- }
- }
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
-
- Similar Topics
- Replies
- Views
- Last post
-
- 1 Replies
- 19084 Views
-
Last post by Eli
-
- Information
-
Who is online
Users browsing this forum: No registered users and 0 guests