0% found this document useful (0 votes)
47 views17 pages

Index: S.No Ex - No Date Program Page - No Remarks

The document contains programs written in C programming language to perform various tasks like finding the sum and product of two numbers, converting Celsius to Fahrenheit, checking if a number is prime, sorting arrays, handling student records using structures and unions, defining functions with and without arguments and return types, and calculating factorials using recursion. Each program is accompanied by its source code, input/output and description.

Uploaded by

Benitaarun
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views17 pages

Index: S.No Ex - No Date Program Page - No Remarks

The document contains programs written in C programming language to perform various tasks like finding the sum and product of two numbers, converting Celsius to Fahrenheit, checking if a number is prime, sorting arrays, handling student records using structures and unions, defining functions with and without arguments and return types, and calculating factorials using recursion. Each program is accompanied by its source code, input/output and description.

Uploaded by

Benitaarun
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

INDEX

S.NO EX.NO DATE


1 2 3 4 5 6 7 8 9 10 11 12 13 1a 1b 1c 1d 2 3 4 5 6 7 8 9a 9b

PROGRAM
Letter Writing Advertisement Inserting Symbols and Formulae Resume Table Conversion and Formatting Mail Merge and Letter Preparation Flowchart Inserting Charts Formula Editor Manipulate and Protect The Worksheet Sorting Sum and Product of Two Numbers Fahrenheit To Celsius Conversion

PAGE.NO REMARKS

INDEX

S.NO EX.NO DATE


14 15 16 17 18 19 20 21 22 23 24 25 9c 9d 9e 9f 10 11a 11b 12a 12b 12c 12d 12e

PROGRAM
Biggest Among Three Numbers Using If Else Statement Simple Calculator Using Switch Statement Fibonacci Series Prime or Not Sorting Numbers In an Array Program To Handle student Information Using Structures Program To Handle student Information Using Union Adding Two Numbers Without Argument and Without Return Type Subtracting Two Numbers With Argument and With Return Type Multiplication of Two Numbers With Argument and Without Return type Addition of Two Numbers Without Argument and With Return Type Factorial of a Number Using Recursive Function

PAGE.NO REMARKS

PROGRAM: //TO FIND THE SUM AND PRODUCT OF TWO NUMBERS #include<stdio.h> main() { int a,b,c,d; printf(Enter the number a and b); scanf(%d %d,&a,&b); printf(SUM OF TWO NUMBERS\n); c = a+b; printf(SUM OF TWO NUMBERS IS %d\n,c); printf(PRODUCT OF TWO NUMBERS\n); d = a*b; printf(PRODUCT OF TWO NUMBERS IS %d\n,d); } SAMPLE INPUT AND OUTPUT: Enter the number a and b 5 10 SUM OF TWO NUMBERS SUM OF TWO NUMBERS IS 15 PRODUCT OF TWO NUMBERS PRODUCT OF TWO NUMBERS IS 50

PROGRAM: //TO FIND THE FACTORIAL OF THE GIVEN NUMBER #include<stdio.h> main() { int fact=1,i,num; printf(Enter the number); scanf(%d,&num); for(i=1;i<=num;i++) { fact=fact*i; } printf(The factorial of %d is %d,num,fact); } SAMPLE INPUT AND OUTPUT: Enter the number 5 The factorial of 5 is 120 //CONVERT THE CELCIUS INTO FAHRENTEIET #include<stdio.h> main() { float cel,faren; printf(Enter the Celsius value...); scanf(%f,&cel); faren=(1.8*cel)+32; printf(The fahrenteiet value of the given %f celsius value is %f,cel,faren); } SAMPLE INPUT AND OUTPUT Enter the Celsius value...45 The fahrenteiet value of the given 45.000000 celsius value is 113.000000

PROGRAM: //TO FIND THE LARGEST OF THE THREE NUMBERS #include<stdio.h> main() { int a,b,c,big; printf(Enter the three numbers); scanf(%d %d %d,&a,&b,&c); big=a; if(big<b) big=b; else if (big<c) big=c; printf(The biggest of three number is %d,big); } SAMPLE OUTPUT: Enter the three numbers 93 43 23 The biggest of three number is 93

