Download as pdf
Download as pdf
You are on page 1of 17
. ca 0 numb, el f Big gest among thae as Hrinclucle #2 Casey) pak ec” 4 a hey D2 ebse 4 Cbs painly CB & beg "D2 ws J punk Ce beg"). 4 J Oulpul > Enis Ghee ee eo oe Cau bey 2) Reots of a quacrabic equation ig 1 Als ab VBR ae 2a An. -b HVEF=Fae 2a visran bg, if dzo ig dao = gh+ NEED aae 2e a: ° 2 vy sob - tv be sas 24 oa Hinclude zetdio. WS include math hd vei main c? © at abcd, r72, TP» Ip, ie C" Enter arb “De Seong C4 rg of "da db teu d= eb kb 4 kaKc. % dxdo é T= C-b+ St Cd) faxo z 42 eb o- sqrtCd A, way Pans Ganga : Crestt = v4 voot2 = 7-4 2 M1 7204 a4 Sle ip @=-o) rlcy2 = —b faxa) - pring C° voct= root 2 = v4 "oot |) J ele ‘pe -b/@4a) 7 'p = sqrt Cd /Gra) Z print C" yoott = “4 wold = rf ‘veal rp Ap2: od 3: Censling Fibmacet Soules tylithoud Aseeee™ include Void main L nk tp ram 2 ink piso, fae $3 clucne > pack c: Ente heeo many Ros"! Seong CO yd’, & nim for Ciel. fds num; tH) i daz $4427 prin Ge 400 4 (f $24 ae fay y £ 7 A Prime Number checking perxgter Ain clude Lstdio.h> Void maine? T ink nt flags o + Prnly _*... ee Scand Cvd 2 WO: if (ns=6 fins=D she for Cita zie anfay +410 ip th¥b= =o? L ager break » 4 4 if Qlep =o? prin, C’ vd & O prime numba: B, nde purty C yd ha a prime number’ 02: 4 Stumm of on numbers ! Hrinclude <3 tdio hs void main) t ink = aCooJ-sums O7 rk tne print CO" Enter the ho of elemanh "9D. seanp O° nd" PRD? print? C’ Enter te elomant "D+ or Cis op ben, Ht) Soong nd ae aciz 24 forcize alin, iW Sums Bum tacht + y paint y C" the sum % enna as yd 4um), Enter he no a elemank: 5 Erba the. ekmenk 10 20 3o 4o so he aum a amray Bb (so. ~ Sum fuso NOs Urthg sfunckron. * fosboriol using BLEU sion, & Lpthonace u a a Medbrie addition. multiplication, mean. macioun - a Stedent thucbure - employer Structiae Count no of woads I'd a. pl: a Copying ore $ik te anche. 20. MATRIX MU SIPLICATION sinelnde 5 gevachle Zeon‘onn> void main() intA[10][10},B[10]10},C[2011201 1 int i,j,k pastepsa clrser(); . ‘ print(“Enter-th -ow-arnd-coturmr value of A-matrix”); seanf(%d%d", 4 : .d-columa-value of B matrix”); printf(“Enter-the tov ~scan%ed%ed?, &p aq). if} { iptication: ible’); im aurix printf(“Enter the elements of matrix A”); for(i=0; 1: i+) forli-Oi /* Preprocessor Section*/ #include int aul /* Global Variable declaration*/ int waeal(intint); /* Function declaration */ void main() /* main(Q) function */ { int c /* Local Variable declaration*/ clrscr(); // Executable part of the main()program printf(“\n Enter the values for a and b:\n”); scanf| hd %d” &a,&b); c=agal(ab); adoliton printf(“\n Muttiplieation of %d¥ %d = %d",a,b,c); getch(); } ad int raal(int a,int b) /* Subprogram of mulQ function definition*/ { int c; /* Local Variable declaration */ c=aqb; // Executable part of the function return (c); Output: Enter the values fora and b: 5 3 {Multiplication of 5 * 3 = 15 Program 8.1: Finding factorial of number using recursive function — #include #include int fact(int); void main() { int n; cIrscrQ); printf(“Enter the number :\n”); scanf(“%d",&n); printf(“factorial of %d = %d"\n,fact(n)); getch(); 248 Programming inC int fact(int x) { inti; if(x == 1) return(1); else i=x*fact(x-1); return(i); } Output: Enter the number : a) factorial of 5 = 120 Program 8.3: Write a program to print the Fibonacci series using recursion. | #include | int Fibonacci (int); int main() { int n, i =0, res; printf(“Enter the number of terms\n”); scanf(“%d", &n); printf(“Fibonacci series\n”); for(i = 0; i #include main () { FILE *fpl, *fp2; char filename! [20], filename[20]; str[30]; clrser(); printf(“\n Enter the name of the first filename: “); gets(filenamel); fflush(stdin); printf(‘\n Enter the name of the second filename: “); gets(filename2); fllush(stdin); if((fp 1=fopen(filenamel, “r”))==0) { printf(“\n Error opening the first file”); exit(1); } if(fp2=fopen(filename2, “w"))==0) { printf(“\n Error opening the second file”); exit(1); } Programming in C Lab Manual while((fgets(str, sizeof(str), fp1))!=NULL) fputs(str, fp2); felose(fp1); felose(fp2); getchQ); return 0; Enter the name of the first filename: a.txt Enter the name of the second filename: b.txt FILE COPIED et Bram No: OB File Name: Ex. No: Date: [——— POINTERS TO STRUCTURES: PRINTING STUDENT DETAILS Aim: To writeac Program to print student details using pointers and structures. Algorithm: 1. Start 2. Declare student structure 3. Read student roll number, student name, branch, marks. 4. Print student roll number, student name, branch, marks. 5. Stop. \ Progra ) #include void main() { struct { int rollno; char name[30]; char branch[4]; int marks; } *stud; prinl(™nEnterRolino:"); SS scanf(“%d”, &stud->rollno); printf(“\n Enter Name 2); scanf(“%s”,stud->name); printf(“\n Enter Branch:”); scanf(‘“%s”,stud->branch); printf(“\n Enter Marks:”); scanf(“%d”,&stud->marks); printf(“\n Roll Number:%d”,stud->rollno); printf(‘\n Name:%s”,stud->name); printf(“\n Branch:%s”,stud->branch); printf(“\n Marks: %d”,stud->marks); getchQ; } Output: Enter Rollno :1000 Enter Name :Ebisha Enter Branch:CSE Enter Marks:90 Roll Number:1000 Name:Ebisha Branch:CSE Marks:90

You might also like