cp1 1
cp1 1
cp1 1
PRACTICAL NO : 1.1
Output :
CSE – B1[AU-FEST] 1
COMPUTER PROGRAMMING SAMKIT DHAMI (CS 078)
PRACTICAL NO : 1.2
AIM : To learn about different data types in C programming.
Code :
#include<stdio.h>
int main()
{
int a=13;
float b=57.13;
char e='A';
float d=135.75;
printf("Integer=%d\n",a);
printf("Decimal=%f\n",b);
printf("character=%c\n",e);
printf("D=%d",d);
return 0;
}
Output :
CSE – B1[AU-FEST] 2
COMPUTER PROGRAMMING SAMKIT DHAMI (CS 078)
PRACTICAL NO : 1.3
AIM : To Print characters using ASCII values.
Code :
#include<stdio.h>
int main()
{
char N1='A';
int N2=78;
printf("ASCII value of A=%d\n",N1);
printf("char from ASCII value is =%c\n",N2);
return 0;
}
Output :
CSE – B1[AU-FEST] 3
COMPUTER PROGRAMMING SAMKIT DHAMI (CS 078)
PRACTICAL NO : 1.4
AIM : To Print formula of Simple Interest.
Algorithm :
1. Start the program.
2. Declare the variable P,R,T,SI.
3. Apply the formula for Simple interest :SI=(P*R*T)/100.
4. Print the value of SI.
5. End the program.
Flowchart :
CSE – B1[AU-FEST] 4
Code :
#include<stdio.h>
int main()
{
int P,R,T,SI;
printf("Enter principal amount=");
scanf("%d",&P);
printf("Enter Rate=");
scanf("%d",&R);
printf("Enter time=");
scanf("%d",&T);
SI=(P*R*T)/100;
printf("Simple Interest=%d",SI);
return 0;
}
Output :
CSE – B1[AU-FEST] 5
COMPUTER PROGRAMMING SAMKIT DHAMI (CS 078)
PRACTICAL NO : 1.5
AIM : To practice Arithmetic Operators in C Language.
Algorithm :
1.Start the program.
2.Declare the variable a,b,add,mul,div,sub.
3.Insert the value of a and b form user.
4.Use the formula : add=a+b , sub=a-b, div=a/b, mul=a*b.
5.Print the value of add,mul,sub,div.
6.End the program.
Flowchart :
CSE – B1[AU-FEST] 6
Code:
#include<stdio.h>
int main()
{
int a,b,add,mul,div,sub;
printf("enter the number 1=");
scanf("%d",&a);
printf("enter the number 2=");
scanf("%d",&b);
printf("the value of n1=%d and n2=%d",a,b);
add=a+b;
printf("addition of %d & %d=%d\n",a,b,add);
mul=a*b;
printf("multiplication of %d * %d = %d\n",a,b,mul);
div=a/b;
printf("division of %d / %d =%d\n",a,b,div);
sub=a-b;
printf("substraction of %d -%d = %d",a,b,sub);
return 0;
}
Output :
CSE – B1[AU-FEST] 7
COMPUTER PROGRAMMING SAMKIT DHAMI (CS 078)
PRACTICAL NO : 1.6
AIM : To swap 2 numbers with 3 variables.
Algoritham :
1. Start the program.
2. Declare 3 variable :a,b,c.
3. Swap the value of a and b by this method :
c=a.
a=b.
b=c.
4. After swap print the values of a and b.
5. End the program.
Flowchart :
CSE – B1[AU-FEST] 8
Code:
#include<stdio.h>
int main()
{
int a,b,c;
printf("Before swaping \n");
printf("\nEnter the number 1 : ");
scanf("%d",&a);
printf("\nEnter the number 2 : ");
scanf("%d",&b);
c=a;
a=b;
b=c;
printf("\nAfter swaping");
printf("\nThe number 1 is : %d",a);
printf("\nThe number 2 is : %d",b);
return 0;
}
Output :
CSE – B1[AU-FEST] 8
COMPUTER PROGRAMMING SAMKIT DHAMI (CS 078)
PRACTICAL NO : 1.7
Flowchart :
CSE – B1[AU-FEST] 8
Code:
#include<stdio.h>
int main()
{
int a,b,c;
printf("Before swaping \n");
printf("\nEnter the number 1 : ");
scanf("%d",&a);
printf("\nEnter the number 2 : ");
scanf("%d",&b);
a=a+b;
b=a-b;
a=a-b;
printf("\nAfter swaping");
printf("\nThe number 1 is : %d",a);
printf("\nThe number 2 is : %d",b);
return 0;
}
Output :
CSE – B1[AU-FEST] 9