Showing posts with label C LANGUAGE. Show all posts
Showing posts with label C LANGUAGE. Show all posts
A shortcut to learn the computer programming
WAP TO PERFORM ARITHMETIC OPERATION
We are providing the simple way to perform the arithmetic operation in easy and simple manner.In this program ,we are also using the type conversion.
#include<stdio.h>
void main()
{
int a,b,sum,sub,mul;
float div;
clrscr();
printf("enter the value of a=");
scanf("%d",&a);
printf("enter the value of b=");
scanf("%d",&b);
sum=a+b;
printf("\tsum=\t%d\n",sum);
sub=a-b;
printf("\tsub=\t%d\n",sub);
mul=a*b;
printf("\tmul=\t%d\n",mul);
div=(float)a/b; //Type conversion
printf("\tdiv=\t%f\n",div);
getch();
}
O/P:-enter the value of a=6
enter the value of b=2
sum=8 sub=4 mul=12 div=3.0
We are providing the simple way to perform the arithmetic operation in easy and simple manner.In this program ,we are also using the type conversion.
#include<stdio.h>
void main()
{
int a,b,sum,sub,mul;
float div;
clrscr();
printf("enter the value of a=");
scanf("%d",&a);
printf("enter the value of b=");
scanf("%d",&b);
sum=a+b;
printf("\tsum=\t%d\n",sum);
sub=a-b;
printf("\tsub=\t%d\n",sub);
mul=a*b;
printf("\tmul=\t%d\n",mul);
div=(float)a/b; //Type conversion
printf("\tdiv=\t%f\n",div);
getch();
}
O/P:-enter the value of a=6
enter the value of b=2
sum=8 sub=4 mul=12 div=3.0
How to learn C language in easy way
WAP TO PRINT SUM OPERATION WITHOUT USING THIRD VARIABLE
#include<stdio.h>
void main()
{
int a,b;
clrscr();
printf("enter the value of a=");
scanf("%d",&a);
printf("enter the value of b=");
scanf("%d",&b);
printf("SUM=%d",a+b); // Sum operation without using third variable
getch();
}
o/P:- enter the value of a= 4
enter the value of b= 6
SUM is = 10
#include<stdio.h>
void main()
{
int a,b;
clrscr();
printf("enter the value of a=");
scanf("%d",&a);
printf("enter the value of b=");
scanf("%d",&b);
printf("SUM=%d",a+b); // Sum operation without using third variable
getch();
}
o/P:- enter the value of a= 4
enter the value of b= 6
SUM is = 10
How to learn the C language in easy way
WAP TO PRINT SUM OPERATION
#include<stdio.h>
void main()
{
int a,b,SUM; // Variable declaration
clrscr(); //To clear screen
printf("enter the value of a="); //To display
scanf("%d",&a); //Read value from keyboard
printf("enter the value of b=");
scanf("%d",&b);
SUM=a+b; // Logic
printf("SUM=%d",SUM); // To Display result
getch(); //To hold the output on the screen
}
o/P:- enter the value of a= 4
enter the value of b= 6
SUM is = 10
#include<stdio.h>
void main()
{
int a,b,SUM; // Variable declaration
clrscr(); //To clear screen
printf("enter the value of a="); //To display
scanf("%d",&a); //Read value from keyboard
printf("enter the value of b=");
scanf("%d",&b);
SUM=a+b; // Logic
printf("SUM=%d",SUM); // To Display result
getch(); //To hold the output on the screen
}
o/P:- enter the value of a= 4
enter the value of b= 6
SUM is = 10
How to learn C language in easy way
WAP to insert and print integer no., float no. and character.
#include<stdio.h>
void main()
{
int a,b;
float c,d;
clrscr();
printf("enter the value of integer a=");
scanf("%d",&a);
printf("enter the value of integer b=");
scanf("%d",&b);
printf("enter the value of float c=");
scanf("%f",&c);
printf("enter the value of float d=");
scanf("%f",&d);
printf("a=%d\tb=%d\tc=%f\td=%f",a,b,c,d);
getch();
}
O/P:- Enter the value of integer a=4
Enter the value of integer b =5
Enter the value of float c = 4.5
Enter the value of float d= 7.4
a=4 b=5 c=4.5 d=7.4
How to learn C language in easy way
Subscribe to:
Posts (Atom)