WAP 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

Size: px
Start display at page:

Download "WAP 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"

Transcription

1 Contents 1. WAP to accept the value from the user and exchange the values WAP to check whether the number is even or odd WAP to Check Odd or Even Using Conditional Operator WAP to Check Whether a Number is Positive or Negative WAP check if a Number is Positive or Negative Using Nested if WAP to Check Leap Year WAP to check whether the given integer is a Palindrome WAP to find the Largest number among Three Numbers WAP using switch case to perform addition multiplication subtraction and division operation WAP to print multiplication table WAP to count number of digits in an integer WAP to count the number of vowels, consonants WAP to print fibonacci sequence WAP to print factors of a positive integer WAP to Find Factorial of a Number WAP to make a pyramid with numbers increased by 1. The pattern is as follows : WAP to accept the string from the user and print it WAP to compare two strings WAP to display largest element of an array WAP to add two matrix using multi-dimensional arrays WAP to multiply to matrix using multi-dimensional arrays WAP to find transpose of a matrix WAP to accept two Strings & Compare them WAP to find the Fibonacci number using recursion Anuradha Bhatia 1

2 1. WAP to accept the value from the user and exchange the values. int num1, num2, temp; printf("enter first number: "); scanf("%d", &num1); printf("enter second number: "); scanf("%d",&num2); temp = num1; num1 = num2; num2 = temp; printf("\nafter swapping, firstnumber = %d\n", num1); printf("after swapping, secondnumber = %d", num2); 2. WAP to check whether the number is even or odd. int number; printf("enter an integer: "); scanf("%d", &number); // True if the number is perfectly divisible by 2 if(number % 2 == 0) printf("%d is even.", number); printf("%d is odd.", number); Anuradha Bhatia 2

3 3. WAP to Check Odd or Even Using Conditional Operator int number; printf("enter an integer: "); scanf("%d", &number); (number % 2 == 0)? printf("%d is even.", number) : printf("%d is odd.", number); 4. WAP to Check Whether a Number is Positive or Negative int number; printf("enter a number: "); scanf("%d", &number); if (number <= 0) if (number == 0) printf("you entered 0."); printf("you entered a negative number."); printf("you entered a positive number."); Anuradha Bhatia 3

4 5. WAP check if a Number is Positive or Negative Using Nested if... int number; printf("enter a number: "); scanf("%d", &number); if (number < 0) printf("you entered a negative number."); if ( number > 0) printf("you entered a positive number."); printf("you entered 0."); 6. WAP to Check Leap Year int year; printf("enter a year: "); scanf("%d",&year); if(year%4 == 0) if( year%100 == 0) if ( year%400 == 0) printf("%d is a leap year.", year); printf("%d is not a leap year.", year); printf("%d is a leap year.", year ); Anuradha Bhatia 4

5 printf("%d is not a leap year.", year); 7. WAP to check whether the given integer is a Palindrome int n, rev = 0, rem, num; printf("enter an integer: "); scanf("%d", &n); num = n; while( n!=0 ) rem = n%10; rev = rev*10 + rem; n /= 10; if (num == rev) printf("%d is a palindrome.", num); printf("%d is not a palindrome.", num); 8. WAP to find the Largest number among Three Numbers int n1, n2, n3; printf("enter three different numbers: "); scanf("%d %d %d", &n1, &n2, &n3); if( n1>=n2 && n1>=n3 ) printf("%d is the largest number.", n1); Anuradha Bhatia 5

6 if( n2>=n1 && n2>=n3 ) printf("%d is the largest number.", n2); if( n3>=n1 && n3>=n2 ) printf("%d is the largest number.", n3); 9. WAP using switch case to perform addition multiplication subtraction and division operation #include<stdio.h> #include<conio.h> int choice, a, b; int sum, div, mul, sub; char c= 'y'; while(c=='y') printf("\naddition -> 1\nSubtraction -> 2 \nmultiplication -> 3 \ndivision -> 4\n"); printf("\aenter your choice of operation to perform -: \n"); scanf("%d",& choice); printf("\a\nenter two number :- \n"); scanf("%d%d",&a,&b); switch(choice) case 1: sum = a + b; printf("\a\n Sum = %d", sum); break; case 2: sub = a - b; printf("\a\n Difference = %d", sub); break; case 3: mul = a * b; printf("\a\n Multiplication = %d", mul); break; case 4: div = a - b; Anuradha Bhatia 6

