SlideShare a Scribd company logo
Lab Assignment 3: Array and Structures: C Programming
CS-153 Computer Programming Lab
Autumn Semester, 2016, IIT Indore
Date: 17-08-16
Note: Write following programs in C language. Also note that this assignment will be evaluated by
TA’s in the upcoming labs of next week (22-08-16 onward) for each batch.
1. Write a program to compute the frequencies of all distinct numbers that appear in the array of size N.
Read N and the actual numbers in the array from the keyboard before you compute the frequency.
2. Write a program to display Pascal's triangle. Pascal's triangle represents the binomial coefficients*. The
first few rows of Pascal's triangle are displayed below. Observe how a row is related to the row above
it.
Extra Point: How many arrays did you use? Try solving the problem with just one array.
* Example of binomial coefficient for 6th
row is (x + y)5
= 1 x5
+ 5 x4
y + 10 x3
y2
+ 10 x2
y3
+ 5 x y4
+ 1 y5
3. Write a program to produce the following output:
A B C D E F G F E D C B A
A B C D E F F E D C B A
A B C D E E D C B A
A B C D D C B A
A B C C B A
A B B A
A A
4. Create a structure to specify data on students given below: Roll number, Name, Department, Course,
Year of joining Assume that there are not more than 450 students in the institute.
5. Create a structure to specify data of customers in a bank. The data to be stored is: Account number,
Name, Balance in account. Assume maximum of 200 customers in the bank.
#include<stdio.h>
#include<conio.h>
int main(){
int n, t, i, j, arr[30],len, halflen,flag=0,count=0;
printf("Enter number of elements to insert in an array:n");
scanf("%d",&len);
printf("Enter elements to insert in an array:n");
for(i=0;i<len;i++){
scanf("%d",&t);
arr[i]=t;
}
printf("n");
/*****************************/
for(i=0;i<len;i++){ //loop for pass 1 to len
count=1; //again initialize the count variable with 1
for(j=i+1;j<=len-1;j++){
if(arr[i]==arr[j] && arr[i]!='0'){ //if same value of arr[i] find at index 'j' and it is
not null then
count++; //increment the count of frequency for the value
arr[j]='0'; //store null value to arr[j]
}
}
if(arr[i]!='0'){ //if value of arr[i] is not null then
printf("%d is %d times.n",arr[i],count); //print the value if arr[i] and it frequency
count
}
}
/*****************************/
getch();
return 0;
}
#include<stdio.h>
#include<conio.h>
int main()
{
int array[10][10];
int i, j, k, rows;
printf("Enter the number of rowsn");
scanf("%d",&rows);
for(i=1; i<=rows; i++) //create array of size rows
{
for(j=1; j<=i; j++) //count of the values in a row will be same as the index 'i'
of the rows
{
if(j==1||j==i) //if it is first value of a row or count of the values in a row
matches with the row index 'i'
{
array[i][j]=1; //then store value 1 in array[i][j]
}
else
{
array[i][j]=array[i-1][i-j]+array[i-1][i-j+1]; //else sum the two values on
above row of
}
}
}
for(i=1; i<=rows; i++) //print array of size rows
{
for(k=1; k<=rows-i; k++) //adjust the spaces between printed values for the
index 1 to row-i
{
printf(" ");
}
for(j=1; j<=i; j++) //print values form the index 1 to i
{
printf("%d ",array[i][j]);
}
printf("n");
}
getch();
}
#include<stdio.h>
#include<conio.h>
main() {
int i,j,k,l;
for(i=71;i>=65;i--) {
/* loop for printing ascending letters */
for(j=65;j<=i;j++) {
printf("%c ",j);
}
/* loop for making a space between patterns */
for(k=i+1;k<=71;k++) {
if(k==71)
printf(" ");
if(k<71)
printf(" ");
}
/* loop to print descending letters */
for(l=i;l>=65;l--) {
if(l==71) { /* to skip printing 'G' twice */
continue;
}
printf("%c ",l);
}
printf("n");
}
getch();
return 0;
}
#include<stdio.h>
#include<conio.h>
#define N 450
struct students {
int rlnm;
char name[25];
char dept[25]; /* structure defined outside of main(); */
char course[25];
int year;
};
main() {
/* main() */
struct students s[N];
int i, ch;
/* taking input of 450 students in an array of structure */
for (i = 0; i < N; i++) {
printf(" Enter data of student %dtttttotal students: %dn", i + 1, N);
printf("****************************nn");
printf("enter rollnumber: ");
scanf("%d", & s[i].rlnm);
printf("nnenter name: ");
scanf(" %s", & s[i].name);
printf("nnenter department: ");
scanf("%s", & s[i].dept);
printf("nnenter course: ");
scanf("%s", & s[i].course);
printf("nnenter year of joining: ");
scanf("%d", & s[i].year);
}
getch();
}
#include<stdio.h>
#include<conio.h>
#define N 200
struct bank {
int acn;
char name[20];
int bal; /* defined out of main() */
};
void main() {
struct bank b[N];
int i, ch, lw = 100, ch2, ac, am;
for (i = 0; i < N; i++) {
/* inputting customer data */
printf("tEnter information of customers n");
printf("t******************************nn");
printf("enter account no.: ");
scanf("%d", & b[i].acn);
printf("nnenter customer name: ");
scanf("%s", & b[i].name);
printf("nnenter balance: ");
scanf("%d", & b[i].bal);
}
getch();
}

More Related Content

What's hot

Let us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solutionLet us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solution
rohit kumar
 
Bcsl 033 data and file structures lab s3-3
Bcsl 033 data and file structures lab s3-3Bcsl 033 data and file structures lab s3-3
Bcsl 033 data and file structures lab s3-3
Dr. Loganathan R
 
Expressions using operator in c
Expressions using operator in cExpressions using operator in c
Expressions using operator in c
Saranya saran
 
Bcsl 033 data and file structures lab s5-3
Bcsl 033 data and file structures lab s5-3Bcsl 033 data and file structures lab s5-3
Bcsl 033 data and file structures lab s5-3
Dr. Loganathan R
 
Let us C (by yashvant Kanetkar) chapter 3 Solution
Let us C   (by yashvant Kanetkar) chapter 3 SolutionLet us C   (by yashvant Kanetkar) chapter 3 Solution
Let us C (by yashvant Kanetkar) chapter 3 Solution
Hazrat Bilal
 
C-programs
C-programsC-programs
C-programs
SSGMCE SHEGAON
 
Bcsl 033 data and file structures lab s2-1
Bcsl 033 data and file structures lab s2-1Bcsl 033 data and file structures lab s2-1
Bcsl 033 data and file structures lab s2-1
Dr. Loganathan R
 
Xi CBSE Computer Science lab programs
Xi CBSE Computer Science lab programsXi CBSE Computer Science lab programs
Xi CBSE Computer Science lab programs
Prof. Dr. K. Adisesha
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
Saranya saran
 
Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3
Dr. Loganathan R
 
C Programming Example
C Programming Example C Programming Example
C Programming Example
University of Potsdam
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
PRATHAMESH DESHPANDE
 
Program in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointersProgram in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointers
Dr. Loganathan R
 
Let us c chapter 4 solution
Let us c chapter 4 solutionLet us c chapter 4 solution
Let us c chapter 4 solution
rohit kumar
 
Implement a queue using two stacks.
Implement a queue using two stacks.Implement a queue using two stacks.
Implement a queue using two stacks.
Dr. Loganathan R
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
Rahul Pandit
 
Chapter 5 exercises Balagurusamy Programming ANSI in c
Chapter 5 exercises Balagurusamy Programming ANSI  in cChapter 5 exercises Balagurusamy Programming ANSI  in c
Chapter 5 exercises Balagurusamy Programming ANSI in c
BUBT
 
Chapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in CChapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in C
BUBT
 
Numerical analysis
Numerical analysisNumerical analysis
Numerical analysisVishal Singh
 

What's hot (20)

Let us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solutionLet us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solution
 
Bcsl 033 data and file structures lab s3-3
Bcsl 033 data and file structures lab s3-3Bcsl 033 data and file structures lab s3-3
Bcsl 033 data and file structures lab s3-3
 
Expressions using operator in c
Expressions using operator in cExpressions using operator in c
Expressions using operator in c
 
Bcsl 033 data and file structures lab s5-3
Bcsl 033 data and file structures lab s5-3Bcsl 033 data and file structures lab s5-3
Bcsl 033 data and file structures lab s5-3
 
Let us C (by yashvant Kanetkar) chapter 3 Solution
Let us C   (by yashvant Kanetkar) chapter 3 SolutionLet us C   (by yashvant Kanetkar) chapter 3 Solution
Let us C (by yashvant Kanetkar) chapter 3 Solution
 
C-programs
C-programsC-programs
C-programs
 
Bcsl 033 data and file structures lab s2-1
Bcsl 033 data and file structures lab s2-1Bcsl 033 data and file structures lab s2-1
Bcsl 033 data and file structures lab s2-1
 
Xi CBSE Computer Science lab programs
Xi CBSE Computer Science lab programsXi CBSE Computer Science lab programs
Xi CBSE Computer Science lab programs
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
 
Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3
 
C Programming Example
C Programming Example C Programming Example
C Programming Example
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
Program in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointersProgram in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointers
 
Let us c chapter 4 solution
Let us c chapter 4 solutionLet us c chapter 4 solution
Let us c chapter 4 solution
 
Ansi c
Ansi cAnsi c
Ansi c
 
Implement a queue using two stacks.
Implement a queue using two stacks.Implement a queue using two stacks.
Implement a queue using two stacks.
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
 
Chapter 5 exercises Balagurusamy Programming ANSI in c
Chapter 5 exercises Balagurusamy Programming ANSI  in cChapter 5 exercises Balagurusamy Programming ANSI  in c
Chapter 5 exercises Balagurusamy Programming ANSI in c
 
Chapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in CChapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in C
 
Numerical analysis
Numerical analysisNumerical analysis
Numerical analysis
 

Similar to C- Programming Assignment 3

VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2
YOGESH SINGH
 
Mouse programming in c
Mouse programming in cMouse programming in c
Mouse programming in cgkgaur1987
 
Compiler Design Lab File
Compiler Design Lab FileCompiler Design Lab File
Compiler Design Lab File
Kandarp Tiwari
 
Best C Programming Solution
Best C Programming SolutionBest C Programming Solution
Best C Programming Solution
yogini sharma
 
Introduction to programming c and data structures
Introduction to programming c and data structuresIntroduction to programming c and data structures
Introduction to programming c and data structures
Pradipta Mishra
 
CBSE Class 12 Computer practical Python Programs and MYSQL
CBSE Class 12 Computer practical Python Programs and MYSQL CBSE Class 12 Computer practical Python Programs and MYSQL
CBSE Class 12 Computer practical Python Programs and MYSQL
Rishabh-Rawat
 
the refernce of programming C notes ppt.pptx
the refernce of programming C notes ppt.pptxthe refernce of programming C notes ppt.pptx
the refernce of programming C notes ppt.pptx
AnkitaVerma776806
 
Introduction to programming c and data-structures
Introduction to programming c and data-structures Introduction to programming c and data-structures
Introduction to programming c and data-structures
Pradipta Mishra
 
Programming Fundamentals Arrays and Strings
Programming Fundamentals   Arrays and Strings Programming Fundamentals   Arrays and Strings
Programming Fundamentals Arrays and Strings
imtiazalijoono
 
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
DR B.Surendiran .
 
Background Sometimes the standard C libraries (stdio.h, stdlib.h, e.pdf
Background Sometimes the standard C libraries (stdio.h, stdlib.h, e.pdfBackground Sometimes the standard C libraries (stdio.h, stdlib.h, e.pdf
Background Sometimes the standard C libraries (stdio.h, stdlib.h, e.pdf
ebrahimbadushata00
 
COM1407: Arrays
COM1407: ArraysCOM1407: Arrays
COM1407: Arrays
Hemantha Kulathilake
 
Ch 4
Ch 4Ch 4
Ch 4
AMIT JAIN
 
Cd practical file (1) start se
Cd practical file (1) start seCd practical file (1) start se
Cd practical file (1) start se
dalipkumar64
 
basics of C and c++ by eteaching
basics of C and c++ by eteachingbasics of C and c++ by eteaching
basics of C and c++ by eteaching
eteaching
 
C file
C fileC file
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdf
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdfUsing standard libraries like stdio and sdtlib.h and using stats.h a.pdf
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdf
fashiongallery1
 

Similar to C- Programming Assignment 3 (20)

L5 array
L5 arrayL5 array
L5 array
 
VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2
 
Muzzammilrashid
MuzzammilrashidMuzzammilrashid
Muzzammilrashid
 
Mouse programming in c
Mouse programming in cMouse programming in c
Mouse programming in c
 
Introduction to c part 2
Introduction to c   part  2Introduction to c   part  2
Introduction to c part 2
 
Compiler Design Lab File
Compiler Design Lab FileCompiler Design Lab File
Compiler Design Lab File
 
Best C Programming Solution
Best C Programming SolutionBest C Programming Solution
Best C Programming Solution
 
Introduction to programming c and data structures
Introduction to programming c and data structuresIntroduction to programming c and data structures
Introduction to programming c and data structures
 
CBSE Class 12 Computer practical Python Programs and MYSQL
CBSE Class 12 Computer practical Python Programs and MYSQL CBSE Class 12 Computer practical Python Programs and MYSQL
CBSE Class 12 Computer practical Python Programs and MYSQL
 
the refernce of programming C notes ppt.pptx
the refernce of programming C notes ppt.pptxthe refernce of programming C notes ppt.pptx
the refernce of programming C notes ppt.pptx
 
Introduction to programming c and data-structures
Introduction to programming c and data-structures Introduction to programming c and data-structures
Introduction to programming c and data-structures
 
Programming Fundamentals Arrays and Strings
Programming Fundamentals   Arrays and Strings Programming Fundamentals   Arrays and Strings
Programming Fundamentals Arrays and Strings
 
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
 
Background Sometimes the standard C libraries (stdio.h, stdlib.h, e.pdf
Background Sometimes the standard C libraries (stdio.h, stdlib.h, e.pdfBackground Sometimes the standard C libraries (stdio.h, stdlib.h, e.pdf
Background Sometimes the standard C libraries (stdio.h, stdlib.h, e.pdf
 
COM1407: Arrays
COM1407: ArraysCOM1407: Arrays
COM1407: Arrays
 
Ch 4
Ch 4Ch 4
Ch 4
 
Cd practical file (1) start se
Cd practical file (1) start seCd practical file (1) start se
Cd practical file (1) start se
 
basics of C and c++ by eteaching
basics of C and c++ by eteachingbasics of C and c++ by eteaching
basics of C and c++ by eteaching
 
C file
C fileC file
C file
 
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdf
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdfUsing standard libraries like stdio and sdtlib.h and using stats.h a.pdf
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdf
 

More from Animesh Chaturvedi

Cloud Platforms & Frameworks
Cloud Platforms & FrameworksCloud Platforms & Frameworks
Cloud Platforms & Frameworks
Animesh Chaturvedi
 
Cloud platforms and frameworks
Cloud platforms and frameworksCloud platforms and frameworks
Cloud platforms and frameworks
Animesh Chaturvedi
 
Cloud service lifecycle management
Cloud service lifecycle managementCloud service lifecycle management
Cloud service lifecycle management
Animesh Chaturvedi
 
Graph Analytics and Complexity Questions and answers
Graph Analytics and Complexity Questions and answersGraph Analytics and Complexity Questions and answers
Graph Analytics and Complexity Questions and answers
Animesh Chaturvedi
 
Advance Systems Engineering Topics
Advance Systems Engineering TopicsAdvance Systems Engineering Topics
Advance Systems Engineering Topics
Animesh Chaturvedi
 
P, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardP, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-Hard
Animesh Chaturvedi
 
System Development Life Cycle (SDLC)
System Development Life Cycle (SDLC)System Development Life Cycle (SDLC)
System Development Life Cycle (SDLC)
Animesh Chaturvedi
 
Shortest path, Bellman-Ford's algorithm, Dijkastra's algorithm, their Java co...
Shortest path, Bellman-Ford's algorithm, Dijkastra's algorithm, their Java co...Shortest path, Bellman-Ford's algorithm, Dijkastra's algorithm, their Java co...
Shortest path, Bellman-Ford's algorithm, Dijkastra's algorithm, their Java co...
Animesh Chaturvedi
 
Minimum Spanning Tree (MST), Kruskal's algorithm and Prim's Algorithm, and th...
Minimum Spanning Tree (MST), Kruskal's algorithm and Prim's Algorithm, and th...Minimum Spanning Tree (MST), Kruskal's algorithm and Prim's Algorithm, and th...
Minimum Spanning Tree (MST), Kruskal's algorithm and Prim's Algorithm, and th...
Animesh Chaturvedi
 
System requirements engineering
System requirements engineeringSystem requirements engineering
System requirements engineering
Animesh Chaturvedi
 
Informatics systems
Informatics systemsInformatics systems
Informatics systems
Animesh Chaturvedi
 
Introduction to Systems Engineering
Introduction to Systems EngineeringIntroduction to Systems Engineering
Introduction to Systems Engineering
Animesh Chaturvedi
 
Big Data Analytics and Ubiquitous computing
Big Data Analytics and Ubiquitous computingBig Data Analytics and Ubiquitous computing
Big Data Analytics and Ubiquitous computing
Animesh Chaturvedi
 
Cloud Platforms and Frameworks
Cloud Platforms and FrameworksCloud Platforms and Frameworks
Cloud Platforms and Frameworks
Animesh Chaturvedi
 
Cloud Service Life-cycle Management
Cloud Service Life-cycle ManagementCloud Service Life-cycle Management
Cloud Service Life-cycle Management
Animesh Chaturvedi
 
Push Down Automata (PDA)
Push Down Automata (PDA)Push Down Automata (PDA)
Push Down Automata (PDA)
Animesh Chaturvedi
 
Pumping Lemma and Regular language or not?
Pumping Lemma and Regular language or not?Pumping Lemma and Regular language or not?
Pumping Lemma and Regular language or not?
Animesh Chaturvedi
 
Regular language and Regular expression
Regular language and Regular expressionRegular language and Regular expression
Regular language and Regular expression
Animesh Chaturvedi
 
Pattern detection in mealy machine
Pattern detection in mealy machinePattern detection in mealy machine
Pattern detection in mealy machine
Animesh Chaturvedi
 
NFA to DFA
NFA to DFANFA to DFA
NFA to DFA
Animesh Chaturvedi
 

More from Animesh Chaturvedi (20)

Cloud Platforms & Frameworks
Cloud Platforms & FrameworksCloud Platforms & Frameworks
Cloud Platforms & Frameworks
 
Cloud platforms and frameworks
Cloud platforms and frameworksCloud platforms and frameworks
Cloud platforms and frameworks
 
Cloud service lifecycle management
Cloud service lifecycle managementCloud service lifecycle management
Cloud service lifecycle management
 
Graph Analytics and Complexity Questions and answers
Graph Analytics and Complexity Questions and answersGraph Analytics and Complexity Questions and answers
Graph Analytics and Complexity Questions and answers
 
Advance Systems Engineering Topics
Advance Systems Engineering TopicsAdvance Systems Engineering Topics
Advance Systems Engineering Topics
 
P, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardP, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-Hard
 
System Development Life Cycle (SDLC)
System Development Life Cycle (SDLC)System Development Life Cycle (SDLC)
System Development Life Cycle (SDLC)
 
Shortest path, Bellman-Ford's algorithm, Dijkastra's algorithm, their Java co...
Shortest path, Bellman-Ford's algorithm, Dijkastra's algorithm, their Java co...Shortest path, Bellman-Ford's algorithm, Dijkastra's algorithm, their Java co...
Shortest path, Bellman-Ford's algorithm, Dijkastra's algorithm, their Java co...
 
Minimum Spanning Tree (MST), Kruskal's algorithm and Prim's Algorithm, and th...
Minimum Spanning Tree (MST), Kruskal's algorithm and Prim's Algorithm, and th...Minimum Spanning Tree (MST), Kruskal's algorithm and Prim's Algorithm, and th...
Minimum Spanning Tree (MST), Kruskal's algorithm and Prim's Algorithm, and th...
 
System requirements engineering
System requirements engineeringSystem requirements engineering
System requirements engineering
 
Informatics systems
Informatics systemsInformatics systems
Informatics systems
 
Introduction to Systems Engineering
Introduction to Systems EngineeringIntroduction to Systems Engineering
Introduction to Systems Engineering
 
Big Data Analytics and Ubiquitous computing
Big Data Analytics and Ubiquitous computingBig Data Analytics and Ubiquitous computing
Big Data Analytics and Ubiquitous computing
 
Cloud Platforms and Frameworks
Cloud Platforms and FrameworksCloud Platforms and Frameworks
Cloud Platforms and Frameworks
 
Cloud Service Life-cycle Management
Cloud Service Life-cycle ManagementCloud Service Life-cycle Management
Cloud Service Life-cycle Management
 
Push Down Automata (PDA)
Push Down Automata (PDA)Push Down Automata (PDA)
Push Down Automata (PDA)
 
Pumping Lemma and Regular language or not?
Pumping Lemma and Regular language or not?Pumping Lemma and Regular language or not?
Pumping Lemma and Regular language or not?
 
Regular language and Regular expression
Regular language and Regular expressionRegular language and Regular expression
Regular language and Regular expression
 
Pattern detection in mealy machine
Pattern detection in mealy machinePattern detection in mealy machine
Pattern detection in mealy machine
 
NFA to DFA
NFA to DFANFA to DFA
NFA to DFA
 

Recently uploaded

Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 

Recently uploaded (20)

Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 

C- Programming Assignment 3

  • 1. Lab Assignment 3: Array and Structures: C Programming CS-153 Computer Programming Lab Autumn Semester, 2016, IIT Indore Date: 17-08-16 Note: Write following programs in C language. Also note that this assignment will be evaluated by TA’s in the upcoming labs of next week (22-08-16 onward) for each batch. 1. Write a program to compute the frequencies of all distinct numbers that appear in the array of size N. Read N and the actual numbers in the array from the keyboard before you compute the frequency. 2. Write a program to display Pascal's triangle. Pascal's triangle represents the binomial coefficients*. The first few rows of Pascal's triangle are displayed below. Observe how a row is related to the row above it. Extra Point: How many arrays did you use? Try solving the problem with just one array. * Example of binomial coefficient for 6th row is (x + y)5 = 1 x5 + 5 x4 y + 10 x3 y2 + 10 x2 y3 + 5 x y4 + 1 y5 3. Write a program to produce the following output: A B C D E F G F E D C B A A B C D E F F E D C B A A B C D E E D C B A A B C D D C B A A B C C B A A B B A A A 4. Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the institute. 5. Create a structure to specify data of customers in a bank. The data to be stored is: Account number, Name, Balance in account. Assume maximum of 200 customers in the bank.
  • 2. #include<stdio.h> #include<conio.h> int main(){ int n, t, i, j, arr[30],len, halflen,flag=0,count=0; printf("Enter number of elements to insert in an array:n"); scanf("%d",&len); printf("Enter elements to insert in an array:n"); for(i=0;i<len;i++){ scanf("%d",&t); arr[i]=t; } printf("n"); /*****************************/ for(i=0;i<len;i++){ //loop for pass 1 to len count=1; //again initialize the count variable with 1 for(j=i+1;j<=len-1;j++){ if(arr[i]==arr[j] && arr[i]!='0'){ //if same value of arr[i] find at index 'j' and it is not null then count++; //increment the count of frequency for the value arr[j]='0'; //store null value to arr[j] } } if(arr[i]!='0'){ //if value of arr[i] is not null then printf("%d is %d times.n",arr[i],count); //print the value if arr[i] and it frequency count } } /*****************************/ getch(); return 0; }
  • 3. #include<stdio.h> #include<conio.h> int main() { int array[10][10]; int i, j, k, rows; printf("Enter the number of rowsn"); scanf("%d",&rows); for(i=1; i<=rows; i++) //create array of size rows { for(j=1; j<=i; j++) //count of the values in a row will be same as the index 'i' of the rows { if(j==1||j==i) //if it is first value of a row or count of the values in a row matches with the row index 'i' { array[i][j]=1; //then store value 1 in array[i][j] } else { array[i][j]=array[i-1][i-j]+array[i-1][i-j+1]; //else sum the two values on above row of } } } for(i=1; i<=rows; i++) //print array of size rows { for(k=1; k<=rows-i; k++) //adjust the spaces between printed values for the index 1 to row-i { printf(" "); } for(j=1; j<=i; j++) //print values form the index 1 to i { printf("%d ",array[i][j]); } printf("n"); } getch(); }
  • 4. #include<stdio.h> #include<conio.h> main() { int i,j,k,l; for(i=71;i>=65;i--) { /* loop for printing ascending letters */ for(j=65;j<=i;j++) { printf("%c ",j); } /* loop for making a space between patterns */ for(k=i+1;k<=71;k++) { if(k==71) printf(" "); if(k<71) printf(" "); } /* loop to print descending letters */ for(l=i;l>=65;l--) { if(l==71) { /* to skip printing 'G' twice */ continue; } printf("%c ",l); } printf("n"); } getch(); return 0; }
  • 5. #include<stdio.h> #include<conio.h> #define N 450 struct students { int rlnm; char name[25]; char dept[25]; /* structure defined outside of main(); */ char course[25]; int year; }; main() { /* main() */ struct students s[N]; int i, ch; /* taking input of 450 students in an array of structure */ for (i = 0; i < N; i++) { printf(" Enter data of student %dtttttotal students: %dn", i + 1, N); printf("****************************nn"); printf("enter rollnumber: "); scanf("%d", & s[i].rlnm); printf("nnenter name: "); scanf(" %s", & s[i].name); printf("nnenter department: "); scanf("%s", & s[i].dept); printf("nnenter course: "); scanf("%s", & s[i].course); printf("nnenter year of joining: "); scanf("%d", & s[i].year); } getch(); }
  • 6. #include<stdio.h> #include<conio.h> #define N 200 struct bank { int acn; char name[20]; int bal; /* defined out of main() */ }; void main() { struct bank b[N]; int i, ch, lw = 100, ch2, ac, am; for (i = 0; i < N; i++) { /* inputting customer data */ printf("tEnter information of customers n"); printf("t******************************nn"); printf("enter account no.: "); scanf("%d", & b[i].acn); printf("nnenter customer name: "); scanf("%s", & b[i].name); printf("nnenter balance: "); scanf("%d", & b[i].bal); } getch(); }