PROGRAM:
// SIMPLE CALCULATION USING SWITCH STATEMENT #include<stdio.h> main() { int a,b,c,d,e,f; while(1) { printf(\nEnter the number a and b ); scanf(%d %d ,&a, &b); printf(\nchoose one of the options given below); printf(\n1.Addition \n 2.Subtraction \n 3.Multiplication \n 4. Division \n 5. Exit); scanf(%d,&o); switch(o) { case 1: c = a+b; printf(The Addition of Two Numbers is %d ,c); break; case 2: d = a-b; printf(The Subtraction of Two Numbers is %d ,d); break; case 3: e = a*b; printf(The Multiplication of Two Numbers is %d ,e); break; } case 4: f = a/b; printf(The Division of Two Numbers is %d ,f); break; } default: } SAMPLE OUTPUT: Enter the number a and b .. 15 5 Choose one of the options given below 1.Addition 2.Subtraction 3.Multiplication 4.Division 5.Exit 1 The Addition of Two Numbers is 20 2 The Subtraction of Two Numbers is 10 3 The Multiplication of Two Numbers is 75 4 The Division of Two Numbers is 3 5 exit exit(0); }

PROGRAM: //TO PRINT THE FIBBONACI SERIES UPTO GIVEN NUMBERS #include<stdio.h> main() { int num,fib=0,a=0,b=1,i; printf(Enter the number); scanf(%d,&num); printf(\n FIBBONACI SERIES\n); if(num==0) printf(0); else { for(i=0;i<num;i++) { fib=fib+a; a=b; b=fib; printf(%d\t,fib); } } } SAMPLE INPUT AND OUTPUT Enter the number 5 FIBONACCI SERIES 0 1 1 2 3

PROGRAM: //FIND THE GIVEN NUMBER IS PRIME OR NOT #include <stdio.h> main() { int num,i=2; printf(Enter the number...); scanf(%d,&num); while(i<=num-1) { if(num%i==0) { printf(The given number is not a prime number); break; } i++; } if(i==num) printf(The given number is a prime); } SAMPLE OUTPUT: Enter the number...5 The given number is a prime

PROGRAM: /*ASCENDING AND DESCENDING ORDER OF THE GIVEN NUMBERS*/ #include<stdio.h> main() { int num[100],no,i,j,a; printf(Enter Upper Limit...); scanf(%d,&no); printf(Enter the numbers); for(i=0;i<no;i++) scanf(%d,&num[i]); for(i=0;i<no-1;i++) { for(j=i+1;j<no;j++) { if(num[i]<num[j]) { a=num[i]; num[i]=num[j]; num[j]=a; } } } printf(\nThe ascending order of the given numbers); for(i=0;i<no;i++) printf(\n%d,num[i]); printf(\n The descending number of the given numbers); for(j=no-1;j>=0;j-) printf(\n%d,num[j]); } SAMPLE OUTPUT Enter the number how many number you want to sort 5 Enter the numbers 10 30 50 60 20 The ascending order of the given numbers 10 20 30 50 60 The descending number of the given numbers 60 50 30 20 10

PROGRAM: //STUDENT RECORD USING POINTER AND STRUCT #include<stdio.h> main() { struct student { char name[25]; char regno[25]; int avg; char grade; } stud[50],*pt; int i,no; printf(Enter the number of the students...); scanf(%d,&no); for(i=0;i<no;i++) { printf(\n student[%d] information:\n,i+1); printf(Enter the name); scanf(%s,stud[i].name); printf(\nEnter the roll no of the student); scanf(%s,stud[i].regno); printf(\nEnter the average value of the student); scanf(%d,&stud[i].avg); } pt=stud; for(pt=stud;pt<stud+no;pt++) { if(pt->avg<30) pt->grade=D; else if(pt->avg<50) pt->grade=C; else if(pt->avg<70) pt->grade=B; else pt->grade=A; } printf(\n); printf(NAME REGISTER-NO AVERAGE GRADE\n); for(pt=stud;pt<stud+no;pt++) { printf(%-20s%-10s,pt->name,pt->regno); printf(%10d \t %c\n,pt->avg,pt->grade); } }