7 printf("\a\n Division = %d", div); break; default : printf("\awrong CHOICE"); printf("\ndo you want to continue [y / n]"); c=getch(); getch(); 10. WAP to print multiplication table. int n, i; printf("enter an integer: "); scanf("%d",&n); for(i=1; i<=10; ++i) printf("%d * %d = %d \n", n, i, n*i); 11. WAP to count number of digits in an integer long long n; int count = 0; printf("enter an integer: "); scanf("%lld", &n); while(n!= 0) // n = n/10 ++count; Anuradha Bhatia 7

8 printf("number of digits: %d", count); 12. WAP to count the number of vowels, consonants. char line[150]; int i, vowels, consonants, digits, spaces; vowels = consonants = digits = spaces = 0; printf("enter a line of string: "); scanf("%[^\n]", line); for(i=0; line[i]!='\0'; ++i) if(line[i]=='a' line[i]=='e' line[i]=='i' line[i]=='o' line[i]=='u' line[i]=='a' line[i]=='e' line[i]=='i' line[i]=='o' line[i]=='u') ++vowels; if((line[i]>='a'&& line[i]<='z') (line[i]>='a'&& line[i]<='z')) ++consonants; if(line[i]>='0' && line[i]<='9') ++digits; if (line[i]==' ') ++spaces; printf("vowels: %d",vowels); Anuradha Bhatia 8

9 printf("\nconsonants: %d",consonants); printf("\ndigits: %d",digits); printf("\nwhite spaces: %d", spaces); 13. WAP to print fibonacci sequence int i, n, t1 = 0, t2 = 1, nextterm; printf("enter the number of terms: "); scanf("%d", &n); printf("fibonacci Series: "); for (i = 1; i <= n; ++i) printf("%d, ", t1); nextterm = t1 + t2; t1 = t2; t2 = nextterm; 14. WAP to print factors of a positive integer int number, i; printf("enter a positive integer: "); scanf("%d",&number); printf("factors of %d are: ", number); for(i=1; i <= number; ++i) if (number%i == 0) Anuradha Bhatia 9

10 printf("%d ",i); 15. WAP to Find Factorial of a Number int n, i; unsigned long long factorial = 1; printf("enter an integer: "); scanf("%d",&n); // show error if the user enters a negative integer if (n < 0) printf("error! Factorial of a negative number doesn't exist."); for(i=1; i<=n; ++i) factorial *= i; // factorial = factorial*i; printf("factorial of %d = %llu", n, factorial); Anuradha Bhatia 10

11 16. WAP to make a pyramid with numbers increased by 1. The pattern is as follows : void main() int i,j,gap, rows, k,t=1; printf("input number of rows : "); scanf("%d",&rows); gap=rows+ 4-1; for(i=1;i<=rows; i++) for(k= gap;k>=1;k--) printf(" "); for(j=1;j<=i;j++) printf("%d ",t++); printf("\n"); gap--; Anuradha Bhatia 11

12 17. WAP to accept the string from the user and print it. char array[100]; printf("enter a string\n"); scanf("%s", array); printf("you entered the string %s\n",array); 18. WAP to compare two strings. #include <string.h> char a[100], b[100]; printf("enter the first string\n"); gets(a); printf("enter the second string\n"); gets(b); if (strcmp(a,b) == 0) printf("entered strings are equal.\n"); printf("entered strings are not equal.\n"); Anuradha Bhatia 12

