Categories: C LanguageLearn C++

C Basic Programs

C basic programs

In this tutorial, we will discuss some C Basic Programs

program 1

Display “hollow world” as a string

#include <stdio.h>
#include <stdlib.h>

int main()
{
printf(“Hello world!n”);
return 0;
}

Program 1

using printf function

program 2
Display age as an integer
#include <stdio.h>
#include <stdlib.h>
int main()
{
  int age=23;
  printf(“Hi this is anil!n my age is %d”,age);
  getch();
  return 0;
}
Program 2

using scanf function

program 3
This program allows the user to enter age and display given age
#include <stdio.h>
#include <stdlib.h>
int main()
{
  int age;
  printf(“Enter your age!n”);
  scanf(“%d”,&age);
  printf(“your age is %d”,age);
  return 0;
}
Program 3
program 4
#include <stdio.h>
#include <stdlib.h>
int main()
{
  int age;
  float weight;
  printf(“Enter your age and weightn”);
  scanf(“%d%f”,&age,&weight);
  printf(“your age is %dn your weight is %f”,age,weight);
  return 0;
}
Program 4
program 5
variable assignment
#include <stdio.h>
#include <stdlib.h>
int main()
{
  //datatype name;
  int age;
  float weight;
  char sex;
  age=23;
  weight=50.5;
  sex=’M’;
  printf(“%d %f %c”,age,weight,sex);
  return 0;
}
program 5
program 6
arithmetic operator in c
#include <stdio.h>
#include <stdlib.h>
int main()
{
  int a,b,c,d,e,f;
  a=100;
  b=10;
  c=a+b;
   d=a-b;
    e=a*b;
     f=a/b;
  printf(“toatal value is: %dn”,c);
  printf(“toatal value is: %dn”,d);
  printf(“toatal value is: %dn”,e);
  printf(“toatal value is: %dn”,f);
  return 0;
}
Program 6
program 7

#include <stdio.h>
#include <stdlib.h>

int main()
{
  int number;
  printf(“Enter the integer:”);
  scanf(“%d”,&number);
  printf(“you entered :%d”,number);
  return 0;
}
Program 7
program 8
#include <stdio.h>
#include <stdlib.h>
int main()
{
  int a,b,c,d,e,f,g;
  a=20;
  b=15;
  c=a+b;
  d=a-b;
  e=a*b;
  f=a/b;
  g=a%b;
  printf(“Hello kannan your output here!n”);
   printf(“a+b addition is %d n”,c);
    printf(“a-b subtraction is %dn”,d);
     printf(“a*b multipilication is %dn”,e);
      printf(“a/b divition is %dn”,f);
       printf(“a+b modulas is %dn”,g);
  return 0;
}
Program 8
program 9
#include <stdio.h>
#include <stdlib.h>
int main()
{
  int a,b,c,d,e,f,g;
  printf(“Hello kannan enter the first number a:!n”);
  scanf(“%d”,&a);
  printf(“Hello kannan enter the second number b:!n”);
  scanf(“%d”,&b);
  c=a+b;
  d=a-b;
  e=a*b;
  f=a/b;
  g=a%b;
   printf(“Hello kannan your output here:!n”);
   printf(“a+b addition is %dn”,c);
    printf(“a-b subtraction is %dn”,d);
     printf(“a*b multipilication is %dn”,e);
      printf(“a/b divition is %dn”,f);
       printf(“a+b modulas is %dn”,g);
  return 0;
}
program 9
Suggested for you
Karmehavannan

Recent Posts

Subtract two numbers using method overriding

Subtract two numbers using method overriding   Program 1

3 months ago

PHP Star triangle Pattern program

PHP Star triangle Pattern program Here's a simple Java program that demonstrates how to print…

3 months ago

Using function or method to Write temperature conversion : Fahrenheit into Celsius

Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…

1 year ago

Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user

Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…

1 year ago

Write temperature conversion program: Fahrenheit into Celsius

Write temperature conversion program: from Fahrenheit to Celsius In this article, we will discuss the…

1 year ago

How to write a program to convert Fahrenheit into Celsius

How to write a program to convert Fahrenheit into Celsius In this article, we will…

1 year ago

This website uses cookies.