Search This Blog

Friday, 15 May 2020

programming C(values)

   swap the values and display the output


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

int main()
{
    int X,y,temp;

    printf("Enter number for the first variable\n");
    scanf("%d",&X);

    printf("enter number for the second variable\n");
    scanf("%d",&y);

    temp=X;
    X=y;
    y=temp;

    printf("first variable value %d \n",X);
    printf("second variable value %d \n",y);

    return 0;
}

    

programming C (student name with age)

    name with age

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

int main()
{
    char name[50];
    int b_year,age;

    printf("enter your name\n");
    scanf("%s",&name);

    printf("enter your born year\n");
    scanf("%d",&b_year);

    age=2020-b_year;

    printf("student name is %s \n",name);
    printf("student age is %d \n",age);
    return 0;
}

     

programming C(name and school)

    Name and school


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

int main()
{
    char name[25]="kusal mendis";
    printf("%s\n",name);

    char name2[35]="ncfc college";
    printf("%s\n",name2);
}

programming C(two integers total)

  two integers and display the total


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

int main()
{
    int x,y;

    printf("enter first number \n");
    scanf("%d",&x);

    printf("enter second number \n");
    scanf("%d",&y);

    printf("total is %d \n",x+y);
    return 0;

}

    

programming C(two numbers average)

 Numbers average

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

int main()
{
    float x,y,tot,avg;
    printf("enter first number\n");
    scanf("%f",&x);

    printf("enter second number\n");
    scanf("%f",&y);

    tot=x+y;
    avg=tot/2;

    printf("avarage is %f \n",avg);

    return 0;
}



https://programminglanguagensbm.blogspot.com