13 19. WAP to display largest element of an array int i, n; float arr[100]; printf("enter total number of elements(1 to 100): "); scanf("%d", &n); printf("\n"); // Stores number entered by the user for(i = 0; i < n; ++i) printf("enter Number %d: ", i+1); scanf("%f", &arr[i]); // Loop to store largest number to arr[0] for(i = 1; i < n; ++i) // Change < to > if you want to find the smallest element if(arr[0] < arr[i]) arr[0] = arr[i]; printf("largest element = %.2f", arr[0]); 20. WAP to add two matrix using multi-dimensional arrays. int r, c, a[100][100], b[100][100], sum[100][100], i, j; printf("enter number of rows (between 1 and 100): "); scanf("%d", &r); printf("enter number of columns (between 1 and 100): "); scanf("%d", &c); printf("\nenter elements of 1st matrix:\n"); for(i=0; i<r; ++i) Anuradha Bhatia 13

14 for(j=0; j<c; ++j) printf("enter element a%d%d: ",i+1,j+1); scanf("%d",&a[i][j]); printf("enter elements of 2nd 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", &b[i][j]); // Adding Two matrices for(i=0;i<r;++i) for(j=0;j<c;++j) sum[i][j]=a[i][j]+b[i][j]; // Displaying the result printf("\nsum of two matrix is: \n\n"); for(i=0;i<r;++i) for(j=0;j<c;++j) printf("%d ",sum[i][j]); if(j==c-1) printf("\n\n"); Anuradha Bhatia 14

15 21. WAP to multiply to matrix using multi-dimensional arrays. int a[10][10], b[10][10], result[10][10], r1, c1, r2, c2, i, j, k; printf("enter rows and column for first matrix: "); scanf("%d %d", &r1, &c1); printf("enter rows and column for second matrix: "); scanf("%d %d",&r2, &c2); // Column of first matrix should be equal to column of second matrix and while (c1!= r2) printf("error! column of first matrix not equal to row of second.\n\n"); printf("enter rows and column for first matrix: "); scanf("%d %d", &r1, &c1); printf("enter rows and column for second matrix: "); scanf("%d %d",&r2, &c2); // Storing elements of first matrix. printf("\nenter elements of matrix 1:\n"); for(i=0; i<r1; ++i) for(j=0; j<c1; ++j) printf("enter elements a%d%d: ",i+1, j+1); scanf("%d", &a[i][j]); // Storing elements of second matrix. printf("\nenter elements of matrix 2:\n"); for(i=0; i<r2; ++i) for(j=0; j<c2; ++j) printf("enter elements b%d%d: ",i+1, j+1); scanf("%d",&b[i][j]); // Initializing all elements of result matrix to 0 for(i=0; i<r1; ++i) for(j=0; j<c2; ++j) Anuradha Bhatia 15

16 result[i][j] = 0; // Multiplying matrices a and b and // storing result in result matrix for(i=0; i<r1; ++i) for(j=0; j<c2; ++j) for(k=0; k<c1; ++k) result[i][j]+=a[i][k]*b[k][j]; // Displaying the result printf("\noutput Matrix:\n"); for(i=0; i<r1; ++i) for(j=0; j<c2; ++j) printf("%d ", result[i][j]); if(j == c2-1) printf("\n\n"); 22. WAP to find transpose of a matrix 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); Anuradha Bhatia 16

17 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"); 23. WAP to accept two Strings & Compare them. void main() int count1 = 0, count2 = 0, flag = 0, i; char string1[10], string2[10]; Anuradha Bhatia 17

18 printf("enter a string:"); gets(string1); printf("enter another string:"); gets(string2); /* Count the number of characters in string1 */ while (string1[count1]!= '\0') count1++; /* Count the number of characters in string2 */ while (string2[count2]!= '\0') count2++; i = 0; while ((i < count1) && (i < count2)) if (string1[i] == string2[i]) i++; continue; if (string1[i] < string2[i]) flag = -1; break; if (string1[i] > string2[i]) flag = 1; break; if (flag == 0) printf("both strings are equal \n"); if (flag == 1) printf("string1 is greater than string2 \n", string1, string2); if (flag == -1) printf("string1 is less than string2 \n", string1, string2); Anuradha Bhatia 18