SAMPLE OUTPUT: Enter the number of the students 3 student[1] information: Enter the name MUNI Enter the roll no of the student 100 Enter the average value of the student 95 student[2] information: Enter the name LAK Enter the roll no of the student 200 Enter the average value of the student 55 student[3] information: Enter the name RAJA Enter the roll no of the student 300 Enter the average value of the student 25 NAME REGISTER-NO AVERAGE GRADE MANI 100 95 A LKA 200 55 B RAJA 300 25 D

PROGRAM: /*Write a program to print student name, total marks & average.*/ #include<stdio.h> #include<conio.h> union stud { int rollno; Char name[30]; int mark1,mark2,mark3,total; float avg; }a[25]; Void main() { int i,n; printf(enter the no. of students \n); scanf(%d,&n); for(i=0;i<n;i++) { printf(Enter the student %d details :,i+1); printf(\n roll no.:); scanf(%d,&a[i].rollno); printf(Name:); scanf(%d &a[i].name); printf(mark1:); scanf(%d,&a[i].mark1); printf(mark2:); scanf(%d,&a[i].mark2); printf(mark3:); scanf(%d,&a[i].mark3); a[i].total= a[i].mark1+a[i].mark2+a[i].mark3; a[i].avg=a[i].total/3; } printf(\t\t students marks details: \n); printf(\n Roll No\t Name \t Mark1\t mark2 \t mark3 \t Total \t Avg); for(i=0;i<n;i++) printf(\n %d\t%s\t%d\t%d\t%d\t%d\t%f, a[i].rollno, a[i].name, a[i].mark1, a[i].mark2 ,a[i].mark3, a[i].total ,a[i].avg); }

PROGRAM: //FUNCTIONS WITH OUT ARGUMENTS AND NO RETURN VALUES #include<stdio.h> main() { void sum(void); sum(); } void sum() { int a,b,c,d; printf(Enter the number a and b); scanf(%d %d,&a,&b); printf(SUM OF TWO NUMBERS\n); c = a+b; printf(SUM OF TWO NUMBERS IS %d\n,c); } SAMPLE OUTPUT: Enter the number a and b 25 10 SUM OF TWO NUMBERS SUM OF TWO NUMBERS IS 250

PROGRAM: //FUNCTION WITH ARGUMENTS AND RETURN VALUES #include<stdio.h> main() { int a,b,c; printf(Enter the two numbers...); scanf(%d %d,&a,&b); c=add(a,b); printf(The Subtraction of two numbers %d and %d is %d,a,b,c); } add(int x,int y) { int z; z=x-y; return(z); } SAMPLE OUTPUT: Enter the two numbers... 15 6 The Subtraction of two numbers 15 and 6 is 9

PROGRAM: //FUNCTIONS WITH ARGUMENTS BUT NO RETURN VALUES #include<stdio.h> main() { int a,b; printf(Enter two numbers....); scanf(%d%d,&a,&b); mul(a,b); } mul(int a,int b) { int c; c=a*b; printf(The Multiplication of two numbers %d and %d is %d,a,b,c); } SAMPLE OUTPUT Enter two Multiplication of two numbers 10 and 20 is 200

PROGRAM: //FUNCTIONS WITH OUT ARGUMENTS AND WITH RETURN VALUES #include<stdio.h> main() { int a[10],i,no,sum=0; printf(Enter the size of array...); scanf(%d,&no); printf(Enter the elements of the array...); for(i=0;i<no;i++) scanf(%d,&a[i]); for(i=0;i<no;i++) printf(\n%d,a[i]); sum=add(&a[0],no); printf(\nThe sum of %d numbers is...%d,no,sum); } add(int *pt,int n) { int i,a=0; for(i=0;i<n;i++) { a=a+*pt; pt++; } return(a); } SAMPLE OUTPUT: Enter the size of array... 5 Enter the elements of the array ... 1 2 3 4 5 1 2 3 4 5 The sum of 5 numbers is... 15

PROGRAM: #include<stdio.h> main() { int num,a; printf(Enter the number); scanf(%d,&num); a=recur(num); printf(The factorial of the number %d is %d,num,a); } recur(int no) { int fact=1; if(no==1) return(1); else fact=no*recur(no-1); } SAMPLE OUTPUT: Enter the number 5 The factorial of the number 5 is 120

You might also like