List of Programs: Programs: 1. Polynomial addition
|
|
- Clarissa Mason
- 6 years ago
- Views:
Transcription
1 List of Programs: 1. Polynomial addition 2. Common operations on vectors in c 3. Matrix operation: multiplication, transpose 4. Basic Unit conversion 5. Number conversion: Decimal to binary 6. Number conversion: Binary to Octal 7. Number conversion: Octal to Hexadecimal 8. Square root of number 9. Implement SIMPSON'S 1/3 RULE 10. Implement Newton raphson method 11. Operations on polygon in c #include<math.h> Programs: 1. Polynomial addition /* This structure is used to store a polynomial term. An array of such terms represents a polynomial. The "coeff" element stores the coefficient of a term in the polynomial,while the "exp" element stores the exponent. */ struct poly float coeff; int exp; ; //declaration of polynomials struct poly a[50],b[50],c[50],d[50]; int main() int i; int deg1,deg2; int k=0,l=0,m=0; //stores degrees of the polynomial printf("enter the highest degree of poly1:"); scanf("%d",°1); //taking polynomial terms from the user for(i=0;i<=deg1;i++) //entering values in coefficient of the polynomial terms printf("\nenter the coeff of x^%d :",i);
2 scanf("%f",&a[i].coeff); //entering values in exponent of the polynomial terms a[k++].exp = i; //taking second polynomial from the user printf("\nenter the highest degree of poly2:"); scanf("%d",°2); for(i=0;i<=deg2;i++) printf("\nenter the coeff of x^%d :",i); scanf("%f",&b[i].coeff); b[l++].exp = i; //printing first polynomial printf("\nexpression 1 = %.1f",a[0].coeff); for(i=1;i<=deg1;i++) printf("+ %.1fx^%d",a[i].coeff,a[i].exp); //printing second polynomial printf("\nexpression 2 = %.1f",b[0].coeff); for(i=1;i<=deg2;i++) printf("+ %.1fx^%d",b[i].coeff,b[i].exp); //Adding the polynomials if(deg1>deg2) for(i=0;i<=deg2;i++) c[m].coeff = a[i].coeff + b[i].coeff; c[m].exp = a[i].exp; m++; else for(i=deg2+1;i<=deg1;i++) c[m].coeff = a[i].coeff; c[m].exp = a[i].exp; m++;
3 for(i=0;i<=deg1;i++) c[m].coeff = a[i].coeff + b[i].coeff; c[m].exp = a[i].exp; m++; for(i=deg1+1;i<=deg2;i++) c[m].coeff = b[i].coeff; c[m].exp = b[i].exp; m++; //printing the sum of the two polynomials printf("\nexpression after additon = %.1f",c[0].coeff); for(i=1;i<m;i++) printf("+ %.1fx^%d",c[i].coeff,c[i].exp); return 0; Output: Enter the highest degree of poly1:5 Enter the coeff of x^0 :1 Enter the coeff of x^1 :2 Enter the coeff of x^2 :3 Enter the coeff of x^3 :4 Enter the coeff of x^4 :5 Enter the coeff of x^5 :6 Enter the highest degree of poly2:4 Enter the coeff of x^0 :4 Enter the coeff of x^1 :3 Enter the coeff of x^2 :2 Enter the coeff of x^3 :1 Enter the coeff of x^4 :0 Expression 1 = x^1+ 3.0x^2+ 4.0x^3+ 5.0x^4+ 6.0x^5 Expression 2 = x^1+ 2.0x^2+ 1.0x^3+ 0.0x^4 Expression after additon = x^1+ 5.0x^2+ 5.0x^3+ 5.0x^4+ 6.0x^5 2. Common operations on vectors in c /* Vector addition */ int main() int a[10], b[10]; /* vectors to be added */
4 Output int c[10]; /* result vector */ int n, i; clrscr(); /* read vectors a and b */ printf("enter vector size: "); scanf("%d", &n); printf("enter elements of vector a:\n"); for (i = 0; i < n; i++) scanf("%d", &a[i]); printf("enter elements of vector b:\n"); for (i = 0; i < n; i++) scanf("%d", &b[i]); /* perform vector addition */ for (i = 0; i < n; i++) c[i] = a[i] + b[i]; /* print addition vector C */ printf("addition vector:\n"); for (i = 0; i < n; i++) printf("%d ", c[i]); getch(); #include <stdio.h> 3. Matrix operation: multiplication transpose Matrix multiplication int main() int m, n, p, q, c, d, k, sum = 0; int first[10][10], second[10][10], multiply[10][10]; printf("enter the number of rows and columns of first matrix\n"); scanf("%d%d", &m, &n); printf("enter the elements of first matrix\n"); for (c = 0; c < m; c++) for (d = 0; d < n; d++) scanf("%d", &first[c][d]); printf("enter the number of rows and columns of second matrix\n"); scanf("%d%d", &p, &q); if (n!= p) printf("matrices with entered orders can't be multiplied with each other.\n");
5 else printf("enter the elements of second matrix\n"); for (c = 0; c < p; c++) for (d = 0; d < q; d++) scanf("%d", &second[c][d]); for (c = 0; c < m; c++) for (d = 0; d < q; d++) for (k = 0; k < p; k++) sum = sum + first[c][k]*second[k][d]; multiply[c][d] = sum; sum = 0; printf("product of entered matrices:-\n"); for (c = 0; c < m; c++) for (d = 0; d < q; d++) printf("%d\t", multiply[c][d]); printf("\n"); return 0; #include <stdio.h> Transpose int main()
6 int a[10][10], transpose[10][10], r, c, i, j; printf("enter rows and columns of matrix: "); scanf("%d %d", &r, &c); // Storing elements of the matrix printf("\nenter elements of matrix:\n"); for(i=0; i<r; ++i) for(j=0; j<c; ++j) printf("enter element a%d%d: ",i+1, j+1); scanf("%d", &a[i][j]); // Displaying the matrix a[][] */ printf("\nentered Matrix: \n"); for(i=0; i<r; ++i) for(j=0; j<c; ++j) printf("%d ", a[i][j]); if (j == c-1) printf("\n\n"); // Finding the transpose of matrix a for(i=0; i<r; ++i) for(j=0; j<c; ++j) transpose[j][i] = a[i][j]; // Displaying the transpose of matrix a printf("\ntranspose of Matrix:\n"); for(i=0; i<c; ++i) for(j=0; j<r; ++j) printf("%d ",transpose[i][j]); if(j==r-1) printf("\n\n"); return 0; Output: Enter rows and columns of matrix: 2 3 Enter element of matrix: Enter element a11: 2 Enter element a12: 3 Enter element a13: 4 Enter element a21: 5 Enter element a22: 6 Enter element a23: 4 Entered Matrix:
7 Transpose of Matrix: Basic Unit conversion C code to convert one unit to other unit: #include<math.h> int main() char fromunit,tounit; char *funit,*tunit; long double fromvalue,metervalue,tovalue; int power =0; printf("to convert the 12 Inch to Foot\n"); printf("enter the the unit in the format : dc12\n"); printf("ell: a\n"); printf("femi: b\n"); printf("foot: c\n"); printf("inch: d\n"); printf("light year: e\n"); printf("metre: f\n"); printf("mile: g\n"); printf("nano meter: h\n"); printf("pace: i\n"); printf("point: j\n"); printf("yard: k\n"); printf("mili meter: l\n"); printf("centi meter: m\n"); printf("deci meter: n\n"); printf("deca meter: o\n"); printf("hecto meter: p\n"); printf("kilo meter: q\n"); scanf("%c%c%lf",&fromunit,&tounit,&fromvalue); switch(fromunit) case 'a': metervalue = fromvalue * 1.143; funit="ell"; break; case 'b': metervalue = fromvalue ; power = -15; funit="fm"; break; case 'c': metervalue = fromvalue * ; funit="ft"; break; case 'd': metervalue = fromvalue * ; funit="in"; break; case 'e': metervalue = fromvalue * ; power =15; funit="ly"; break; case 'f': metervalue = fromvalue; funit="m"; break; case 'g': metervalue = fromvalue * ; funit="mi"; break;
8 case 'h': metervalue = fromvalue; funit="nm"; power = -9; break; case 'i': metervalue = fromvalue * ; funit="pace"; break; case 'j': metervalue = fromvalue * ; funit="pt"; break; case 'k': metervalue = fromvalue * ; funit="yd"; break; case 'l': metervalue = fromvalue * 0.001; funit="mm"; break; case 'm': metervalue = fromvalue * 0.01; funit="cm"; break; case 'n': metervalue = fromvalue * 0.1; funit="deci meter"; break; case 'o': metervalue = fromvalue * 10; funit="deca meter"; break; case 'p': metervalue = fromvalue * 100; funit="hm"; break; case 'q': metervalue = fromvalue * 1000; funit="km"; break; default: printf("invalid input"); exit(0); switch(tounit) case 'a': tovalue = metervalue/1.143; tunit="ell"; break; case 'b': tovalue = metervalue; tunit="fm"; break; case 'c': tovalue = metervalue/0.3048; tunit="ft"; break; case 'd': tovalue = metervalue/0.0254; tunit="in"; break; case 'e': tovalue = metervalue/ ; tunit="ly"; break; case 'f': tovalue = metervalue; tunit="m";break; case 'g': tovalue = metervalue/ ; tunit="mi"; break; case 'h': tovalue = metervalue; tunit="nm"; break; case 'i': tovalue = metervalue/0.762; tunit="pace"; break; case 'j': tovalue = metervalue/ ; tunit="pt"; break; case 'k': tovalue = metervalue/0.9144; tunit="yd"; break; case 'l': tovalue = metervalue/0.001; tunit="mm"; break; case 'm': tovalue = metervalue/0.01; tunit="cm"; break; case 'n': tovalue = metervalue/0.1; tunit="deci meter"; break; case 'o': tovalue = metervalue/10; tunit="deca meter"; break; case 'p': tovalue = metervalue/100; tunit="hm"; break; case 'q': tovalue = metervalue/1000; tunit="km"; break; default: printf("invalid input"); exit(0); if(power==0) printf("%.4lf %s = %.4Lf %s",fromvalue,funit,tovalue,tunit); else while(tovalue > 10 printf("%.4lf %s = %.4Lf*10^%d %s",fromvalue,funit,tovalue,power,tunit); return 0; 5. Number conversion: Decimal to binary int main() long int m,no=0,a=1; int n,rem; printf("enter any decimal number->"); scanf("%d",&n); m=n; while(n!=0) rem=n%2; no=no+rem*a;
9 n=n/2; a=a*10; printf("the value %ld in binary is->",m); printf("%ld",no); return 0; 6. Number conversion: Binary to Octal /* * C Program to Convert Binary to Octal */ #include <stdio.h> int main() long int binarynum, octalnum = 0, j = 1, remainder; printf("enter the value for binary number: "); scanf("%ld", &binarynum); while (binarynum!= 0) remainder = binarynum % 10; octalnum = octalnum + remainder * j; j = j * 2; binarynum = binarynum / 10; printf("equivalent octal value: %lo", octalnum); return 0; 7. Number conversion: Octal to Hexadecimal /* C Program - Octal to Hexadecimal Conversion */ #include<conio.h> #include<string.h> #include<math.h> void main() clrscr(); int a[20], b[20], c[20], rev[20], h, i, j, k, l, x, fra, flag, rem, num1, num3; float rem1, num2, num4, dno; char s[20]; x = fra = flag = rem = 0; rem1 = 0.0; printf("enter any Octal Number : "); scanf("%s",s); for(i=0,j=0,k=0; i<strlen(s); i++) if(s[i]=='.') flag=1;
10 else if(flag==0) a[j++]=s[i]-48; else if(flag==1) b[k++]=s[i]-48; x=j; fra=k; for(j=0,i=x-1; j<x; j++,i--) rem = rem +(a[j] * pow(8,i)); for(k=0,i=1;k<fra;k++,i++) rem1 = rem1 +(b[k] / pow(8,i)); rem1 = rem + rem1; dno = rem1; num1 = (int)dno; num2 = dno - num1; i=0; while(num1!=0) rem = num1 % 16; rev[i] = rem; num1 = num1 /16; i++; j=0; while(num2!=0.0) num2 = num2 * 16; num3 = (int)num2; num4 = num2 - num3; num2 = num4; a[j] = num3; j++; if(j==4) break; l=i; printf("\nequivalent Hexadecimal Value = "); for(i=l-1; i>=0; i--) if(rev[i]==10) printf("a"); else if(rev[i]==11) printf("b");
11 else if(rev[i]==12) printf("c"); else if(rev[i]==13) printf("d"); else if(rev[i]==14) printf("e"); else if(rev[i]==15) printf("f"); else printf("%d",rev[i]); h=j; printf("."); for(k=0; k<h; k++) if(a[k]==10) printf("a"); else if(a[k]==11) printf("b"); else if(a[k]==12) printf("c"); else if(a[k]==13) printf("d"); else if(a[k]==14) printf("e"); else if(a[k]==15) printf("f"); else printf("%d",a[k]); getch();
12 8. Square root of number void main() float m,n; float num; n=0.0001; // This is taken small so that we can calculate upto decimal places also printf("enter A NUMBER : "); scanf("%f",&num); for(m=0;m<num;m=m+n) if((m*m)>num) m=m-n; // This if() is used to calculate the final value as soon as the square of the number exceeds break; // the number then we deduct the value exceeded and stop the procedure using break; this is our final value which is stored in m; printf("%.2f",m); getch(); return 1; 9. Implement SIMPSON'S 1/3 RULE #include<conio.h> float f(float x) return(1/(1+x)); void main() int i,n; float x0,xn,h,y[20],so,se,ans,x[20]; printf("\n Enter values of x0,xn,h: "); scanf("%f%f%f",&x0,&xn,&h); n=(xn-x0)/h; if(n%2==1) n=n+1; h=(xn-x0)/n; printf("\n Refined value of n and h are:%d %f\n",n,h); printf("\n Y values: \n"); for(i=0; i<=n; i++)
13 x[i]=x0+i*h; y[i]=f(x[i]); printf("\n %f\n",y[i]); so=0; se=0; for(i=1; i<n; i++) if(i%2==1) so=so+y[i]; else se=se+y[i]; ans=h/3*(y[0]+y[n]+4*so+2*se); printf("\n Final integration is %f",ans); getch(); Output #include<math.h> float f(float x) return x*log10(x) - 1.2; float df (float x) 10. Implement Newton raphson method
14 return log10(x) ; void main() int itr, maxmitr; float h, x0, x1, allerr; printf("\nenter x0, allowed error and maximum iterations\n"); scanf("%f %f %d", &x0, &allerr, &maxmitr); for (itr=1; itr<=maxmitr; itr++) h=f(x0)/df(x0); x1=x0-h; printf(" At Iteration no. %3d, x = %9.6f\n", itr, x1); if (fabs(h) < allerr) printf("after %3d iterations, root = %8.6f\n", itr, x1); return 0; x0=x1; printf(" The required solution does not converge or iterations are insufficient\n"); return 1; Output 11. Operations on polygon in c
PROGRAMMING IN C LAB MANUAL FOR DIPLOMA IN ECE/EEE
PROGRAMMING IN C LAB MANUAL FOR DIPLOMA IN ECE/EEE 1. Write a C program to perform addition, subtraction, multiplication and division of two numbers. # include # include int a, b,sum,
More informationProgramming in C Lab
Programming in C Lab 1a. Write a program to find biggest number among given 3 numbers. ALGORITHM Step 1 : Start Start 2 : Input a, b, c Start 3 : if a > b goto step 4, otherwise goto step 5 Start 4 : if
More informationWAP 10. WAP 11. WAP 12. WAP 13. WAP 14. WAP 15. WAP 16. WAP 1. : 17. WAP 18. WAP 19. WAP 20. WAP 21. WAP 22. WAP 23. WAP & 24. WAP
Contents 1. WAP to accept the value from the user and exchange the values.... 2 2. WAP to check whether the number is even or odd.... 2 3. WAP to Check Odd or Even Using Conditional Operator... 3 4. WAP
More informationF.E. Sem. II. Structured Programming Approach
F.E. Sem. II Structured Programming Approach Time : 3 Hrs.] Mumbai University Examination Paper Solution - May 13 [Marks : 80 Q.1(a) Explain the purpose of following standard library functions : [3] (i)
More information/* Area and circumference of a circle */ /*celsius to fahrenheit*/
/* Area and circumference of a circle */ #include #include #define pi 3.14 int radius; float area, circum; printf("\nenter radius of the circle : "); scanf("%d",&radius); area = pi
More informationBCSE1002: Computer Programming and Problem Solving LAB MANUAL
LABMANUAL BCSE1002: Computer Programming and Problem Solving LAB MANUAL L T P Course Type Semester Offered Academic Year 2018-2019 Slot Class Room Faculty Details: Name Website link Designation School
More informationPESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Basic Science and Humanities
PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Basic Science and Humanities Continuous Internal Evaluation Test 2 Date: 0-10- 2017 Marks: 0 Subject &
More informationUNIT III ARRAYS AND STRINGS
UNIT III ARRAYS AND STRINGS Arrays Initialization Declaration One dimensional and Two dimensional arrays. String- String operations String Arrays. Simple programs- sorting- searching matrix operations.
More informationStructured programming
Exercises 6 Version 1.0, 25 October, 2016 Table of Contents 1. Arrays []................................................................... 1 1.1. Declaring arrays.........................................................
More informationAPS105. Collecting Elements 10/20/2013. Declaring an Array in C. How to collect elements of the same type? Arrays. General form: Example:
Collecting Elements How to collect elements of the same type? Eg:., marks on assignments: APS105 Arrays Textbook Chapters 6.1-6.3 Assn# 1 2 3 4 5 6 Mark 87 89 77 96 87 79 Eg: a solution in math: x 1, x
More informationonly in the space provided. Do the rough work in the space provided for it. The question paper has total 12 pages.
Instructions: Answer all five questions. Total marks = 10 x 2 + 4 x 10 = 60. Time = 2hrs. Write your answer only in the space provided. Do the rough work in the space provided for it. The question paper
More information'C' Programming Language
F.Y. Diploma : Sem. II [DE/EJ/ET/EN/EX] 'C' Programming Language Time: 3 Hrs.] Prelim Question Paper Solution [Marks : 70 Q.1 Attempt any FIVE of the following : [10] Q.1(a) Define pointer. Write syntax
More informationTHE BAPATLA ENGINEERING COLLEGE:: BAPATLA DEPARTMENT OF MCA. Subject name: C programing Lab. Subject code: MCA 107. LAB manual of c programing lab
THE BAPATLA ENGINEERING COLLEGE:: BAPATLA DEPARTMENT OF MCA Subject name: C programing Lab Subject code: MCA 107 LAB manual of c programing lab 1. Write a C program for calculating compound interest. #include
More informationUnit 5. Decision Making and Looping. School of Science and Technology INTRODUCTION
INTRODUCTION Decision Making and Looping Unit 5 In the previous lessons we have learned about the programming structure, decision making procedure, how to write statements, as well as different types of
More informationNUMERICAL METHODS AND COMPUTATIONAL PROGRAMMING LAB MATH-204-F
LAB MANUAL NUMERICAL METHODS AND COMPUTATIONAL PROGRAMMING LAB MATH-204-F LIST OF EXPERIMENTS NUMERICAL METHODS OF COMPUTATIONAL PROGRAMMING LAB MATH-204-F S. No. NAME OF EXPERIMENTS 1. Solution of Non-linear
More informationGovernment Polytechnic Muzaffarpur.
Government Polytechnic Muzaffarpur. Name of the Lab: COMPUTER PROGRAMMING LAB (MECH. ENGG. GROUP) Subject Code: 1625408 Experiment: 1 Aim: Programming exercise on executing a C program. If you are looking
More informationName Roll No. Section
Indian Institute of Technology, Kharagpur Computer Science and Engineering Department Class Test I, Autumn 2012-13 Programming & Data Structure (CS 11002) Full marks: 30 Feb 7, 2013 Time: 60 mins. Name
More informationIntroduction to Computing Lecture 07: Repetition and Loop Statements (Part II)
Introduction to Computing Lecture 07: Repetition and Loop Statements (Part II) Assist.Prof.Dr. Nükhet ÖZBEK Ege University Department of Electrical & Electronics Engineering nukhet.ozbek@ege.edu.tr Topics
More informationC Language Part 2 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee
C Language Part 2 (Minor modifications by the instructor) 1 Scope Rules A variable declared inside a function is a local variable Each local variable in a function comes into existence when the function
More information/* Polynomial Expressions Using Linked List*/ #include<stdio.h> #include<conio.h> #include <malloc.h> struct node. int num; int coeff;
/* Polynomial Expressions Using Linked List*/ #include #include #include struct node int num; int coeff; struct node *next; ; struct node *start1 = NULL; struct node *start2
More informationQ1: Multiple choice / 20 Q2: C input/output; operators / 40 Q3: Conditional statements / 40 TOTAL SCORE / 100 EXTRA CREDIT / 10
EECE.2160: ECE Application Programming Spring 2016 Exam 1 February 19, 2016 Name: Section (circle 1): 201 (8-8:50, P. Li) 202 (12-12:50, M. Geiger) For this exam, you may use only one 8.5 x 11 double-sided
More informationLab Manual B.Tech 1 st Year
Lab Manual B.Tech 1 st Year Fundamentals & Computer Programming Lab Dev Bhoomi Institute of Technology Dehradun www.dbit.ac.in Affiliated to Uttrakhand Technical University, Dehradun www.uktech.in CONTENTS
More informationProgramming and Data Structures Mid-Semester - Solutions to Sample Questions Dept. of Computer Science and Engg. IIT Kharagpur Spring
Programming and Data Structures Mid-Semester - s to Sample Questions Dept. of Computer Science and Engg. IIT Kharagpur Spring 2015-16 February 15, 2016 1. Tick the correct options. (a) Consider the following
More informationEECE.2160: ECE Application Programming Spring 2016 Exam 1 Solution
EECE.2160: ECE Application Programming Spring 2016 Exam 1 Solution 1. (20 points, 5 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling
More informationLAB MANUAL. ANTC Lab (ME-321- F) DEPARTMENT OF APPLIED SCIENCE AND HUMINITIES
LAB MANUAL ANTC Lab (ME-321- F) DEPARTMENT OF APPLIED SCIENCE AND HUMINITIES 1 Check list for Lab Manual S. No. Particulars Page Number 1 Mission and Vision 3 2 Guidelines for the student 4 3 List of Programs
More informationESC 101N: Fundmentals of Computing ( IInd Semester) Mid Sem II Examination PM, Monday 7th March, 2011
ESC 101N: Fundmentals of Computing (2010-11-IInd Semester) Mid Sem II Examination 3.30-4.30PM, Monday 7th March, 2011 Instructions 1. Write your name, roll number and section below and also in the space
More informationF.E. Sem. II. Structured Programming Approach
F.E. Sem. II Structured Programming Approach Time : 3 Hrs.] Mumbai University Examination Paper Solution - May 14 [Marks : 80 Q.1(a) What do you mean by algorithm? Which points you should consider [4]
More informationLABORATORY MANUAL APPLIED NUMERICAL TECHNIQUES AND COMPUTING LAB. ME 321 F
LABORATORY MANUAL APPLIED NUMERICAL TECHNIQUES AND COMPUTING LAB. ME 321 F LIST OF EXPERIMENTS APPLIED NUMERICAL TECHNIQUES AND COMP. SR.NO. NAME OF EXPERIMENTS DATE SIGNATURE 1. Solution of Non linear
More informationIosif Ignat, Marius Joldoș Laboratory Guide 5. Functions. FUNCTIONS in C
FUNCTIONS in C 1. Overview The learning objective of this lab session is to: Understand the structure of a C function Understand function calls both using arguments passed by value and by reference Understand
More informationUIC. C Programming Primer. Bharathidasan University
C Programming Primer UIC C Programming Primer Bharathidasan University Contents Getting Started 02 Basic Concepts. 02 Variables, Data types and Constants...03 Control Statements and Loops 05 Expressions
More informationProgramming & Data Structure Laboratory. Day 2, July 24, 2014
Programming & Data Structure Laboratory Day 2, July 24, 2014 Loops Pre and post test loops for while do-while switch-case Pre-test loop and post-test loop Condition checking True Loop Body False Loop Body
More informationFlow of Control. Selection. if statement. True and False in C False is represented by any zero value. switch
Flow of Control True and False in C Conditional Execution Iteration Nested Code(Nested-ifs, Nested-loops) Jumps 1 True and False in C False is represented by any zero value The int expression having the
More informationIntroduction to Programming. Sample Question Paper. Q. 1. a). What is an algorithm? 2.5 X10
Introduction to Programming Sample Question Paper Note: Q.No. 1 is compulsory, attempt one question from each unit. Q. 1. a). What is an algorithm? 2.5 X10 b) What do you mean by Program? Write a small
More informationIndian Institute of Technology, Kharagpur
Indian Institute of Technology, Kharagpur Department of Computer Science and Engineering Students: 700 Full marks: 60 Mid-Semester Examination, Autumn 2013-14 Programming and Data Structures (CS 11001)
More informationSolutions to Assessment
Solutions to Assessment [1] What does the code segment below print? int fun(int x) ++x; int main() int x = 1; fun(x); printf( %d, x); return 0; Answer : 1. The argument to the function is passed by value.
More informationINDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator EXAMINATION ( End Semester ) SEMESTER ( Spring ) Roll Number Section Name Subject Number C S 1 0 0 0 1 Subject Name Programming
More informationFundamentals of Programming
Fundamentals of Programming Lecture 4 Input & Output Lecturer : Ebrahim Jahandar Borrowed from lecturer notes by Omid Jafarinezhad Outline printf scanf putchar getchar getch getche Input and Output in
More informationFundamental of Programming (C)
Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi CE 43 - Fall 97 Lecture 4 Input and Output Department of Computer Engineering Outline printf
More informationFundamentals of Programming & Procedural Programming
Universität Duisburg-Essen PRACTICAL TRAINING TO THE LECTURE Fundamentals of Programming & Procedural Programming Session Eight: Math Functions, Linked Lists, and Binary Trees Name: First Name: Tutor:
More information-2017-18 1. a.. b. MS-Paint. Ex.No 1 Windows XP c. 23,, d. MS-Dos DIR /W /P /B /L. Windows Xp, MS-Paint, Dir ; 1. Properties 23 10111 23 27 23 17 2. Display Properties MS-Paint ok 1. Start All program
More informationMGM S JAWAHARLAL NEHRU ENGINEERING COLLEGE N-6, CIDCO, AURANGABAD LAB MANUALS SUB: COMPUTER LAB-II CLASS: S.E.CIVIL
MGM S JAWAHARLAL NEHRU ENGINEERING COLLEGE N-6, CIDCO, AURANGABAD LAB MANUALS (Procedure for conduction of Practical/Term Work) SUB: COMPUTER LAB-II CLASS: S.E.CIVIL Prepared by Ms.V.S.Pradhan Lab In charge
More informationWhat is recursion. WAP to find sum of n natural numbers using recursion (5)
DEC 2014 Q1 a What is recursion. WAP to find sum of n natural numbers using recursion (5) Recursion is a phenomenon in which a function calls itself. A function which calls itself is called recursive function.
More informationUNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING
UNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING APS 105 Computer Fundamentals Midterm Examination October 20, 2011 6:15 p.m. 8:00 p.m. (105 minutes) Examiners: J. Anderson, T. Fairgrieve,
More informationF.Y. Diploma : Sem. II [CO/CD/CM/CW/IF] Programming in C
F.Y. Diploma : Sem. II [CO/CD/CM/CW/IF] Programming in C Time : 3 Hrs.] Prelim Question Paper Solution [Marks : 70 Q.1 Attempt any FIVE of the following : [10] Q.1 (a) List any four relational operators.
More informationCOP 3223 Introduction to Programming with C - Study Union - Fall 2017
COP 3223 Introduction to Programming with C - Study Union - Fall 2017 Chris Marsh and Matthew Villegas Contents 1 Code Tracing 2 2 Pass by Value Functions 4 3 Statically Allocated Arrays 5 3.1 One Dimensional.................................
More informationQuestion Bank (SPA SEM II)
Question Bank (SPA SEM II) 1. Storage classes in C (Refer notes Page No 52) 2. Difference between function declaration and function definition (This question is solved in the note book). But solution is
More informationSubject: PIC Chapter 2.
02 Decision making 2.1 Decision making and branching if statement (if, if-, -if ladder, nested if-) Switch case statement, break statement. (14M) 2.2 Decision making and looping while, do, do-while statements
More informationECE 15 Fall 16 Midterm Solutions
ECE 15 Fall 16 Midterm Solutions This is a closed-book exam: no notes, books, calculators, cellphones, or friends are allowed. In problems 4 6, you can assume that the user s input is correct. If you need
More informationComputer Programming. C Array is a collection of data belongings to the same data type. data_type array_name[array_size];
Arrays An array is a collection of two or more adjacent memory cells, called array elements. Array is derived data type that is used to represent collection of data items. C Array is a collection of data
More informationC Program. Output. Hi everyone. #include <stdio.h> main () { printf ( Hi everyone\n ); }
C Program Output #include main () { printf ( Hi everyone\n ); Hi everyone #include main () { printf ( Hi everyone\n ); #include and main are Keywords (or Reserved Words) Reserved Words
More informationIosif Ignat, Marius Joldoș Laboratory Guide 4. Statements. STATEMENTS in C
STATEMENTS in C 1. Overview The learning objective of this lab is: To understand and proper use statements of C/C++ language, both the simple and structured ones: the expression statement, the empty statement,
More informationDEV BHOOMI INSTITUTE OF TECHNOLOGY
DEV BHOOMI INSTITUTE OF TECHNOLOGY Department of Computer Science and Engineering Year: 2rd Semester: 3rd CBNST Lab-PCS-302 LAB MANUAL Prepared By: HOD (CSE) DEV BHOOMI INSTITUTE OF TECHNOLOGY Department
More informationTo store the total marks of 100 students an array will be declared as follows,
Chapter 4 ARRAYS LEARNING OBJECTIVES After going through this chapter the reader will be able to declare and use one-dimensional and two-dimensional arrays initialize arrays use subscripts to access individual
More informationBITS PILANI, DUBAI CAMPUS DUBAI INTERNATIONAL ACADEMIC CITY, DUBAI FIRST SEMESTER
BITS PILANI, DUBAI CAMPUS DUBAI INTERNATIONAL ACADEMIC CITY, DUBAI FIRST SEMESTER 2017-2018 COURSE : COMPUTER PROGRAMMING (CS F111) COMPONENT : Tutorial#4 (SOLUTION) DATE : 09-NOV-2017 Answer 1(a). #include
More informationConcept of algorithms Understand and use three tools to represent algorithms: Flowchart Pseudocode Programs
Morteza Noferesti Concept of algorithms Understand and use three tools to represent algorithms: Flowchart Pseudocode Programs We want to solve a real problem by computers Take average, Sort, Painting,
More informationIntroduction to Programming
Introduction to Programming Lecture 5: Interaction Interaction Produce output Get input values 2 Interaction Produce output Get input values 3 Printing Printing messages printf("this is message \n"); Printing
More informationUnit 3 Decision making, Looping and Arrays
Unit 3 Decision making, Looping and Arrays Decision Making During programming, we have a number of situations where we may have to change the order of execution of statements based on certain conditions.
More informationCOP 3223 Introduction to Programming with C - Study Union - Fall 2017
COP 3223 Introduction to Programming with C - Study Union - Fall 2017 Chris Marsh and Matthew Villegas Contents 1 Code Tracing 2 2 Pass by Value Functions 4 3 Statically Allocated Arrays 5 3.1 One Dimensional.................................
More informationArrays in C. By Mrs. Manisha Kuveskar.
Arrays in C By Mrs. Manisha Kuveskar. C Programming Arrays An array is a collection of data that holds fixed number of values of same type. For example: if you want to store marks of 100 students, you
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The model answer and the answer written by candidate
More informationBranching is deciding what actions to take and Looping is deciding how many times to take a certain action.
3.0 Control Statements in C Statements The statements of a C program control the flow of program execution. A statement is a command given to the computer that instructs the computer to take a specific
More informationProgramming & Data Structure: CS Section - 1/A DO NOT POWER ON THE MACHINE
DS Tutorial: III (CS 11001): Section 1 Dept. of CS&Engg., IIT Kharagpur 1 Tutorial Programming & Data Structure: CS 11001 Section - 1/A DO NOT POWER ON THE MACHINE Department of Computer Science and Engineering
More information1) Write a C Program to check whether given year is Leap year or not. AIM: A C Program to check whether given year is Leap year or not.
1) Write a C Program to check whether given year is Leap year or not. AIM: A C Program to check whether given year is Leap year or not. #include int year; printf("enter a year:"); scanf("%d",&year);
More informationC Program Reviews 2-12
Program 2: From Pseudo Code to C ICT106 Fundamentals of Computer Systems Topic 12 C Program Reviews 2-12 Initialise linecount and alphacount to zero read a character while (character just read is not end
More informationMAHALAKSHMI ENGINEERING COLLEGE B TIRUCHIRAPALLI
MAHALAKSHMI ENGINEERING COLLEGE B TIRUCHIRAPALLI 621213 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Sub code: CS2203 SEM: III Sub Name: Object Oriented Programming Year: II UNIT-I PART-A 1. What is
More informationLaboratory 4. INSTRUCTIONS (part II) I. THEORETICAL BACKGROUND
PROGRAMMING LANGUAGES Laboratory 4 INSTRUCTIONS (part II) I. THEORETICAL BACKGROUND 1. Instructions (overview) 1.1. The conditional instruction (if..else) if(expresie) instruction1; else instruction2;
More informationMA 511: Computer Programming Lecture 3: Partha Sarathi Mandal
MA 511: Computer Programming Lecture 3: http://www.iitg.ernet.in/psm/indexing_ma511/y10/index.html Partha Sarathi Mandal psm@iitg.ernet.ac.in Dept. of Mathematics, IIT Guwahati Semester 1, 2010-11 Last
More informationProgramming and Data Structures
Programming and Data Structures Teacher: Sudeshna Sarkar sudeshna@cse.iitkgp.ernet.in Department of Computer Science and Engineering Indian Institute of Technology Kharagpur #include int main()
More informationQ 1. Attempt any TEN of the following:
Subject Code: 17212 Model Answer Page No: 1 / 26 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The
More informationUNIT 2 ARRAYS 2.0 INTRODUCTION. Structure. Page Nos.
UNIT 2 ARRAYS Arrays Structure Page Nos. 2.0 Introduction 23 2.1 Objectives 24 2.2 Arrays and Pointers 24 2.3 Sparse Matrices 25 2.4 Polynomials 28 2.5 Representation of Arrays 30 2.5.1 Row Major Representation
More informationAlgorithms Lab (NCS 551)
DRONACHARYA GROUP OF INSTITUTIONS, GREATER NOIDA Affiliated to Utter Pradesh Technical University Noida Approved by AICTE Algorithms Lab (NCS 551) SOLUTIONS 1. PROGRAM TO IMPLEMENT INSERTION SORT. #include
More informationFundamental of Programming (C)
Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 8 Array typical problems, Search, Sorting Department of Computer Engineering Outline
More informationStructured programming
Exercises 2 Version 1.0, 22 September, 2016 Table of Contents 1. Simple C program structure................................................... 1 2. C Functions..................................................................
More informationPOLYNOMIAL ADDITION. AIM:- To write a C program to represent a polynomial as a linked list and write functions for polynomial addition.
POLYNOMIAL ADDITION AIM:- To write a C program to represent a polynomial as a linked list and write functions for polynomial addition. ALGORITHM:- 1. Start the program 2. Get the coefficients and powers
More informationProgramming Language A
Programming Language A Takako Nemoto (JAIST) 22 October Takako Nemoto (JAIST) 22 October 1 / 28 From Homework 2 Homework 2 1 Write a program calculate something with at least two integer-valued inputs,
More informationMore Recursive Programming
PDS: CS 11002 Computer Sc & Engg: IIT Kharagpur 1 More Recursive Programming PDS: CS 11002 Computer Sc & Engg: IIT Kharagpur 2 Tower of Hanoi/Brahma A B C PDS: CS 11002 Computer Sc & Engg: IIT Kharagpur
More informationMTH 307/417/515 Final Exam Solutions
MTH 307/417/515 Final Exam Solutions 1. Write the output for the following programs. Explain the reasoning behind your answer. (a) #include int main() int n; for(n = 7; n!= 0; n--) printf("n =
More informationDepartment of Computer Science & Engineering Indian Institute of Technology Kharagpur. Practice Sheet #04
Department of Computer Science & Engineering Indian Institute of Technology Kharagpur Topic: Arrays and Strings Practice Sheet #04 Date: 24-01-2017 Instructions: For the questions consisting code segments,
More informationSRI VIDYA COLLEGE OF ENGINEERING & TECHNOLOGY, VIRUDHUNAGAR Department of CSE & IT Internal Test I
SRI VIDYA COLLEGE OF ENGINEERING & TECHNOLOGY, VIRUDHUNAGAR Department of CSE & IT Internal Test I Year & Sem: I B.E (CSE) & II Date of Exam: 21/02/2015 Subject Code & Name: CS6202 & Programming & Data
More informationSample Examination. Family Name:... Other Names:... Signature:... Student Number:...
Family Name:... Other Names:... Signature:... Student Number:... THE UNIVERSITY OF NEW SOUTH WALES SCHOOL OF COMPUTER SCIENCE AND ENGINEERING Sample Examination COMP1917 Computing 1 EXAM DURATION: 2 HOURS
More informationContents. Sr. No. Title of the Practical: Page no Signature. Gate. OR gate. EX-OR gate. gate. identifying ODD and EVEN number.
Contents Sr. No. Title of the Practical: Page no Signature 01. To Design and train a perceptron for AND Gate. 02. To design and train a perceptron training for OR gate. 03. To design and train a perceptron
More informationStructured programming
Exercises 4 Version 1.0, 10 October, 2016 Table of Contents 1. Flow control statements if-else............................................. 1 1.1. From lectures...........................................................
More informationINDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator EXAMINATION ( Mid Semester ) SEMESTER ( Autumn ) Roll Number Section Name Subject Number C S 1 0 0 0 1 Subject Name Programming
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) MODEL ANSWER
Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The model answer and the answer written by candidate
More informationIndian Institute of Technology Kharagpur Programming and Data Structures (CS10001) Autumn : Mid-Semester Examination
Indian Institute of Technology Kharagpur Programming and Data Structures (CS10001) Autumn 2017-18: Mid-Semester Examination Time: 2 Hours Full Marks: 60 INSTRUCTIONS 1. Answer ALL questions 2. Please write
More information1. Basics 1. Write a program to add any two-given integer. Algorithm Code 2. Write a program to calculate the volume of a given sphere Formula Code
1. Basics 1. Write a program to add any two-given integer. Algorithm - 1. Start 2. Prompt user for two integer values 3. Accept the two values a & b 4. Calculate c = a + b 5. Display c 6. Stop int a, b,
More informationIntroduction To C. Programming. Presented by: Jim Polzin. otto:
Introduction To C Programming Presented by: Jim Polzin e-mail: james.polzin@normandale.edu otto: http://otto.normandale.edu Table of Contents TABLE OF CONTENTS TABLE OF CONTENTS... 2 C OVERVIEW... 4 BASIC
More informationSubject: Fundamental of Computer Programming 2068
Subject: Fundamental of Computer Programming 2068 1 Write an algorithm and flowchart to determine whether a given integer is odd or even and explain it. Algorithm Step 1: Start Step 2: Read a Step 3: Find
More informationComputers Programming Course 12. Iulian Năstac
Computers Programming Course 12 Iulian Năstac Recap from previous course Strings in C The character string is one of the most widely used applications that involves vectors. A string in C is an array of
More informationDr. R. Z. Khan, Associate Professor, Department of Computer Science
ALIGARH MUSLIM UNIVERSITY Department of Computer Science Course: CSM-102: Programming & Problem Solving Using C Academic Session 2015-2016 UNIT-2: Handout-3 Topic: Control Structures (Selection & Repetition)
More informationLABORATORY MANUAL. (CSE-103F) FCPC Lab
LABORATORY MANUAL (CSE-103F) FCPC Lab Department of Computer Science & Engineering BRCM College of Engineering & Technology Bahal, Haryana Aim: Main aim of this course is to understand and solve logical
More informationUnit 1 - Arrays. 1 What is an array? Explain with Example. What are the advantages of using an array?
1 What is an array? Explain with Example. What are the advantages of using an array? An array is a fixed-size sequenced collection of elements of the same data type. An array is derived data type. The
More informationBerner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 2
Control Structures for C CS Basics 10) C Control Structures Emmanuel Benoist Fall Term 2016-17 Data Input and Output Single character In and Output Writing output data Control Statements Branching Looping
More informationStructured programming
Exercises 9 Version 1.0, 13 December, 2016 Table of Contents 1. Remainders from lectures.................................................... 1 1.1. What is a pointer?.......................................................
More informationCSC 373 Sections 501, 510 Winter 2015 C Examples
CSC 373 Sections 501, 510 Winter 2015 C Examples These are posted on condor. These notes do not have any #include directives. The.c files should compile as they are 1. Simple hello: 1_hello.c 2. Illustrates
More informationCOP 3223 Introduction to Programming with C - Study Union - Spring 2018
COP 3223 Introduction to Programming with C - Study Union - Spring 2018 Chris Marsh and Matthew Villegas Contents 1 Code Tracing 2 2 Pass by Value Functions 4 3 Statically Allocated Arrays 5 3.1 One Dimensional.................................
More informationPrepared by: Shraddha Modi
Prepared by: Shraddha Modi Introduction In looping, a sequence of statements are executed until some conditions for termination of the loop are satisfied. A program loop consist of two segments Body of
More information& Technology. Expression? Statement-x. void main() int no; scanf("%d", &no); if(no%2==0) if(no%2!=0) Syllabus for 1. of execution of statements.
statement- Computer Programming and Utilization (CPU) 110003 D) Decision Control Structure (if, if, if e if, switch, ) 1 Explain if with example and draw flowchart. if is used to control the flow of execution
More informationData types, variables, constants
Data types, variables, constants Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers 2.4 Memory Concepts 2.5 Arithmetic in C 2.6 Decision
More informationComputer Programming Unit 3
POINTERS INTRODUCTION Pointers are important in c-language. Some tasks are performed more easily with pointers such as dynamic memory allocation, cannot be performed without using pointers. So it s very
More information