- Write a program to print "Hellow World".
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("Hellow World");
getch();
} - The length and height of a rectangle and radius of a circle are input through the keyboard.Write a program to find the area & perimeter of the rectangle and circumference of the circle.
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int length,height,area,per,rad,cir;
printf("Enter a length? \n");
scanf("%d",&length);
printf("Enter a height? \n");
scanf("%d",&height);
printf("Enter a radius?\n");
scanf("%d",&rad);
area=length*height;
per=2*(length+height);
cir=2*3.1416*rad;
printf("The perimiter is: %d\n",per);
printf("The area is: %d\n",area);
printf("The circumference is:%d",cir);
getch();
} - Rahim's basic salary is inpute through the keyboard.His house rent allowarnce is 30% of his basic salary and medical allowance is 5% of basic salary.He gets extra 1000 tk as technical allowance.Write a program to calculate his gross salary and print the result.
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int b,t,g;
float h,m;
printf("input rahim's basic salary:\n");
scanf("%d",&b);
h=(b*30)/100;
m=(b*5)/100;
t=1000;
g=(b)+(h)+(m)+(t);
printf("Rahim's gross salary is:%d",g);
getch();
} - Two anumbers are input through the keyboard into two locations A and B. Write a program to interchange the contents of A and B.
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,temp;
printf("Enter the value of A:");
scanf("%d",&a);
printf("Enter the value of B:");
scanf("%d",&b);
temp=a;
a=b;
b=temp;
printf("\n\nAfter interchange the value of A is:%d",a);
printf("\n\nAfter interchange the value of B is:%d",b);
getch();
} - If a 5 digit number is input through the keyboard, Write a program to calculate and print the sum of its digits.
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int rem,sum=0;
int num;
printf("A 5 digit number is?\n");
scanf("%d",&num);
rem=num%10;
sum=rem+sum;
num=num/10;
rem=num%10;
sum=rem+sum;
num=num/10;
rem=num%10;
sum=rem+sum;
num=num/10;
rem=num%10;
sum=sum+rem;
num=num/10;
sum=sum+num;
printf("\nThe sum of the digits of this number is:%d",sum);
getch();
} - If a 5 digit number is input through the keyboard, Write a program to reverse the number.
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
long int rem,numb=0;
long int num;
printf("Enter the 5 digit number ?\n");
scanf("%ld",&num);
rem=num%10;
numb=numb+(10000*rem);
num=num/10;
rem=num%10;
numb=numb+(1000*rem);
num=num/10;
rem=num%10;
numb=numb+(100*rem);
num=num/10;
rem=num%10;
numb=numb+(10*rem);
num=num/10;
numb=numb+num;
printf("The reverse number of this number is:%ld",numb);
getch();
} - If a 4 digit number is input through the keyboard, Write a program to obtain the sum of the first and last digit of this number.
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int rem,sum=0;
int num;
printf("A 4 digit number is?\n");
scanf("%d",&num);
rem=num%10;
sum=rem+sum;
num=num/10;
rem=num%10;
num=num/10;
rem=num%10;
num=num/10;
rem=num%10;
sum=sum+rem;
printf("\nThe sum of the first and last digit of this number is:%d",sum);
getch();
}
Search Here
Wednesday, March 30, 2011
Preliminary C programming
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment