THE BAPATLA ENGINEERING COLLEGE:: BAPATLA DEPARTMENT OF MCA. Subject name: C programing Lab. Subject code: MCA 107. LAB manual of c programing lab
|
|
- Wilfrid Howard
- 6 years ago
- Views:
Transcription
1 THE BAPATLA ENGINEERING COLLEGE:: BAPATLA DEPARTMENT OF MCA Subject name: C programing Lab Subject code: MCA 107 LAB manual of c programing lab
2 1. Write a C program for calculating compound interest. #include<stdio.h> #include<conio.h> #include<math.h> void main() float p,r,t,ci; clrscr(); printf( Enter Principle, Rate and Time: ); scanf( %f%f%f,&p,&r,&t); ci=pow(p*(1+r/100),t); printf( Bank Loans Compound Interest = %f%,ci); getch();
3 2. Write a C program for calculating roots of a quadratic equation? #include <stdio.h> #include <math.h> /* This is needed to use sqrt() function.*/ int main() float a, b, c, determinant, r1,r2, real, imag; printf("enter coefficients a, b and c: "); scanf("%f%f%f",&a,&b,&c); determinant=b*b-4*a*c; if (determinant>0) r1= (-b+sqrt(determinant))/(2*a); r2= (-b-sqrt(determinant))/(2*a); printf("roots are: %.2f and %.2f",r1, r2); else if (determinant==0) r1 = r2 = -b/(2*a); printf("roots are: %.2f and %.2f", r1, r2); else real= -b/(2*a); imag = sqrt(-determinant)/(2*a); printf("roots are: %.2f+%.2fi and %.2f-%.2fi", real, imag, real, imag); return 0;
4 3. Write a C program for finding average of N numbers. #include<stdio.h> #include<conio.h> void main() int n, count; float sum = 0, x, avg; printf("\nenter How Many Numbers : "); scanf("%d", &n); for(count = 1; count <= n; count++) printf("x = "); scanf("%f", &x); sum += x; avg = sum / n; printf("\nthe Average of Numbers is : %0.2f", avg);
5 4. Write a C program to check whether the given number is prime or not? #include <stdio.h> int main() int n, i, flag=0; printf("enter a positive integer: "); scanf("%d",&n); for(i=2;i<=n/2;++i) if(n%i==0) flag=1; break; if (flag==0) printf("%d is a prime number.",n); else printf("%d is not a prime number.",n); return 0;
6 5. Write a C program to check weather given number is perfect number or not? #include<stdio.h> int main() int n,i=1,sum=0; printf("enter a number: "); scanf("%d",&n); while(i<n) if(n%i==0) sum=sum+i; i++; if(sum==n) printf("%d is a perfect number",i); else printf("%d is not a perfect number",i); return 0;
7 6. Write a C program to check weather given number is Armstrong number or not? #include <stdio.h> int main() int n, n1, rem, num=0; printf("enter a positive integer: "); scanf("%d", &n); n1=n; while(n1!=0) rem=n1%10; num+=rem*rem*rem; n1/=10; if(num==n) printf("%d is an Armstrong number.",n); else printf("%d is not an Armstrong number.",n);
8 7. Write a c program to check weather given number is palindrome or not? #include <stdio.h> int main() int n, reverse = 0, temp; printf("enter a number to check if it is a palindrome or not\n"); scanf("%d",&n); temp = n; while( temp!= 0 ) reverse = reverse * 10; reverse = reverse + temp%10; temp = temp/10; if ( n == reverse ) printf("%d is a palindrome number.\n", n); else printf("%d is not a palindrome number.\n", n); return 0;
9 8. Write a C program to demonstrate the difference between %, / operator? #include <stdio.h> int main() int dividend, divisor, quotient, remainder; printf("enter dividend: "); scanf("%d",÷nd); printf("enter divisor: "); scanf("%d",&divisor); quotient=dividend/divisor; /* Computes quotient */ remainder=dividend%divisor; /* Computes remainder */ printf("quotient = %d\n",quotient); printf("remainder = %d",remainder); return 0;
10 9. Write a C program to print following output #include<stdio.h> #include<conio.h> void main() int I,j; clrscr(); printf( the pattern is:\n ); for(i=1;i<5;i++) for(j=1;j<5;j++) printf( %d\t,j); printf( \n ); getch();
11 10. Write a C program to find sum of digits of a given integer? #include <stdio.h> int main() int n, t, sum = 0, remainder; printf("enter an integer\n"); scanf("%d", &n); t = n; while (t!= 0) remainder = t % 10; sum = sum + remainder; t = t / 10; printf("sum of digits of %d = %d\n", n, sum); return 0;
12 11. Write a C program to find factorial of a given number using recursion? #include<stdio.h> int factorial(int n); int main() int n; printf("enter an positive integer: "); scanf("%d",&n); printf("factorial of %d = %ld", n, factorial(n)); return 0; int factorial(int n) if(n!=1) return n*factorial(n-1);
13 12. Write a C program to find Fibonacci series using recursion? #include<stdio.h> void printfibonacci(int); int main() int k,n; long int i=0,j=1,f; printf("enter the range of the Fibonacci series: "); scanf("%d %d ",&n); printf("fibonacci Series: "); printf("%d ",0); printfibonacci(n); return 0; void printfibonacci(int n) long int first=0,second=1,sum; while(n>0) sum = first + second; first = second; second = sum; printf("%ld ",sum); n--;
14 13. Write a C program to read and write data onto the file? #include<stdio.h> struct Student int roll; char name[12]; int percent; s1 = 10, "SMJC", 80 ; int main() FILE *fp; struct Student s2; fp = fopen("ip.txt", "w"); fwrite(&s1, sizeof(s1), 1, fp); fclose(fp); fp = fopen("ip.txt", "r"); fread(&s2, sizeof(s2), 1, fp); fclose(fp); printf("\nroll : %d", s2.roll); printf("\nname : %s", s2.name); printf("\npercent : %d", s2.percent); return (0);
15 14. Write a C program to create and update an employee record using files? #include <stdio.h> #include <stdlib.h> #include <string.h> #define size 200 struct emp int id; char *name; *emp1, *emp3; void display(); void create(); void update(); FILE *fp, *fp1; int count = 0; void main(int argc, char **argv) int i, n, ch; printf("1] Create a Record\n"); printf("2] Display Records\n"); printf("3] Update Records\n"); printf("4] Exit"); while (1) printf("\nenter your choice : "); scanf("%d", &ch); switch (ch) case 1: fp = fopen(argv[1], "a"); create(); break; case 2: fp1 = fopen(argv[1],"rb"); display(); break; case 3:
16 case 4: fp1 = fopen(argv[1], "r+"); update(); break; exit(0); /* To create an employee record */ void create() int i; char *p; emp1 = (struct emp *)malloc(sizeof(struct emp)); emp1->name = (char *)malloc((size)*(sizeof(char))); printf("enter name of employee : "); scanf(" %[^\n]s", emp1->name); printf("enter emp id : "); scanf(" %d", &emp1->id); fwrite(&emp1->id, sizeof(emp1->id), 1, fp); fwrite(emp1->name, size, 1, fp); count++; // count to number of entries of records fclose(fp); /* Display the records in the file */ void display() emp3=(struct emp *)malloc(1*sizeof(struct emp)); emp3->name=(char *)malloc(size*sizeof(char)); int i = 1; if (fp1 == NULL) printf("\nfile not opened for reading"); while (i <= count) fread(&emp3->id, sizeof(emp3->id), 1, fp1); fread(emp3->name, size, 1, fp1);
17 printf("\n%d %s",emp3->id,emp3->name); i++; fclose(fp1); free(emp3->name); free(emp3); void update() int id, flag = 0, i = 1; char s[size]; if (fp1 == NULL) printf("file cant be opened"); return; printf("enter employee id to update : "); scanf("%d", &id); emp3 = (struct emp *)malloc(1*sizeof(struct emp)); emp3->name=(char *)malloc(size*sizeof(char)); while(i<=count) fread(&emp3->id, sizeof(emp3->id), 1, fp1); fread(emp3->name,size,1,fp1); if (id == emp3->id) printf("enter new name of emplyee to update : "); scanf(" %[^\n]s", s); fseek(fp1, -204L, SEEK_CUR); fwrite(&emp3->id, sizeof(emp3->id), 1, fp1); fwrite(s, size, 1, fp1); flag = 1; break; i++; if (flag!= 1)
18 printf("no employee record found"); flag = 0; fclose(fp1); free(emp3->name); /* to free allocated memory */ free(emp3);
19 15. Write a C program to calculate average of n numbers using arrays? #include <stdio.h> int main() int n, i; float num[100], sum=0.0, average; printf("enter the numbers of data: "); scanf("%d",&n); while (n>100 n<=0) printf("error! number should in range of (1 to 100).\n"); printf("enter the number again: "); scanf("%d",&n); for(i=0; i<n; ++i) printf("%d. Enter number: ",i+1); scanf("%f",&num[i]); sum+=num[i]; average=sum/n; printf("average = %.2f",average); return 0;
20 16. Write a c program for addition of two matrices? #include<stdio.h> void main() int a[3][3],b[3][3],c[3][3],i,j; printf("enter the First matrix->"); for(i=0;i<3;i++) for(j=0;j<3;j++) scanf("%d",&a[i][j]); printf("\nenter the Second matrix->"); for(i=0;i<3;i++) for(j=0;j<3;j++) scanf("%d",&b[i][j]); printf("\nthe First matrix is\n"); for(i=0;i<3;i++) printf("\n"); for(j=0;j<3;j++) printf("%d\t",a[i][j]); printf("\nthe Second matrix is\n"); for(i=0;i<3;i++) printf("\n"); for(j=0;j<3;j++) printf("%d\t",b[i][j]); for(i=0;i<3;i++) for(j=0;j<3;j++) c[i][j]=a[i][j]+b[i][j]; printf("\nthe Addition of two matrix is\n"); for(i=0;i<3;i++) printf("\n"); for(j=0;j<3;j++) printf("%d\t",c[i][j]);
21 17. Write a c Program for multiplication of two matrices? #include <stdio.h> 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"); 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++)
22 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;
23 18. Write a C program for sorting an array? #include <stdio.h> void main() int i, j, a, n, number[30]; printf("enter the value of N \n"); scanf("%d", &n); printf("enter the numbers \n"); for (i = 0; i < n; ++i) scanf("%d", &number[i]); for (i = 0; i < n; ++i) for (j = i + 1; j < n; ++j) if (number[i] > number[j]) a = number[i]; number[i] = number[j]; number[j] = a; printf("the numbers arranged in ascending order are given below \n"); for (i = 0; i < n; ++i) printf("%d\n", number[i]);
24 19. Write a c program to find row sum and column sum of a matrix? #include <stdio.h> void main () static int array[10][10]; int i, j, m, n, sum = 0; printf("enter the order of the matrix\n"); scanf("%d %d", &m, &n); printf("enter the co-efficients of the matrix\n"); for (i = 0; i < m; ++i) for (j = 0; j < n; ++j) scanf("%d", &array[i][j]); for (i = 0; i < m; ++i) for (j = 0; j < n; ++j) sum = sum + array[i][j] ; printf("sum of the %d row is = %d\n", i, sum); sum = 0; sum = 0; for (j = 0; j < n; ++j) for (i = 0; i < m; ++i) sum = sum + array[i][j]; printf("sum of the %d column is = %d\n", j, sum); sum = 0;
25 20. Write a C program to sort strings using pointers? #include<stdio.h> #include<conio.h> #include<string.h> void main() char *x[20]; int i,n=0; void reorder(int n,char *x[]); printf("enter no. of String : "); scanf("%d",&n); printf("\n"); for(i=0;i<n;i++) printf("enter the Strings %d : ",i+1); x[i]=(char *)malloc(20*sizeof(char)); scanf("%s",x[i]); reorder(n,x); printf("\nreorder list is : \n"); for(i=0;i<n;i++) printf("%d %s\n",i+1,x[i]); void reorder(int n,char *x[]) int i,j; char t[20]; for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) if(strcmp(x[i],x[j])>0) strcpy(t,x[j]); strcpy(x[j],x[i]); strcpy(x[i],t);
26 21. Write a c program for calculating number of words, characters in a given string? #include<stdio.h> #include<conio.h> int main() int count_words=0,i; int count_char=0; char str[20]; printf("enter string : "); gets(str); for(i=0; str[i]!=null; i++) count_char++; if(str[i]==' ') count_words++; printf("\nnumber of characters in string : %d",count_char); printf("\nnumber of words in string : % d",count_words+1); getch(); return 0;
27 22. Write a c program to demonstrate weather given string is palindrome or not? #include <stdio.h> #include <string.h> int main() char a[100], b[100]; printf("enter the string to check if it is a palindrome\n"); gets(a); strcpy(b,a); strrev(b); if (strcmp(a,b) == 0) printf("entered string is a palindrome.\n"); else printf("entered string is not a palindrome.\n"); return 0;
28 23. Write a c program to find number of words and vowels in a given string? #include<stdio.h> #include<stdlib.h> #include<ctype.h> #include<conio.h> #define low 1 #define high 0 void main() int nob, now, nod, nov, nos, pos = high; char *str; nob = now = nod = nov = nos = 0; clrscr(); printf("enter any string : "); gets(str); while (*str!= '\0') if (*str == ' ') // counting number of blank spaces. pos = high; ++nob; else if (pos == high) // counting number of words. pos = low; ++now; if (isdigit(*str)) /* counting number of digits. */ ++nod; if (isalpha(*str)) /* counting number of vowels */ switch (*str) case 'a': case 'e': case 'i': case 'o': case 'u': case 'A': case 'E': case 'I':
29 case 'O': case 'U': ++nov; break; /* counting number of special characters */ if (!isdigit(*str) &&!isalpha(*str)) ++nos; str++; printf("\nnumber of words %d", now); printf("\nnumber of spaces %d", nob); printf("\nnumber of vowels %d", nov); printf("\nnumber of digits %d", nod); printf("\nnumber of special characters %d", nos); getch();
30 24. Write a C program to demonstrate the self-referential structure? #include<stdio.h> #include<conio.h> #include<string.h> void main() struct student int rno; char name[10]; struct student *next; ; struct student s1; struct student s2; struct student s3; struct student *p; clrscr(); s1.rno=1; strcpy(s1.name,"aaa"); s1.next=&s2; s2.rno=2; strcpy(s2.name,"bbb"); s2.next=&s3; s3.rno=3; strcpy(s3.name,"ccc"); s3.next=null; p=&s1; printf("roll numbers and names of students are:\n"); while(p!= NULL) printf("%d\t %s\n",p->rno,p->name); p=p->next; getch();
31 25. Write a C program to demonstrate array of structures? #include<stdio.h> #include<conio.h> void main() struct student int rno; char name[15]; ; struct student std[10]; int i,n; clrscr(); printf("enter number of recoreds you want to store\n"); scanf("%d",&n); for(i=1;i<=n;i++) printf("enter number and name:\n"); scanf("%d%s",&std[i].rno,&std[i].name); for(i=1;i<=n;i++) printf("\nrecord of student %d is:\n",i); printf("%d\t%s",std[i].rno,std[i].name); getch(); 26.
32 27. Write a C program to find area of circle using macros? #include <stdio.h> #define PI #define area(r) (PI*(r)*(r)) int main() int radius; float area; printf("enter the radius: "); scanf("%d",&radius); area=area(radius); printf("area=%.2f",area); return 0;
33 28. Write a c program to demonstrate union in structure? #include <string.h> #include <stdio.h> typedef union int units; float kgs; amount ; typedef struct char selling[15]; float unitprice; int unittype; amount howmuch; product; int main() product dieselmotorbike; product apples; product * myebaystore[2]; int nitems = 2; int i; strcpy(dieselmotorbike.selling,"a Diesel Motor Cycle"); dieselmotorbike.unitprice = ; dieselmotorbike.unittype = 1; dieselmotorbike.howmuch.units = 4; strcpy(apples.selling,"granny dubois"); apples.unitprice = 0.78; apples.unittype = 2; apples.howmuch.kgs = 0.5; myebaystore[0] = &dieselmotorbike; myebaystore[1] = &apples;
34 for (i=0; i<nitems; i++) printf("\n%s\n",myebaystore[i]->selling); switch (myebaystore[i]->unittype) case 1: printf("we have %d units for sale\n", myebaystore[i]->howmuch.units); break; case 2: printf("we have %f kgs for sale\n", myebaystore[i]->howmuch.kgs); break;
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 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 informationSection 1: C Programming Lab
Course Code : MCSL-017 Course Title : C and Assembly Language Programming (Lab Course) Assignment Number : MCA(1)/015/Assignment/17-18 Maximum Marks : 100 Weightage : 25% Last Dates for Submission : 15th
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 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 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 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 informationList of Programs: Programs: 1. Polynomial addition
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:
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 informationTest Paper 1 Programming Language 1(a) What is a variable and value of a variable? A variable is an identifier and declared in a program which hold a value defined by its type e.g. integer, character etc.
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 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 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 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 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 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 informationSubject: PROBLEM SOLVING THROUGH C Time: 3 Hours Max. Marks: 100
Code: DC-05 Subject: PROBLEM SOLVING THROUGH C Time: 3 Hours Max. Marks: 100 NOTE: There are 11 Questions in all. Question 1 is compulsory and carries 16 marks. Answer to Q. 1. must be written in the space
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 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 informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)
Subject Code: 17212 Model Answer Page No: 1/28 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in themodel answer scheme. 2) The model
More informationWipro Technical Interview Questions
Wipro Technical Interview Questions Memory management in C The C programming language manages memory statically, automatically, or dynamically. Static-duration variables are allocated in main memory, usually
More informationDRONACHARYA COLLEGE OF ENGINEERING,GURGAON. Affiliated to M.D.U.,Rohtak. Approved by AICTE DEPARTMENT OF APPIED SEIENCES & HUMANITIES.
DRONACHARYA COLLEGE OF ENGINEERING,GURGAON Affiliated to M.D.U.,Rohtak Approved by AICTE DEPARTMENT OF APPIED SEIENCES & HUMANITIES Lab Manual for Fundamental of Computer Programming in C-LAB CSE-103 List
More informationC PROGRAMMING. Prof. (Dr.) S. N. Mishra (Prof. & Head, Dept. of CSEA, IGIT, Sarang)
LAB MANUAL C MING Prof. (Dr.) S. N. Mishra (Prof. & Head, Dept. of CSEA, IGIT, Sarang) C MING LAB Experiment No. 1 Write a C program to find the sum of individual digits of a positive integer. Experiment
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 informationStructured Programming Approach
Software Engineering MU 2. Project Scheduling CGBS 2015-2016 Structured Programming Approach FIRST YEAR HUMANITIES & SCIENCE (FEC205) MRS.ANURADHA BHATIA M.E. Computer Engineering Table of Contents 1.
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 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 informationLAB MANUAL LAB. Regulation : 2013 Branch. : B.E. All Branches Year & Semester : I Year / I Semester GE6161 COMPUTER PRACTICES
LAB MANUAL Regulation : 2013 Branch : B.E. All Branches Year & Semester : I Year / I Semester GE6161 COMPUTER PRACTICES LAB VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 1 ANNA UNIVERSITY: CHENNAI
More informationEx. No. 3 C PROGRAMMING
Ex. No. 3 C PROGRAMMING C is a powerful, portable and elegantly structured programming language. It combines features of a high-level language with the elements of an assembler and therefore, suitable
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 information1. Simple if statement. 2. if else statement. 3. Nested if else statement. 4. else if ladder 1. Simple if statement
UNIT- II: Control Flow: Statements and Blocks, if, switch statements, Loops: while, do-while, for, break and continue, go to and Labels. Arrays and Strings: Introduction, One- dimensional arrays, Declaring
More information1. Write a C program that receives 10 float numbers from the console and sort them in nonascending order, and prints the result
Solutions 1. Write a C program that receives 10 float numbers from the console and sort them in nonascending order, and prints the result #include int main() //Program Start float numbers[10],result;
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 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 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 informationMODULE 1. Introduction to Data Structures
MODULE 1 Introduction to Data Structures Data Structure is a way of collecting and organizing data in such a way that we can perform operations on these data in an effective way. Data Structures is about
More informationC Programming. First published on 3 July 2012 This is the 7 h Revised edition
First published on 3 July 2012 This is the 7 h Revised edition Updated on: 03 August 2015 DISCLAIMER The data in the tutorials is supposed to be one for reference. We have made sure that maximum errors
More informationC Programming. First published on 3 July 2012 This is the 8 th Revised edition
First published on 3 July 2012 This is the 8 th Revised edition Updated on: 19 August 2017 DISCLAIMER The data in the tutorials is supposed to be one for reference. We have made sure that maximum errors
More informationArrays. Arrays are of 3 types One dimensional array Two dimensional array Multidimensional array
Arrays Array is a collection of similar data types sharing same name or Array is a collection of related data items. Array is a derived data type. Char, float, int etc are fundamental data types used in
More informationMODULE 2: Branching and Looping
MODULE 2: Branching and Looping I. Statements in C are of following types: 1. Simple statements: Statements that ends with semicolon 2. Compound statements: are also called as block. Statements written
More informationWrite a C program using arrays and structure
03 Arrays and Structutes 3.1 Arrays Declaration and initialization of one dimensional, two dimensional and character arrays, accessing array elements. (10M) 3.2 Declaration and initialization of string
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 informationAryan College. Fundamental of C Programming. Unit I: Q1. What will be the value of the following expression? (2017) A + 9
Fundamental of C Programming Unit I: Q1. What will be the value of the following expression? (2017) A + 9 Q2. Write down the C statement to calculate percentage where three subjects English, hindi, maths
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 informationScheme of valuations-test 3 PART 1
Scheme of valuations-test 3 PART 1 1 a What is string? Explain with example how to pass string to a function. Ans A string constant is a one-dimensional array of characters terminated by a null ( \0 )
More informationM4.1-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE
M4.1-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE is to be
More informationSolution for Data Structure
Solution for Data Structure May 2016 INDEX Q1 a 2-3 b 4 c. 4-6 d 7 Q2- a 8-12 b 12-14 Q3 a 15-18 b 18-22 Q4- a 22-35 B..N.A Q5 a 36-38 b N.A Q6- a 39-42 b 43 1 www.brainheaters.in Q1) Ans: (a) Define ADT
More informationCS240: Programming in C
CS240: Programming in C Lecture 10: Review - Structures and Memory Allocation Unions Recap: Structures Holds multiple items as a unit Treated as scalar in C: can be returned from functions, passed to functions
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 informationAlgorithms 4. Odd or even Algorithm 5. Greatest among three numbers Algorithm 6. Simple Calculator Algorithm
s 4. Odd or even Step 3 : If number divisible by 2 then Print "Number is Even" Step 3.1 : else Print "Number is Odd" Step 4 : Stop 5. Greatest among three numbers Step 2 : Read values of a, b and c Step
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 informationProcedural Programming & Fundamentals of Programming
& Fundamentals of Programming Exercise 4 (SS 2018) 12.06.2018 What will I learn in the 5. exercise Files Math functions Dynamic data structures (linked Lists) Exercise(s) 1 Files A file can be seen as
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 informationAssignment 6. Q1. Create a database of students using structures, where in each entry of the database will have the following fields:
Assignment 6 Q1. Create a database of students using structures, where in each entry of the database will have the following fields: 1. a name, which is a string with at most 128 characters 2. their marks
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 informationQuestions Bank. 14) State any four advantages of using flow-chart
Questions Bank Sub:PIC(22228) Course Code:-EJ-2I ----------------------------------------------------------------------------------------------- Chapter:-1 (Overview of C Programming)(10 Marks) 1) State
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 informationChapter 8. Arrays, Addresses, and Pointers : Structured Programming Structured Programming 1
Chapter 8 Arrays, Addresses, and Pointers 204112: Structured Programming 204112 Structured Programming 1 Pointer Pointer is a variable that contains an address. If num_ptr is a pointer, *num_ptr means
More informationClassification s of Data Structures
Linear Data Structures using Sequential organization Classification s of Data Structures Types of Data Structures Arrays Declaration of arrays type arrayname [ arraysize ]; Ex-double balance[10]; Arrays
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 informationSample Paper - II Subject Computer Science
Sample Paper - II Subject Computer Science Max Marks 70 Duration 3 hrs Note:- All questions are compulsory Q1) a) What is significance of My Computer? 2 b) Explain different types of operating systems.
More informationCSE101-Lec#18. Multidimensional Arrays Application of arrays. Created By: Amanpreet Kaur & Sanjeev Kumar SME (CSE) LPU. LPU CSE101 C Programming
CSE101-Lec#18 Multidimensional Arrays Application of arrays Created By: Amanpreet Kaur & Sanjeev Kumar SME (CSE) LPU Outline Defining and processing 1D array 2D array Applications of arrays 1-D array A
More informationProgramming & Data Structure Laboratory. Arrays, pointers and recursion Day 5, August 5, 2014
Programming & Data Structure Laboratory rrays, pointers and recursion Day 5, ugust 5, 2014 Pointers and Multidimensional rray Function and Recursion Counting function calls in Fibonacci #include
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 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 informationI YEAR II SEMESTER COMPUTER SCIENCE PROGRAMMING IN C
I YEAR II SEMESTER COMPUTER SCIENCE 3-2-108 UNIT I PROGRAMMING IN C Introduction to C: Introduction Structure of C Program Writing the first C Program File used in C Program Compiling and Executing C Programs
More informationDeveloped By: P.Venkateshwarlu, Alphores Womens Degree College, Karimnagar
B.Sc (Computer Science) 1 sem Practical Solutions 1.Program to find biggest in 3 numbers using conditional operators. # include # include int a, b, c, big ; printf("enter three numbers
More informationUNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING
UNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING APS 105 Computer Fundamentals Final Examination December 16, 2013 2:00 p.m. 4:30 p.m. (150 minutes) Examiners: J. Anderson, B. Korst, J.
More information(2½ Hours) [Total Marks: 75
(2½ Hours) [Total Marks: 75 N. B.: (1) All questions are compulsory. (2) Make suitable assumptions wherever necessary and state the assumptions made. (3) Answers to the same question must be written together.
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 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 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 informationRecursion. Data and File Structures Laboratory. DFS Lab (ISI) Recursion 1 / 20
Recursion Data and File Structures Laboratory http://www.isical.ac.in/~dfslab/2018/index.html DFS Lab (ISI) Recursion 1 / 20 Function calls 1 void main(void) 2 {... 3 u = f(x, y*z); 4... 5 } 6 7 int f(int
More informationLOOPS. 1- Write a program that prompts user to enter an integer N and determines and prints the sum of cubes from 5 to N (i.e. sum of 5 3 to N 3 ).
LOOPS 1- Write a program that prompts user to enter an integer N and determines and prints the sum of cubes from 5 to N (i.e. sum of 5 3 to N 3 ). 2-Give the result of the following program: #include
More informationFundamental of Programming (C)
Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 9 Pointer Department of Computer Engineering 1/46 Outline Defining and using Pointers
More informationTribhuvan University Institute of Science and Technology 2065
1CSc.102-2065 2065 Candidates are required to give their answers in their own words as for as practicable. 1. Draw the flow chart for finding largest of three numbers and write an algorithm and explain
More information1. FIBONACCI SERIES. Write a C++ program to generate the Fibonacci for n terms. To write a C++ program to generate the Fibonacci for n terms.
PROBLEM: 1. FIBONACCI SERIES Write a C++ program to generate the Fibonacci for n terms. AIM: To write a C++ program to generate the Fibonacci for n terms. PROGRAM CODING: #include #include
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 informationUnited States Naval Academy Electrical and Computer Engineering Department EC310-6 Week Midterm Spring AY2017
United States Naval Academy Electrical and Computer Engineering Department EC310-6 Week Midterm Spring AY2017 1. Do a page check: you should have 8 pages including this cover sheet. 2. You have 50 minutes
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 informationPESIT Bangalore South Campus Hosur road, 1km before ElectronicCity, Bengaluru -100 Department of Basic Science and Humanities
INTERNAL ASSESSMENT TEST-3 Date : 12-05-2016 Marks: 40 Subject & Code : Programming in C and data structures (15PCD23) Sec : F,G,H,I,J,K Name of faculty :Dr J Surya Prasad/Mr.Sreenath M V/Ms.Monika/ Time
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 informationRecursion. Data and File Structures Laboratory. DFS Lab (ISI) Recursion 1 / 27
Recursion Data and File Structures Laboratory http://www.isical.ac.in/~dfslab/2017/index.html DFS Lab (ISI) Recursion 1 / 27 Definition A recursive function is a function that calls itself. The task should
More informationE.G.S PILLAY ENGINEERING COLLEGE, NAGAPATTINAM DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 17GEX51 - PROGRAMMING IN C LABORATARY MANUAL
E.G.S PILLAY ENGINEERING COLLEGE, NAGAPATTINAM DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING (Approved by AICTE, Affiliated to Anna University) (Accredited by NBA CSE/EEE/MECH) (Accredited by NAAC with
More informationVALLIAMMAI ENGINEERING COLLEGE SRM NAGAR, KATTANGULATHUR
VALLIAMMAI ENGINEERING COLLEGE SRM NAGAR, KATTANGULATHUR 603 203 FIRST SEMESTER B.E / B.Tech., (Common to all Branches) QUESTION BANK - GE 6151 COMPUTER PROGRAMMING UNIT I - INTRODUCTION Generation and
More information7.STRINGS. Data Structure Management (330701) 1
Strings and their representation String is defined as a sequence of characters. 7.STRINGS In terms of c language string is an array of characters. While storing the string in character array the size of
More informationDHANALAKSHMI SRINIVASAN INSTITUTE OF RESEARCH AND TECHNOLOGY SIRUVACHUR, PERAMBALUR
DHANALAKSHMI SRINIVASAN INSTITUTE OF RESEARCH AND TECHNOLOGY SIRUVACHUR, PERAMBALUR 621 113 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING B.E SECOND SEMESTER CS 6202 PROGRAMMING AND DATA STRUCTURES I
More informationPROGRAMMING IN C AND C++:
PROGRAMMING IN C AND C++: Week 1 1. Introductions 2. Using Dos commands, make a directory: C:\users\YearOfJoining\Sectionx\USERNAME\CS101 3. Getting started with Visual C++. 4. Write a program to print
More informationMultiple Choice Questions ( 1 mark)
Multiple Choice Questions ( 1 mark) Unit-1 1. is a step by step approach to solve any problem.. a) Process b) Programming Language c) Algorithm d) Compiler 2. The process of walking through a program s
More informationStructured programming. Exercises 3
Exercises 3 Table of Contents 1. Reminder from lectures...................................................... 1 1.1. Relational operators..................................................... 1 1.2. Logical
More informationComputer programming UNIT IV UNIT IV. GPCET,Dept of CSE, P Kiran Rao
UNIT IV COMMAND LINE ARGUMENTS Computer programming UNIT IV It is possible to pass some values from the command line to C programs when they are executed. These values are called command line arguments
More informationMODULE V: POINTERS & PREPROCESSORS
MODULE V: POINTERS & PREPROCESSORS INTRODUCTION As you know, every variable is a memory-location and every memory-location has its address defined which can be accessed using ampersand(&) operator, which
More informationSyntax of for loop is as follows: for (inite; terme; updatee) { block of statements executed if terme is true;
Birla Institute of Technology & Science, Pilani Computer Programming (CSF111) Lab-5 ---------------------------------------------------------------------------------------------------------------------------------------------
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)
WINTER 17 EXAMINATION Subject Name: Data Structure Using C Model Answer Subject Code: 17330 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as
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 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 information4(a) ADDITION OF TWO NUMBERS. Program:
4(a) ADDITION OF TWO NUMBERS int a,b,c: printf( enter the elements a and b ); scanf( %d%d,&a,&b); c=a+b; printf( sum of the elements is%d,c); Output: Enter the elements a and b: 4 5 Sum of the elements
More informationComputer Programming Unit v
READING AND WRITING CHARACTERS We can read and write a character on screen using printf() and scanf() function but this is not applicable in all situations. In C programming language some function are
More information