OUTPUT:-
AIM: WRITE A PROGRAM TO FIND GREATER NUMBER BETWEEN THREE NUMBERS. CODING:
#include<stdio.h> #include<conio.h> void main() { int a,b,c,big; clrscr(); /*variable declaration*/ /*to clear screen*/ /*inbuilt header file for standard input output*/ /*inbuilt header file for console input output*/ /*program starts*/
printf("enter value of a,b,c\n"); /*to get output on screen*/ scanf("%d %d %d",&a,&b,&c); if(a>b&&a>c) { printf("a is grater"); big=a; } else if(b>c) { printf("b is greater"); big=b; /*this will be output if this statement if its true*/ /*value stored*/ /*to get input from user*/ /*condition used*/
OUTPUT:
PROGRAM NO: 6 AIM: WRITE A PROGRAM TO FIND WHETHER THE NUMBER IS EVEN OR ODD. CODING:
#include<stdio.h> #include<conio.h> void main() { int num; c lrscr(); printf("enter number\n"); scanf("%d",&num); if(num%2==0) { printf("number is even"); } else { printf("number is odd"); } /*to get second statement displayed if first statement false*/ /*to get output on screen*/ /*to clear screen*/ /*to get output on screen*/ /*to get input from user*/ /*condition used*/ /*variable declaration*/ /*header file for standard input output*/ /*header file for console input output*/ /*program starts*/
10
/*end of program*/
OUTPUT:
11
12
OUTPUT:
13
14
15
16
17
PROGRAM NO: 10 AIM: WRITE A PROGRAM TO FIND NUMBER IS LEAP YEAR OR NOT. CODING:
#include<stdio.h> #include<conio.h> void main () { int n; clrscr(); printf("enter the number"); scanf("%d",&n); if(n%2==0) { printf("year is a leap year"); } else { printf("year is not a leap year"); /*integer declaration*/ /*to clear screen*/ /*to get output on screen*/ /*to get input from user*/ /*condition used*/ /*inbuilt header file for standard input output*/ /*inbuilt header file for console input output*/ /*program starts*/
18
OUTPUT:
19
20
21
OUTPUT:
22
23
OUTPUT:
24
25
Output:
26
AIM: WRITE A PROGRAM TO PRINT PYRAMID OF STARS USING FOR LOOP. CODING:
#include<stdio.h> #include<conio.h> void main() { int i,j; clrscr(); for(i=1;i<=25;i++) { for(j=1;j<=i;j++) { printf("*"); } printf("\n"); } getch();
27
Output:
28
29
30
31
32
Output:
33
34
OUTPUT:
35
36
OUTPUT:
37
38
OUTPUT:
39
AIM: WRITE A PROGRAM TO FIND WHETHER THE NUMBER IS PRIME OR NOT. CODING:
#include<stdio.h> #include<conio.h> void main () { int i,n; clrscr(); printf("enter the number to be checked"); scanf("%d",&n); for(i=2;i<=10;i++) if(n%1==0) { printf("the number is prime"); } else {
40
OUTPUT:
41
42
} getch(); }
OUTPUT:
43
44
OUTPUT:
45
46
OUTPUT:
47
48
49
50
OUTPUT:
51
CODING:
#include<stdio.h> #include<conio.h> #include<math.h> void main() { int a,b,c,d; float r1,r2; clrscr(); printf("Enter the values of a,b,c"); scanf("%d%d%d",&a,&b,&c); d=(b*b)-(4*a*c); printf("Discriminant is %d",d); if(d>0) { printf("\n the roots are real"); r1=((-b)+sqrt(d))/(2*a); r2=((-b)-sqrt(d))/(2*a);
52
53
54
CODING:
#include<stdio.h> #include<conio.h> void main() { int a[50],s,n,i,loc; printf("\n enter the size of list"); scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&a[i]); } printf("\n enter element to search"); scanf("%d",&s); for(i=1;i<n;i++) {
55
printf("\n Element %d is present at %d location",s,loc); break; } } if(i==n) printf("\n%d is not present in list",s); getch(); }
OUTPUT:
56
57
58
59
printf("Enter the number of rows in pyramid of numbers you wish to see "); scanf("%d",&n); temp = n; for ( row = 1 ; row <= n ; row++ ) { for ( c = 1 ; c < temp ; c++ ) printf(" "); temp--; for ( c = 1 ; c <= 2*row - 1 ; c++ ) printf("%d",c); printf("\n"); } getch(); }
60
61
62
OUTPUT:
63
64
OUTPUT:
65