19 24. WAP to find the Fibonacci number using recursion. int fibo(int); int num; int result; printf("enter the nth number in fibonacci series: "); scanf("%d", &num); if (num < 0) printf("fibonacci of negative number is not possible.\n"); result = fibo(num); printf("the %d number in fibonacci series is %d\n", num, result); int fibo(int num) if (num == 0) if (num == 1) return 1; return(fibo(num - 1) + fibo(num - 2)); Anuradha Bhatia 19

BCSE1002: Computer Programming and Problem Solving LAB MANUAL

BCSE1002: 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 information

PROGRAMMING IN C LAB MANUAL FOR DIPLOMA IN ECE/EEE

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 information

'C' Programming Language

'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 information

APS105. Collecting Elements 10/20/2013. Declaring an Array in C. How to collect elements of the same type? Arrays. General form: Example:

APS105. 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 information

Programming in C Lab

Programming 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

Subject: PIC Chapter 2.

Subject: 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 information

List of Programs: Programs: 1. Polynomial addition

List 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 information

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) MODEL ANSWER

MAHARASHTRA 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 information

1. 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 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 information

Government Polytechnic Muzaffarpur.

Government 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 information

PESIT Bangalore South Campus Hosur Road (1km before Electronic City), Bengaluru Department of Basic Science and Humanities

PESIT Bangalore South Campus Hosur Road (1km before Electronic City), Bengaluru Department of Basic Science and Humanities SOLUTION OF CONTINUOUS INTERNAL EVALUATION TEST -1 Date : 27-02 2018 Marks:60 Subject & Code : Programming in C and Data Structures- 17PCD23 Name of faculty : Dr. J Surya Prasad/Mr. Naushad Basha Saudagar

More information

/* Area and circumference of a circle */ /*celsius to fahrenheit*/

