Basic Programmes

1. WRITE A C PROGRAMME TO PRINT NAME, ADDRESS AND BIRTH DATE.

/*C programme to print Name, Address and Birth Date.*/
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
printf("\n Name : Abhilash"); 
printf("\n Address : London"); 
printf("\n Birth Date : 02-01-1998); 
getch();
return 0;
}
output
Name: Abhilash
Address: London
Birth Date:02-01-1999


2. WRITE A C PROGRAM TO DECLARE VARIABLE FOR INTEGER CHARACTER AND FLOAT

/*C program to declare variable for integer character and float*/
#include <stdio.h>
#include<conio.h>
int main(void)
{
int sum;
float money;
char letter;
double pi;
sum = 10; 
/* assign integer value */
money = 2.21; 
/* assign float value */
letter = ‘A’; 
/* assign a character value */
pi = 2.01E+6; 
/* assign a double value */
printf(“ value of sum = %d\n”, sum);
printf(“ value of money = %f\n”, money);
printf(“ value of letter = %c\n”, letter);
printf(“ value of double = %e\n”, pi);
return 0;
}
output
Value of sum = 10
Value of money = 2.210000
Value of letter = A
Value of pi = 2.010000e+06


3. WRITE A C PROGRAM TO DECLARE VARIABLE FOR INTEGER, FLOAT, I.E, OCTAL, DECIMAL, HEXA DECIMAL, FLOATING POINT AND EXPONENTIAL

/*C program to declare variable for integer, float, I.e, octal, decimal, hexa decimal, floating point and exponential*/
#include<stdio.h>
#include<conio.h>
int main()
{
int a;
float b;
clrscr();
printf(“enter a,b values”);
scanf(“%d%f”,&a,&b);
printf(“decimal form of %d=%d\noctal form=%o\n hexa decimal form =%x”,a,a,a);
printf(“floating point of %f=%f\n exponential form = %e”,b,b,b);
getch();
return 0;
}
output
Enter a,b values 88
99.6
Decimal form of 88=88
Octal form = 130
Hexa decimal form = 58
Floating point of 99.600000=99.600000
Exponential form = 9.960000e+1
at July 13, 2017 No comments:  


4. WRITE A C PROGRAM TO PERFORM ADDITION, SUBTRACTION, MULTIPLICATION AND DIVISION

/*C program to perform addition, subtraction, multiplication and division*/
#include<stdio.h>
#include<conio.h>
int main()
{
int num1,num2;
int sum,sub,mult,div,mod;
printf("\nEnter First Number :");
scanf("%d",&num1);
printf("\nEnter Second Number :");
scanf("%d",&num2);
sum = num1 + num2;
printf("\nAddition is : %d",sum);
sub = num1 - num2;
printf("\nSubtraction is : %d",sub);
mult = num1 * num2;
printf("\nMultiplication is : %d",mult);
div = num1 / num2;
printf("\nDivision is : %d",div);
mod = num1 % num2;
printf("\nModulus is : %d",mod);
return(0);
}
output
Enter First Number : 10
Enter Second Number : 5
Addition is : 15
Subtraction is : 5
Multiplication is : 50
Division is : 2
Modulus is : 0


5. WRITE A C PROGRAM TO EXPLAIN FORMATTED OUTPUT FUNCTION “PRINTF”

/*C program to explain formatted output function “printf”*/
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b;
clrscr();
printf(“enter a value”);
scanf(“%d”,&a);
printf(“\naccepted value is %d”,a);
printf(“\nenter b value”);
scanf(“%d”,%b);
printf(“\naccepted value is %d”,b);
printf(“\n their sum is %d”,a+b);
getch();
return 0;
}
output
Enter a value 102
Accepted value is 102
Enter b value 268
Accepted value is 268
Their sum is 370


6. WRITE A C PROGRAM TO EXPLAIN “TYPECASTING”

/*C program to explain “typecasting”*/
#include<stdio.h>
#include<conio.h>
Int main()
{
Int a,b,c;
float d;
a=1;b=2;c=4;
d=(float)(a+b+c)/3; <div class=”red”> /*type casting*/</div>
printf(“d=%f”,d);
getch();
return 0;
}
output
d = 2.133333

Comments