Answers for "c"

C
13

c

#include <stdio.h>

int main() {
   printf("Hello, world!");
   return 0;
}
Posted by: Guest on July-16-2020
1

c

C is bad. JS > Py > C
Posted by: Guest on March-11-2021
2

C

#include <stdio.h>

int main (int argc, char * argv[])
{
    int i = 0;
    int list[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
    int run = 1;
    int length_of_list; // the number of elements that the list contains
    length_of_list = sizeof(list) / sizeof(int); // getting the number
    
    while (run){ //printing the list
    printf("The list is: %d\n", list[i]);
    i = i + 1;
    if (i == length_of_list){ //check if the list has ended
        printf("The list has ended!\n");
        break; // exit the loop
    } 
    }

    return 0;
}
Posted by: Guest on July-02-2021
12

c

/* Answer to: "c" */

/*
  To learn about the letter 'C' you go to the Wikipedia:
  https://en.wikipedia.org/wiki/C
  ...but this is a Chrome Exstention for developers:

  C is a general-purpose, procedural computer programming language
  supporting structured programming, lexical variable scope, and
  recursion, while a static type system prevents unintended
  operations.
  
  Here's the Wikipedia:
  https://en.wikipedia.org/wiki/C_(programming_language)
*/
Posted by: Guest on April-17-2020
1

c

#include <stdio.h>

//main() is the main function for C
int main(){
	
	//int defines an integer variable
	int txt;

	//scanf() inputs the value you give it
	//%d defines that the value is an integer
	//& indicates that you're inputting a variable
	scanf("%d",&txt);

	//printf() outputs the value you give it
	//the %d is our "txt" variable, assigned by putting ",txt"
	printf("%d",txt);

	//return 0 indicates the end of the script
	return 0;
}

//P.S. always remember to put semicolons at the end of a line ;)
Posted by: Guest on November-17-2020
0

c

111 result = 710
   -------
101)100101
    −101
     ---
     1000
     −101
      ---
       111
      −101
       ---
        10 remainder = 210
       ---
Posted by: Guest on June-16-2021
-1

c

Nobody put anything for C, so might as well be the first :)
Posted by: Guest on April-30-2021
0

c

C/C++ - General-purpose language with a bias toward system 
programming and embedded, resource-constrained software.
C++'s Awesome List
https://github.com/fffaraz/awesome-cpp#readme
C's Awesome List
https://github.com/aleksandar-todorovic/awesome-c#readme
Posted by: Guest on January-02-2021
0

c

import java.awt.*;        // Using AWT container and component classes
import java.awt.event.*;  // Using AWT event classes and listener interfaces

// An AWT program inherits from the top-level container java.awt.Frame
public class AWTCounter extends Frame {
   private Label lblCount;    // Declare a Label component
   private TextField tfCount; // Declare a TextField component
   private Button btnCount;   // Declare a Button component
   private int count = 0;     // Counter's value

   // Constructor to setup GUI components and event handlers
   public AWTCounter () {
      setLayout(new FlowLayout());
         // "super" Frame, which is a Container, sets its layout to FlowLayout to arrange
         // the components from left-to-right, and flow to next row from top-to-bottom.

      lblCount = new Label("Counter");  // construct the Label component
      add(lblCount);                    // "super" Frame container adds Label component

      tfCount = new TextField(count + "", 10); // construct the TextField component with initial text
      tfCount.setEditable(false);       // set to read-only
      add(tfCount);                     // "super" Frame container adds TextField component

      btnCount = new Button("Count");   // construct the Button component
      add(btnCount);                    // "super" Frame container adds Button component

      BtnCountListener listener = new BtnCountListener();
      btnCount.addActionListener(listener);
         // "btnCount" is the source object that fires an ActionEvent when clicked.
         // The source object adds an instance of BtnCountListener as an ActionEvent listener,
         //   which provides an ActionEvent handler called actionPerformed().
         // Clicking "Count" button calls back actionPerformed().

      setTitle("AWT Counter");  // "super" Frame sets its title
      setSize(300, 100);        // "super" Frame sets its initial window size

      // For inspecting the Container/Components objects
      // System.out.println(this);
      // System.out.println(lblCount);
      // System.out.println(tfCount);
      // System.out.println(btnCount);
      setVisible(true);         // "super" Frame shows
      // System.out.println(this);
      // System.out.println(lblCount);
      // System.out.println(tfCount);
      // System.out.println(btnCount);
   }

   // The entry main() method
   public static void main(String[] args) {
      // Invoke the constructor to setup the GUI, by allocating an instance
      AWTCounter app = new AWTCounter();
         // or simply "new AWTCounter();" for an anonymous instance
   }

   // Define an inner class to handle the "Count" button-click
   private class BtnCountListener implements ActionListener {
      // ActionEvent handler - Called back upon button-click.
      @Override
      public void actionPerformed(ActionEvent evt) {
         ++count; // Increase the counter value
         // Display the counter value on the TextField tfCount
         tfCount.setText(count + ""); // Convert int to String
      }
   }
}
Posted by: Guest on July-14-2021
1

c

Do not want to be rude but I learnt this language and found out it has no class.
Prefer languages with class like C++, C#, Java, Python, etc.
Be classy.
Posted by: Guest on May-31-2021
0

c

9999 MAD Shiba Jackpot

Posted by: Rajesh Joshi on April-04-2022
0

c

/*
 * FCFS Scheduling Program in C
 */
 
#include <stdio.h>
int main()
{
    int pid[15];
    int bt[15];
    int n;
    printf("Enter the number of processes: ");
    scanf("%d",&n);
 
    printf("Enter process id of all the processes: ");
    for(int i=0;i<n;i++)
    {
        scanf("%d",&pid[i]);
    }
 
    printf("Enter burst time of all the processes: ");
    for(int i=0;i<n;i++)
    {
        scanf("%d",&bt[i]);
    }
 
    int i, wt[n];
    wt[0]=0;
 
    //for calculating waiting time of each process
    for(i=1; i<n; i++)
    {
        wt[i]= bt[i-1]+ wt[i-1];
    }
 
    printf("Process ID     Burst Time     Waiting Time     TurnAround Time\n");
    float twt=0.0;
    float tat= 0.0;
    for(i=0; i<n; i++)
    {
        printf("%d\t\t", pid[i]);
        printf("%d\t\t", bt[i]);
        printf("%d\t\t", wt[i]);
 
        //calculating and printing turnaround time of each process
        printf("%d\t\t", bt[i]+wt[i]);
        printf("\n");
 
        //for calculating total waiting time
        twt += wt[i];
 
        //for calculating total turnaround time
        tat += (wt[i]+bt[i]);
    }
    float att,awt;
 
    //for calculating average waiting time
    awt = twt/n;
 
    //for calculating average turnaround time
    att = tat/n;
    printf("Avg. waiting time= %f\n",awt);
    printf("Avg. turnaround time= %f",att);
}
Posted by: JALLA CHARAN REDDY on January-31-2023
0

c

1millfavs
Posted by: Nguyễn Ngọc Quỳnh Trâm on August-04-2023

Code answers related to "C"

Browse Popular Code Answers by Language