/* 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 information

Branching is deciding what actions to take and Looping is deciding how many times to take a certain action.

Branching 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 information

Programming and Data Structures Mid-Semester - Solutions to Sample Questions Dept. of Computer Science and Engg. IIT Kharagpur Spring

Programming 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 information

Arrays. Arrays are of 3 types One dimensional array Two dimensional array Multidimensional array

Arrays. 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 information

Programming & Data Structure Laboratory. Day 2, July 24, 2014

Programming & 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 information

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.

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. 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 information

Question Bank (SPA SEM II)

Question 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 information

Programming & Data Structure Laboratory. Arrays, pointers and recursion Day 5, August 5, 2014

Programming & 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 information

Q 1. Attempt any TEN of the following:

Q 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 information

Structured Programming Approach

Structured 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 information

Questions Bank. 14) State any four advantages of using flow-chart

Questions 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

PESIT 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 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 information

F.E. Sem. II. Structured Programming Approach

F.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 information

Unit 5. Decision Making and Looping. School of Science and Technology INTRODUCTION

Unit 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 information

Structured programming

Structured programming Exercises 6 Version 1.0, 25 October, 2016 Table of Contents 1. Arrays []................................................................... 1 1.1. Declaring arrays.........................................................

More information

F.E. Sem. II. Structured Programming Approach

F.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

FUNCTIONS OMPAL SINGH

FUNCTIONS OMPAL SINGH FUNCTIONS 1 INTRODUCTION C enables its programmers to break up a program into segments commonly known as functions, each of which can be written more or less independently of the others. Every function

More information

I YEAR II SEMESTER COMPUTER SCIENCE PROGRAMMING IN C

I 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 information

THE 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 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 information

UNIT III ARRAYS AND STRINGS

UNIT 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 information

Programming and Data Structures

Programming 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 information

Write a C program using arrays and structure

Write 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 information

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION

MAHARASHTRA 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 information

Computer Programming Unit 3

Computer 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

Subject: Fundamental of Computer Programming 2068

Subject: 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 information

Computers Programming Course 12. Iulian Năstac

Computers 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 information

F.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 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 information

only in the space provided. Do the rough work in the space provided for it. The question paper has total 12 pages.

only 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

MA 511: Computer Programming Lecture 2: Partha Sarathi Mandal

MA 511: Computer Programming Lecture 2: Partha Sarathi Mandal MA 511: Computer Programming Lecture 2: 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 Largest

More information

Contents ARRAYS. Introduction:

Contents ARRAYS. Introduction: UNIT-III ARRAYS AND STRINGS Contents Single and Multidimensional Arrays: Array Declaration and Initialization of arrays Arrays as function arguments. Strings: Initialization and String handling functions.

More information

Computer Programming. C Array is a collection of data belongings to the same data type. data_type array_name[array_size];

Computer 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 information

F.E. Sem - 2 CBCGS SPA MAY 17

F.E. Sem - 2 CBCGS SPA MAY 17 F.E. Sem 2 CBCGS SPA MAY 17 Q.1.a.) Convert 0010 0100 0010 1101 from base 2 to decimal. Convert 134 from base 10 to hexadecimal. Write steps for conversion. Ans: Binary to decimal: The steps to be followed

More information

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)

MAHARASHTRA 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 information

Introduction to Computing Lecture 07: Repetition and Loop Statements (Part II)

Introduction 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 information

Unit 1 - Arrays. 1 What is an array? Explain with Example. What are the advantages of using an array?

Unit 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 information

P.E.S. INSTITUTE OF TECHNOLOGY BANGALORE SOUTH CAMPUS DEPARTMENT OF SCIENCE AND HUMANITIES EVEN SEMESTER FEB 2017

P.E.S. INSTITUTE OF TECHNOLOGY BANGALORE SOUTH CAMPUS DEPARTMENT OF SCIENCE AND HUMANITIES EVEN SEMESTER FEB 2017 P.E.S. INSTITUTE OF TECHNOLOGY BANGALORE SOUTH CAMPUS DEPARTMENT OF SCIENCE AND HUMANITIES ST INTERNAL ASSESMENT TEST (SCEME AND SOLUTIONS) EVEN SEMESTER FEB 07 FACULTY: Dr.J Surya Prasad/Ms. Saritha/Mr.

More information

DRONACHARYA 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. 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 information

Worksheet 11 Multi Dimensional Array and String

Worksheet 11 Multi Dimensional Array and String Name: Student ID: Date: Worksheet 11 Multi Dimensional Array and String Objectives After completing this worksheet, you should be able to Declare multi dimensional array of elements and string variables

More information

MAHALAKSHMI ENGINEERING COLLEGE B TIRUCHIRAPALLI

MAHALAKSHMI 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 information

Preview from Notesale.co.uk Page 4 of 63

Preview from Notesale.co.uk Page 4 of 63 1. Write a program to compute area of a circle after reading input from user. #include #include int float area, radius, pi=3.141; printf("enter the radius of circle \t"); scanf("%f",

More information

Decision Making and Branching

Decision Making and Branching INTRODUCTION Decision Making and Branching Unit 4 In the previous lessons we have learned about the programming structure, data types, declaration of variables, tokens, constants, keywords and operators

More information

Functions. Arash Rafiey. September 26, 2017

Functions. Arash Rafiey. September 26, 2017 September 26, 2017 are the basic building blocks of a C program. are the basic building blocks of a C program. A function can be defined as a set of instructions to perform a specific task. are the basic

More information

Classification s of Data Structures

Classification 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 information

MTH 307/417/515 Final Exam Solutions

MTH 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 information

CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-0-0)

CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-0-0) CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-0-0) Class Teacher: Pralay Mitra Department of Computer Science and Engineering Indian Institute of Technology Kharagpur Conceptual Idea

More information

Lab Manual B.Tech 1 st Year

Lab 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 information

Sorting & Searching. Hours: 10. Marks: 16

Sorting & Searching. Hours: 10. Marks: 16 Sorting & Searching CONTENTS 2.1 Sorting Techniques 1. Introduction 2. Selection sort 3. Insertion sort 4. Bubble sort 5. Merge sort 6. Radix sort ( Only algorithm ) 7. Shell sort ( Only algorithm ) 8.

More information

4(a) ADDITION OF TWO NUMBERS. Program:

4(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 information

Principles of C and Memory Management

Principles of C and Memory Management COMP281 Lecture 8 Principles of C and Memory Management Dr Lei Shi Last Lecture Pointer Basics Previous Lectures Arrays, Arithmetic, Functions Last Lecture Pointer Basics Previous Lectures Arrays, Arithmetic,

More information

What is recursion. WAP to find sum of n natural numbers using recursion (5)

What 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 information

MODULE 2: Branching and Looping

MODULE 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 information

Chapter 8. Arrays, Addresses, and Pointers : Structured Programming Structured Programming 1

Chapter 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 information

16.216: ECE Application Programming Fall 2011

16.216: ECE Application Programming Fall 2011 16.216: ECE Application Programming Fall 2011 Exam 1 Solution 1. (24 points, 6 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling

More information

To store the total marks of 100 students an array will be declared as follows,

To 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 information

Lecture 10: Recursive Functions. Computer System and programming in C 1

Lecture 10: Recursive Functions. Computer System and programming in C 1 Lecture 10: Recursive Functions Computer System and programming in C 1 Outline Introducing Recursive Functions Format of recursive Functions Tracing Recursive Functions Examples Tracing using Recursive

More information

Tribhuvan University Institute of Science and Technology 2065

Tribhuvan 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 information

Unit 3 Decision making, Looping and Arrays

Unit 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 information

Imperative Programming

Imperative Programming F.Y. B.Sc.(IT) : Sem. I Imperative Programming Time : 2½ Hrs.] Prelim Question Paper Solution [Marks : 75 Q.1 Attempt the following (any THREE) [15] Q.1(a) List various techniques for the development of

More information

Vidyalankar F.Y. Diploma : Sem. II [CD/CM/CO/CW/DE/ED/EE/EI/EJ/EN/EP/ET/EV/EX/IC/IE/IF/IS/IU/MU] Programming in C

Vidyalankar F.Y. Diploma : Sem. II [CD/CM/CO/CW/DE/ED/EE/EI/EJ/EN/EP/ET/EV/EX/IC/IE/IF/IS/IU/MU] Programming in C F.Y. Diploma : Sem. II [CD/CM/CO/CW/DE/ED/EE/EI/EJ/EN/EP/ET/EV/EX/IC/IE/IF/IS/IU/MU] Programming in C Time : 3 Hrs.] Prelim Question Paper Solution [Marks : 100 Q.1 Attempt any TEN of the following : [20]

More information

MA 511: Computer Programming Lecture 3: Partha Sarathi Mandal

MA 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 information

P.E.S. INSTITUTE OF TECHNOLOGY BANGALORE SOUTH CAMPUS 1 ST INTERNAL ASSESMENT TEST (SCEME AND SOLUTIONS)

P.E.S. INSTITUTE OF TECHNOLOGY BANGALORE SOUTH CAMPUS 1 ST INTERNAL ASSESMENT TEST (SCEME AND SOLUTIONS) FACULTY: Ms. Saritha P.E.S. INSTITUTE OF TECHNOLOGY BANGALORE SOUTH CAMPUS 1 ST INTERNAL ASSESMENT TEST (SCEME AND SOLUTIONS) SUBJECT / CODE: Programming in C and Data Structures- 15PCD13 What is token?

More information

{C} Programming. Part 1/2 Basics Variables, Conditions, Loops, Arrays, Pointer basics

{C} Programming. Part 1/2 Basics Variables, Conditions, Loops, Arrays, Pointer basics {C Programming Part 1/2 Basics Variables, Conditions, Loops, Arrays, Pointer basics Variables A variable is a container (storage area) to hold data. Eg. Variable name int potionstrength = 95; Variable

More information

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) 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 information

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University ITC213: STRUCTURED PROGRAMMING Bhaskar Shrestha National College of Computer Studies Tribhuvan University Lecture 10: Arrays Readings: Chapter 9 Introduction Group of same type of variables that have same

More information

C Programming Lecture V

C Programming Lecture V C Programming Lecture V Instructor Özgür ZEYDAN http://cevre.beun.edu.tr/ Modular Programming A function in C is a small sub-program that performs a particular task, and supports the concept of modular

More information

1. Write a C program that receives 10 float numbers from the console and sort them in nonascending order, and prints the result

1. 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 information

SUMMER 13 EXAMINATION Model Answer

SUMMER 13 EXAMINATION 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 information

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University ITC213: STRUCTURED PROGRAMMING Bhaskar Shrestha National College of Computer Studies Tribhuvan University Lecture 08: Control Statements Readings: Chapter 6 Control Statements and Their Types A control

More information

C Program Reviews 2-12

C 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 information

INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator

INDIAN 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 information

7.STRINGS. Data Structure Management (330701) 1

7.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 information

Syntax of for loop is as follows: for (inite; terme; updatee) { block of statements executed if terme is true;

Syntax 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 information

PROGRAMMING IN C AND C++:

PROGRAMMING 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 information

SRI 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 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 information

Arrays in C. By Mrs. Manisha Kuveskar.

Arrays 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 information

Test 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 information

Fundamental of Programming (C)

Fundamental 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 information

B. V. Patel Institute of Business Management, Computer & Information Technology, UTU 2013

B. V. Patel Institute of Business Management, Computer & Information Technology, UTU 2013 Information Technology, UTU 203 030000 Fundamentals of Programming Problems to be solved in laboratory Note: Journal should contain followings for all problems given below:. Problem Statement 2. Algorithm

More information

B.L.D.E.A s Vachana Pitamaha Dr. P. G. Halakatti College of Engineering and Technology, Vijayapur

B.L.D.E.A s Vachana Pitamaha Dr. P. G. Halakatti College of Engineering and Technology, Vijayapur B.L.D.E.A s Vachana Pitamaha Dr. P. G. Halakatti College of Engineering and Technology, Vijayapur-586103. Department of Computer Science and Engineering Lab Manual Subject : Computer Programming Laboratory

More information

CSE101-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. 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 information

Programming Language A

Programming Language A Programming Language A Takako Nemoto (JAIST) 30 October Takako Nemoto (JAIST) 30 October 1 / 29 From Homework 3 Homework 3 1 Write a program to convert the input Celsius degree temperature into Fahrenheight

More information

More Recursive Programming

More 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 information

INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator

INDIAN 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 information

Module 4: Decision-making and forming loops

Module 4: Decision-making and forming loops 1 Module 4: Decision-making and forming loops 1. Introduction 2. Decision making 2.1. Simple if statement 2.2. The if else Statement 2.3. Nested if Statement 3. The switch case 4. Forming loops 4.1. The

More information

Functions. P. S. Suryateja startertutorials.com [short domain - stuts.me] 2

Functions. P. S. Suryateja startertutorials.com [short domain - stuts.me] 2 UNIT - 3 FUNCTIONS Functions Until now, in all the C programs that we have written, the program consists of a main function and inside that we are writing the logic of the program. The disadvantage of

More information

LABORATORY MANUAL. (CSE-103F) FCPC Lab

LABORATORY 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 information

UNIVERSITY OF WINDSOR Fall 2007 QUIZ # 2 Solution. Examiner : Ritu Chaturvedi Dated :November 27th, Student Name: Student Number:

UNIVERSITY OF WINDSOR Fall 2007 QUIZ # 2 Solution. Examiner : Ritu Chaturvedi Dated :November 27th, Student Name: Student Number: UNIVERSITY OF WINDSOR 60-106-01 Fall 2007 QUIZ # 2 Solution Examiner : Ritu Chaturvedi Dated :November 27th, 2007. Student Name: Student Number: INSTRUCTIONS (Please Read Carefully) No calculators allowed.

More information

Prepared by: Shraddha Modi

Prepared 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

Lecture 6. Statements

Lecture 6. Statements Lecture 6 Statements 1 Statements This chapter introduces the various forms of C++ statements for composing programs You will learn about Expressions Composed instructions Decision instructions Loop instructions

More information