download turboc++ from here (nvstech.weebly.com)
basically there are two types of variables
1= float means (decimals value like 1.2 , 8.2)
2= int means (fixed values 2 ,5 ,5 )
1= float means (decimals value like 1.2 , 8.2)
2= int means (fixed values 2 ,5 ,5 )
program no 1:
how to calculate percentage of 3 input marks....
#include<stdio.h>
#inlcude<conio.h>
#inlcude<conio.h>
void main()
{
int m1;
int m2;
int m3;
int sum;
clrscr();
float percentage;
printf("enter marks1:");
printf("enter marks1:");
scanf("%d",&m1);
printf("enter marks2:");
printf("enter marks2:");
scanf("%d",&m2);
printf("enter marks3:");
printf("enter marks3:");
scanf("%d",&m3);
sum=m1+m2+m3;
percentage=sum/300.0*100;
printf("sum=%d",sum);
printf("perce%f",percentage);
getch();
getch();
}
here percentage is floar value (like 89.7% ) so we use "f"
and marks are basically in integers values like ( 56 out 100) so we "d".
now i am compiling this program
then runiing
scanf means (input value )
we use [clrscr();] always after declarations
declarations means (
and [getch();]
always in the end before closing curly brackets)
scanf means (input value )
we use [clrscr();] always after declarations
declarations means (
int m2;
int m3;
int sum;)and [getch();]
always in the end before closing curly brackets)
program no 2:
how to calculate length:
first step declare values or variables we use :
#include<stdio.h>
#inlcude<conio.h>
#inlcude<conio.h>
void main()
{
float length,area;
printf("enter lenght:");
scanf("%f", &length);
area=lenght*length;
printf("area =%f", lenght);
getch();
}
here area and lenght both are float values like (9.7m ) or area = 8.9sqm
now similary u can calculate area of rectangle
area=length*breadth
now here 3 variables are available
length
breadth
area
#include<stdio.h>
#include<conio.h>
void main()
{
float km;
clrscr();
printf("enter km:");
scanf("%f", &km);
m=km*1000.0;
printf("m=%f",m);
getch();
}
{
float length,area;
printf("enter lenght:");
scanf("%f", &length);
area=lenght*length;
printf("area =%f", lenght);
getch();
}
here area and lenght both are float values like (9.7m ) or area = 8.9sqm
now similary u can calculate area of rectangle
area=length*breadth
now here 3 variables are available
length
breadth
area
#include<stdio.h>
#inlcude<conio.h>
#inlcude<conio.h>
void main()
{
float length,breadth,area;
clrscr();
printf("enter lenght:");
scanf("%f", & lenght);
printf(enter breadth:");
scanf("%f", &breadth);
area=lenght*breadth;
printf("area=%f", area);
getch();
}
{
float length,breadth,area;
clrscr();
printf("enter lenght:");
scanf("%f", & lenght);
printf(enter breadth:");
scanf("%f", &breadth);
area=lenght*breadth;
printf("area=%f", area);
getch();
}
points to remember:
1) always use (;) after every step
2)each time when u write scanf u will have to input values
3) use (&) only in scanf not in printf like above
4) (scanf then formula then printf) step by step
program no3:
how to convert km into meter
steps: scanf then formula then printf
#include<stdio.h>
#include<conio.h>
void main()
{
float km;
clrscr();
printf("enter km:");
scanf("%f", &km);
m=km*1000.0;
printf("m=%f",m);
getch();
}
program no 4:
convert km into feets:
#include<stdio.h>
#include<conio.h>
void main()
{
float km,feet;
clrscr();
printf("enter km:");
scanf("%f", &km);
feet=km*3280.6;
printf("feet=%f", feet);
getch();
}
program no 5:
how to calculte table of any number
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,d,e,f,g,h,i,j;
clrscr();
printf("enter no:");
scanf("%d",&a);
b=a*2,c=a*3,d=a*4,e=a*5,f=a*6,g=a*7,h=a*8,i=a*9,j=a*10;
printf("%d\n",a);
printf("%d\n",b);
printf("%d\n",c);
printf("%d\n",d);
printf("%d\n",e);
printf("%d\n",f);
printf("%d\n",g);
printf("%d\n",h);
printf("%d\n",i);
printf("%d\n",j);
printf("Wow! DAniyal (=");
getch();
}
program no 7
convert farenheit into centigrade
here f and c are integers dats y i take both of them in (d) instead of (f)
program no 5:
stay connect for more :)