Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c

C Basic Programs

Posted on July 31, 2016January 29, 2020

Table of Contents

  • C basic programs
      • using printf function
      • using scanf function
    • Related

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;
}

C Basic Programs
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;
}
C Basic Programs
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;
}
C Basic Programs
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;
}
C Basic Programs
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;
}
C Basic Programs
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;
}
C Basic Programs
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;
}
C Basic Programs
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;
}
C Basic Programs
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;
}
C Basic Programs
program 9
Suggested for you
Hollow world program in C language
Sum of two numbers in C language
Find factorial of a number in C language
String manipulation in C language
The operator in C language

Related

Recent Posts

  • Multiply two numbers in Java using scanner| 5 different ways
  • 5 different ways to Divide two numbers in Java using scanner
  • Learn 8 Ways to Subtract Two Numbers Using Methods in Java
  • 10 ways to subtract two numbers in Java
  • Java Code Examples – Multiply Two Numbers in 5 Easy Ways
  • How to Divide two numbers in Java| 5 different ways

tag

Addition (8) Array (38) C++ language (91) C language (98) c sharp (23) Division (8) Function (29) if else (32) Java language (108) JavaScript (5) loops (138) Multiply (8) Oop (2) patterns (66) PHP (13) Python Language (38) Subtraction (9) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2026 Code for Java c | Powered by SuperbThemes