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

Multiply two numbers in Java using scanner| 5 different ways

Multiply two numbers in Java using scanner| 5 different ways In this article, we will…

3 months ago

5 different ways to Divide two numbers in Java using scanner

5 Different ways to Divide two numbers in Java using scanner In this article, we…

3 months ago

Learn 8 Ways to Subtract Two Numbers Using Methods in Java

Learn 8 Ways to Subtract Two Numbers Using Methods in Java In this article, we…

4 months ago

10 ways to subtract two numbers in Java

10 ways to subtract two numbers in Java In this article, we will discuss the…

4 months ago

Java Code Examples – Multiply Two Numbers in 5 Easy Ways

Java Code Examples – Multiply Two Numbers in 5 Easy Ways In this article, we…

4 months ago

How to Divide two numbers in Java| 5 different ways

How to Divide two numbers in Java| 5 different ways In this article, we will…

4 months ago

This website uses cookies.