Pps Programs
Pps Programs
Output :-
enter the value of a:15
enter the value of b:40
the sum of two number is: 55
DATE :-19|9|24
AIM:-Write a program to find the size of float , int , char
and long float datatype.
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a=sizeof (float);
int b=sizeof (int);
int c=sizeof (char);
int d=sizeof (long float);
printf("the size of the float datatype : %d\n",a);
printf("the size of the integer datatype : %d\n",b);
printf("the size of the char datatype : %d\n",c);
printf("the size of the long float datatype : %d\n",d);
getch();
return 0;
}
Output :-
the size of the float datatype : 4
the size of the integer datatype : 2
the size of the char datatype : 1
the size of the long float datatype : 8
DATE :-19|9|24
AIM:-Write a C program to check AND gate.
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c;
clrscr();
printf("enter the first number:\n");
scanf("%d",&a);
printf("enter the second number:\n");
scanf("%d",&b);
c=a&b;
printf("the AND gate between first and second number is :%d\n",c);
getch();
return 0;
}
Output :-
enter the first number:5
enter the second number:39
the AND gate between first and second number is :5
DATE :-26|9|24
AIM:-Write a C program to check OR gate.
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c;
clrscr();
printf("enter the first number :\n");
scanf("%d",&a);
printf("enter the second number :\n");
scanf("%d",&b);
c=a||b;
printf("the OR gate between first and second number is :%d\n",c);
getch();
return 0;
}
Output :-
enter the first number:5
enter the second number:39
the OR gate between first and second number is :39
DATE :-26|9|24
AIM:-Write a C program to shift the given number
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b;
clrscr();
printf("enter the number :\n");
scanf("%d",&a);
b=(a<<2);
printf("after shift number is :%d\n",b);
getch();
return 0;
}
Output :-
enter the number:2
after shift number is :8
DATE :-26|9|24
AIM:-Write a C program to convert minutes into years
and days .
#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
clrscr();
printf(" enter the min to covert in years or in days");
scanf("%d",&a);
b=a/(24*365);
printf("the min in years : %d\n",b);
c=a/24;
printf("the min in days : %d\n",c);
getch();
return 0;
}
Output :-
enter the min to covert in years and in days :40272728929
the min in years : 3078
the min in days : 1123627
DATE:-3|10|24
AIM:-Write a C program to check whether number is
positive , negative or zero.
#include<stdio.h>
#include<conio.h>
int main()
{
float a;
clrscr();
printf("enter the number:");
scanf("%f",&a);
if (a==0)
printf("%f you entered 0");
if (a>0)
printf("%f is positive number",a);
else
printf("%f is negative number",a);
getch();
return 0;
}
Output :-
enter the number:4
4 is positive number
DATE :-3|10|24
AIM:-Write a C program to check whether the
number is even or odd.
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b;
clrscr();
printf("enter the number:");
scanf("%d",&a);
if (a%2==0)
printf("the number is even ");
else
printf("thr number is odd ");
getch();
return 0;
}
Output :-
enter the number:8
the number is even
DATE :-3|10|24
AIM:-Write a C program to input week number and print week day.
#include<stdio.h>
#include<conio.h>
int main(){
int day;
clrscr();
printf("enter the day");
scanf("%d",&day);
switch (day)
{
case 1:
printf("Monday");
break;
case 2:
printf("Tuesday");
break;
case 3:
printf("Wednesday");
break;
case 4:
printf("Thursday");
break;
case 5:
printf("Friday");
break;
case 6:
printf("Saturday");
break;
case 7:
printf("Sunday");
break;
defult:
printf("invalid case ");
}
getch();
return 0;
}
Output :-
enter the day : 5
Friday
DATE :-17|10|24
AIM:-Write a program to enter two number and find their sum
and difference.
#include<stdio.h>
#include<conio.h>
int main(){
float a,b,c,d,e;
int operation;
clrscr();
printf("enter the first number:");
scanf("%f",&a);
printf("enter the second number:");
scanf("%f",&b);{
printf("for sum enter 1\n ");
printf("for difference enter 2\n");
scanf("%d",&c);
}
if (c==1){
d=a+b;
printf("the sum is %f",d);
}
if (c==2){
e=a-b;
printf("the difference is %f",e);
}
else{
printf("invalid case");
}
getch();
return 0;
}
Output :-
enter the first number:6
enter the second number:30
for sum enter 1
for difference enter 2
1
The sum is 36
DATE :-17|10|24
AIM:-Write a C program using loop.
#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,sum=0;
clrscr();
for(i=1;i<=5;i++)
{
sum=sum+i;
}
printf("%d\n",sum);
getch();
return 0;
}
Output :-
15
DATE :-17|10|24
AIM:-Write a program to display table of any number .
#include<stdio.h>
#include<conio.h>
int main()
{
int a,i;
clrscr();
printf(" enter the number of table you want:");
scanf("%d",&a);
for(i=1;i<=10;i++)
{
printf("%d x %d =%d\n",a,i,a*i);
}
getch();
return 0;
}
Output :-
Enter the number of table you want:5
5x1=1
5x2=10
5x3=15
5x4=20
5x5=25
5x6=30
5x7=35
5x8=40
5x9=45
5x10=50
DATE :-24|10|24
AIM :- Write a c program to take input and display it
using array function.
#include<stdio.h>
#include<conio.h>
int main ()
{
int cmarks[2];
clrscr();
printf("enter the first marks:");
scanf("%d",&cmarks[0]);
printf("enter the second marks:");
scanf("%d",&cmarks[1]);
printf("the first marks is : %d\n",cmarks[0]);
printf("the second marks is : %d\n",cmarks[1]);
getch();
return 0;
}
Output :-
enter the first marks :35
enter the second marks :30
Output :-
Enter the value of first matrix:
1
2
3
4
Enter the value of second matrix:
5
2
9
7
Sum =
6
4
12
11
DATE :-21|11|24
AIM:-Write a C program to find the largest integer among
the given integer.
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a[50];
int i,n;
int large=0;
printf("enter the number of elements:");
scanf("%d",&n);
for (i=0;i<n;i++)
{
printf("enter the elements");
scanf("%d",&a[i]);
}
for (i=0;i<n;i++)
{
if (a[i]>large)
large=a[i];
}
printf("the largest number is %d",large);
getch();
return 0;
}
Output :-
Output :-
Output :-
Output :-
Output :-
Output:-
Output:-
enter the value of a:45
45 002D 1258
DATE :19|12|24
AIM:-Write a C program using generic pointer .
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int x=10;
char ch='a';
float f=0.25;
void *gp;
gp=&x;
printf("\n generic pointer points to the integer value
=%d",*(int*)gp);
gp=&ch;
printf("\n generic pointer points to the character =%c",*(char*)gp);
gp=&f;
printf("\n generic pointer points to the float =%f",*(float*)gp);
getch();
return 0;
}
Output:-
generic pointer points to the integer value=10
generic pointer points to the character=a
generic pointer points to the float=0.250000
DATE :19|12|24
AIM:-Write a C program to enter student name ,
branch, roll no ,fees using structures.
#include<stdio.h>
#include<conio.h>
struct student
{
char name[20],branch[20];
int roll_no,fees;
};
int main()
{
int i,n;
clrscr();
printf("\n enter the number of students:");
scanf("%d",&n);
struct student stud[10];
for(i=0;i<n;i++)
{
printf("\n enter the student %d,branch,roll_no,fees:",i+1);
scanf("%s %s %d %d", &stud[i].name ,&stud[i].branch ,
&stud[i].roll_no ,&stud[i].fees);
}
for(i=0;i<n;i++)
{
printf(" student: %d\n name: %s\n branch: %s\n roll_no: %d\n
fees:
%d\n",i+1,stud[i].name,stud[i].branch,stud[i].roll_no,stud[i].fees);
}
getch();
return 0;
}
Output:-
enter the number of students:2
enter the student 1 , branch , roll_no , fees:himanshu Cse 4 40000
enter the student 2 , branch , roll_no , fees:prashant Cse 42 40000
student: 1
name: himanshu
branch: Cse
roll_no: 4
fees: 40000
student: 2
name: prashant
branch: Cse
roll_no: 42
fees: 40000