C PROGRAMMING BASICS

 C Language :

         Procedural Programming Language  - Type of Programming Language that uses step by step procedure to solve the problems.



Usage of Void main 

#include <stdio.h>

void main()

{

    printf("Welcome to C Programming Language");

}

 

Usage of Int main

#include <stdio.h>

int main()

{

    printf("Welcome to C Programming Language");

    return 0;

}


Data Types Program

#include <stdio.h>

int main()

{

    int a=100;

    long int n=1002365988545;

    float b=25.69;

    char c='a';

    double d=45.696544;

    printf("%d\n",a);

    printf("%ld\n",n);

    printf("%.2f\n",b);

    printf("%c\n",c);

    printf("%.2lf\n",d);

    return 0;

}


Printing the all datatypes in same line

#include <stdio.h>

int main()

{

    int mark1=100,mark2=500,mark3=800;

    int  dsaf_1=56;

    int _adsf=89;

    float mark_4=90.63;

    char name='e';

    printf("%d\n%d\n%d\n%f\n%c",mark1,mark2,mark3,mark_4,name);

    return 0;

}


Printing the int char and float data types consecutively 

#include <stdio.h>

int main()

{

    int a;

    char c;

    float d;

    printf("Enter the number\n");

    scanf("%d",&a);

    printf("Enter the character\n");

    scanf(" %c",&c);

    printf("Enter the floating number\n");

    scanf("%f",&d);

    printf("A value is%d\n",a);

    printf("C value is%c\n",c);

    printf("D value is %f\n",d);

    return 0;

}


C Program to find mark statement 

#include <stdio.h>

int main()

{

    int regno;

    float m1,m2,m3,m4,m5;

    double total,avg;

    char s[100];

    printf("Enter your name without space:");

    scanf("%s",s);

    printf("Enter the register number:");

    scanf("%d",&regno);

    printf("Enter the marks\n");

    scanf("%f\n",&m1);

    scanf("%f\n",&m2);

    scanf("%f\n",&m3);

    scanf("%f",&m4);

    total=m1+m2+m3+m4;

    avg=total/4;

    printf("Name %s\n Register no %d\n",s,regno);

    printf("Total mark is%f\n",total);

    printf("Average mark is %lf",avg);

    return 0;

}

C Program to Verify that Float store 5 digits after decimal and Double stores 15 digits after decimal


#include <stdio.h>

int main()

{

    float num1;

    double num2;

    scanf("%f",&num1);

    scanf("%lf",&num2);

    printf("%.15f\n",num1);

    printf("%.15lf",num2);

    return 0;

}


C program to print the ASCII Values

#include <stdio.h>

int main()

{

    char a='a';

    printf("%d",a);

    return 0;

}


C Program for Operators


#include <stdio.h>

int main()

{

    int num1=10,num2=90;

    printf("addition %f\n",num1+num2);

    printf("subtraction %f\n",num1-num2);

    printf("multiplication %f\n",num1*num2);

    printf("division %f\n",num1/num2);

   int e=num1%num2;

    printf("modulus operation%f",e);

    return 0;

}


C Program for printing the Radius from Circumference


#include <stdio.h>
int main()
   int diameter;
   //float radius;
   //float add=0;
    printf("Enter the radius");
    scanf("%d",&diameter);
    //radius=diameter+add;
    printf("Radius value is %f",diameter/2.0);
    return 0;
}


C Program to print the tasks


#include <stdio.h>
int main()
{
    float price,discount,ta;
    float total;
     discount=20;
    ta=30;
    printf("enter the price\n");
    scanf("%f",&price);
    total=(price-(price*20/100))+ta;
    printf("total value is %f",total);
    return 0;

C Program to execute Bitwise Operations

#include <stdio.h>

int main()

{

    int a=8;

    int b=13;

    printf("%d\n",a^b);

    printf("%d\n",a|b);

    printf("%d\n",a&b);

    return 0;

}



C program for unary operator

#include <stdio.h>

int main()

{

    int a=10;

    printf("value of a before increament is %d\n",a);

    printf("value of a after preincreament is %d\n",++a);

    a++; //performing post increament

    printf("value of a after postincreament is %d\n",a);

    int b=10;

    printf("value of a before decreament is %d\n",b);

    printf("value of a after predecreament is %d\n",--b);

    b--; //performing post increament

    printf("value of a after postdecreament is %d\n",b);

    return 0;

    

}


Comments

Popular posts from this blog

3.1.24 Test link