Professional Documents
Culture Documents
INDEX
S.No PRACTICAL NAME DATE REMARKS
1.
find the sum of digits of the number. Write a C program to concatenate two strings.
2.
Write a C program totake marks of a student as input and print his/her grades bases on criteria.
3.
a. Marks<40 c.
Fail
b. 40<=marks<59 Good
59<=marks<80 Excellent outstanding
d. 80<=marks
statement.
4.
5.
string using while loop. Write a C program to convert all the lowercase
6.
character to uppercase letter or vice versa. Write a C program to compute the roots of a
7.
8. 9.
number is aprogram or not, also check whetherit is divisible by a number or not. Write a C program to check whether a given year is aleap or not.
EXPERIMENT NUMBER : 1
Objective :WRITE A C PROGRAM TO FIND REVERSE AND SUM OF DIGITS OF NUMBER? #include<iostream.h> #include<conio.h> #include<stdio.h> void main() { clrscr(); int sum=0,n,rev=0,r; printf("enter a number "); scanf("%d", &n); while(n!=0) { r=n%10; rev=rev*10+r; sum=sum+r; n=n/10; } printf("Reverse is : %d \n",rev ); printf("Sum of digits is : %d",sum); getch(); }
OUTPUT:
EXPERIMENT NUMBER:2
Objective : WRITE A C PROGRAM TO CONCATENATE TWO STRINGS?
#include<stdio.h> #include<conio.h> #include<string.h> void main() { clrscr(); char a[100], b[100]; printf("Enter the value of first string : "); gets(a); printf("Enter the value of second string : "); gets(b); strcat(a,b); printf("String after concatenate : %s",a,b); getch(); }
OUTPUT:
EXPERIMENT NUMBER:3
Objective : WRITE A C PROGRAM TO TAKE MARKS OF A STUDENT AS INPUT AND PRINT HIS/HER GRDES BASES ON FOLLOWING CRITERIA USING IF ELSE STATEMENT. A.MARKS<40 FAIL B.40<=MARKS<59 GOOD C.59<=MARKS<80 EXCELLENT D.80<= OUTSTANDING
#include<stdio.h> #include<conio.h> #include<string.h> void main() { clrscr(); int m1,m2,m3,m4,m5,g; printf(" Enter the marks of Physics "); scanf("%d", &m1); printf("\n Enter the marks of maths "); scanf("%d", &m2); printf("\n Enter the marks of Chemistry "); scanf("%d", &m3); g=(m1+m2+m3)/3; printf("\n Grades of student %d ",g); if(g<40) printf("FAIL"); else if (g>=40 && g<=59) printf("GOOD"); else if (g>=59 && g<80) printf("EXCELLENT"); else printf("OUTSTANDING"); getch(); }
7
OUTPUT:
EXPERIMENT NUMBER : 4
Objective : WRITE A C PROGRAM TO TAKE MARKS OF A STUDENT AS INPUT AND PRINT HIS/HER GRDES BASES ON FOLLOWING CRITERIA USING SWITCH CASE STATEMENT. A.MARKS<40 FAIL B.40<=MARKS<59 GOOD C.59<=MARKS<80 EXCELLENT D.80<= OUTSTANDING #include<stdio.h> #include<conio.h> #include<string.h> void main() { clrscr(); int m1,m2,m3,g; printf("Enter the marks of Physics "); scanf("%d", &m1); printf("Enter the marks of Maths "); scanf("%d", &m2); printf("Enter the marks of Computer Science "); scanf("%d", &m3); g=(m1+m2+m3)/3; switch(g); case1: if(g<40) printf("FAIL"); break; case2: if(g>=40 && g<59) printf("GOOD"); break; if(g<=59 && g>80) printf("EXCELLENT"); break; printf("OUTSTANDING");
case3:
default getch(); }
OUTPUT:-
10
EXPERIMENT NUMBER : 5
Objective :Write a C program to compute the length of a string using while loop.
#include<stdio.h> #include<conio.h> #include<string.h> void main() { clrscr(); charstr[100]; int i=0; printf("Enter the character"); gets(str); while(str[i]!=NULL) i++; printf("The length of the string is %d", i); getch(); }
11
OUTPUT:
12
EXPERIMENT NUMBER : 6
Objective :Write a C program to convert all the lowercase character to uppercase letter or vice versa.
#include<stdio.h> #include<conio.h> #include<string.h> #include<ctype.h> void main() { clrscr(); int i=0,j=0; char a[50]; printf("Enter a string "); gets(a); while(a[i]!=NULL) { i++; } for(int j=0;j<=i;j++) { if(isupper(a[]j)) { a[j]=tolower(a[j]); } else { a[j]=toupper(a[j]); } printf("%c", a[j]); } getch(); }
13
OUTPUT :
14
EXPERIMENT NUMBER : 7
Objective :Write a C program to compute the roots of a quadratic equation. #include<stdio.h> #include<conio.h> #include<math.h> void main() { clrscr(); inta,b,c; float x,y,d; printf("Enter the value of a "); scanf("%d",&a); printf("Enter the value of b "); scanf("%d",&b); printf("Enter the value of c "); scanf("%d",&c); d=b*b-4*a*c; x=(-b-sqrt(d))/2*a; y=(-b+sqrt(d))/2*a; printf("First root is %f",x); printf("Second root is %f",y); getch(); }
15
OUTPUT :
16
EXPERIMENT NUMBER :8
Objective :Write a C program to check whether a given number is aprogram or not, also check
whetherit is divisible by a number or not.
inta,i,l=0; printf("Enter the number "); scanf("%d",&a); for(i=1;i<=a;i++) { if (a%i==0) l++; } If(l==2) printf("no is prime"); else printf("No is not prime"); getch(); }
17
OUTPUT :
18
EXPERIMENT NUMBER :9
Objective :Write a C program to check whether a given year is aleap or not.
#include<stdio.h> #include<conio.h> #include<math.h> void main() { clrscr(); int y; printf("Enter the year "); scanf("%d",&y); if(y%4==0) printf("Leap Year"); else printf("Not Leap year"); getch(); }
19
OUTPUT :
20
21
22