j
Showing posts with label C Language. Show all posts
Showing posts with label C Language. Show all posts

Saturday, 7 November 2015

Write a program that take valuse of a and b then enterchange their values without using extra variable

PROGRAM SOLUTION

#include<stdio.h>
#include<conio.h>
void mian()
{
clrscr();
int a,b;
printf("Enter the value of a and b :: ");
scanf("%d%d",&a,&b);
printf("The value of a before change :: %d\n",a);
printf("The value of b before change :: %d\n",b);
a=a+b;
b=a-b;
a=a-b;
printf("The value of a after change :: %d\n",a);
printf("The value of b after change :: %d\n",b);
getch();
}


OUTPUT

Write a program that take values of a and b than enterchange their values

Program Solution

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,temp;
printf("Enter the values a and b ::");
cin>>a>>b;
printf("The value of a before change :: %d\n",a);
printf("The value of b before change :: %d\n"b);
temp=a;
a=b;
b=temp;
printf("The value of a after change :: %d\n",a);
printf("The value of b after change :: %d",b);
getch();
}

Output

Write a program that take Radius and Height of cylinder and display area of Cylinder....

#include<stdio.h>
#include<conio.h>
void main()
{
float a,pi;
int r,h;
printf("Enter radius of cylinder ::");
scanf("%d",&r);
printf("Enter height of cylinder ::");
scanf("%d",&h);
pi=3.142;
a=2*pi*r*(r+h);
scanf(" Area of cylinder is ",a);
getch();
}

Write a program that take lenght, width and height from user and find the volume, there volume =length*width*height

Program Solution

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int len,wid,hei,v;
printf("Enter length ::");
scanf("%d",&len);
printf("Enter width ::");
scanf("%d",&wid);
printf("Enter heigth ::");
scanf("%d",&hei);
v=len*wid*hei;
printf("Valume is %d",v);
getch();
}

Output



Write a program that take five integer value and solve it 6*a*a-2*b*b+5*a*b+3*b*e*d

Program Solution

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c,d,e,res;
printf("Enter five integer value:");
scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
res=6*a*a-2*b*b+5*a*b+3*b*e*d;
printf("The result is %d");
getch();
}

Output

 


Write a program that take two numbers from user and display its sum

Program Solution 

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
float a,b;
double sum;
printf("Enter two numbers:\n");
scanf("%d%d",&a,&b);
sum=a+b;
printf("Sum of two fractional value is %d",sum);
getch();
}

 Output



Tuesday, 3 November 2015

Write a program that take 2 number from user and find its sum, product,diffrence,quotient and remeinder and display all

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,sum,prod,dif,qou,rem;
printf("Enter Two numbers:");
scanf("%d%d",&a,&b);
sum=a+b;
prod=a*b;
dif=a-b;
qou=a/b;
rem=a%b;
printf("Sum of two values is %d\n",sum);
printf("Product of two valuse is %d\n",prod);
printf("Diffrence of two values is %d\n",dif);
printf("Qoutient of two valuse is %d\n",qou);
printf("Reminder of two values is %d\n",rem);
getch();
}

Write a program, A person read 34 pages per day of a book, takes total number of pages of book from user and find total days to complete this book.



#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int tot_page,comp_day;
printf("Enter total page of book ::");
scanf("%d",&tot_page);
comp_day=tot_page/34;
printf("%d days to complete this book.",comp_day);
getch();
}

write a program, A company pays 10% tax on his monthly income, get per month income of company and calculate its yearly income after deducting annual tax.



#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
long int per_month,yearly,tax;
printf("Enter your per month income ::");
scanf("%ld",&per_month);
tax=per_month*10/100;
per_month=per_month-tax;
yearly=per_month*12;
printf("Your monthly income after deducting annual tax is %ld",yearly);
getch();
}

Write a program that take user weight in pounds and convert it into kilogram.



#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
float kg,pound;
printf("Enter your weight in pounds ::");
scanf("%f",&pound);
kg=pound*0.4536;
printf("Weight in kilogram is %d",kg);
getch();
}

Write a program that take user weight in kilogram and convert it into pounds Hense (1 kg=2.2 pounds)



#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
float kg,pound;
printf("Enter your weight in kilogram ::");
scanf("%d",&kg)
pound=kg*2.2;
printf("Enter your weight in pounds %d",pound);
getch();
}

Write a program that take user per month income and show him into per year,per day, and per hour income



#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
long int pm,ph,pd;
long int py;
printf("Enter your monthly income ::");
scanf("%ld",&pm);
pd=pm/30;
ph=pd/12;
py=pm*12;
printf("Your per hour income is %ld\n",ph);
printf("Your per day income is %ld\n",pd);
printf("Your per year income is %ld",py);
getch();
}