c computer language code example

Example 1: c language

#include stdio.h
#include conio.h
void main(){
    int s1,s2,s3,total;
    float per;
    clrscr();
    printf("ENTER SUBJECT MARKS:");
    scanf("%d%d%d",&s1,&s2,&s3);
    total=s1+s2+s3;
    per=total/3;
    if(s1>40 && s2>40 && s3>49)
    {
      if(per>90)
      printf("A GRADE");
      else if(per>70)  
      printf("B GRADE");
      else if(per>50)
      printf("C GRADE");
      else if(per>40)
      printf("D GRADE");
    }
    else
    printf("FAILED");
    getch();
}

Example 2: c programming language

// this is a single-line comment
/*
this is a multi-line comment!
*/

#include <stdio.h> // this library is included for i/o
#include <stdlib.h> // this library is included for some handy functions

// This function will be ran when the program executes
int main() {
 
  printf("Hello, world!\n"); // this prints "Hello, world!" [line break]
  
  char* myString = "An awesome string!"; // declare string variable!
  printf("%s\n", myString); // print myString where %s is
  
  int myInt = 10;
  printf("%d\n", myInt); // print myInt where %d is
  
  double myDouble = 5.2; // declare double (decimal) variable!
  printf("%f\n", myDouble); // print myDouble where %f is
  
  return 0; // < exit out of the program
}