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();
}
Ad

More Related Content

What's hot (20)

Graphs from Finite Groups: An Overview
Graphs from Finite Groups: An OverviewGraphs from Finite Groups: An Overview
Graphs from Finite Groups: An Overview
Yusuf Zakariya
 
Strings in python
Strings in pythonStrings in python
Strings in python
Prabhakaran V M
 
Python Programming | JNTUA | UNIT 2 | Conditionals and Recursion |
Python Programming | JNTUA | UNIT 2 | Conditionals and Recursion | Python Programming | JNTUA | UNIT 2 | Conditionals and Recursion |
Python Programming | JNTUA | UNIT 2 | Conditionals and Recursion |
FabMinds
 
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
 
String & its application
String & its applicationString & its application
String & its application
Tech_MX
 
Topological Sort
Topological SortTopological Sort
Topological Sort
Dr Sandeep Kumar Poonia
 
Matrices, Arrays and Vectors in MATLAB
Matrices, Arrays and Vectors in MATLABMatrices, Arrays and Vectors in MATLAB
Matrices, Arrays and Vectors in MATLAB
Abu Raihan Ibna Ali
 
Matlab Graphics Tutorial
Matlab Graphics TutorialMatlab Graphics Tutorial
Matlab Graphics Tutorial
Cheng-An Yang
 
Matlab plotting
Matlab plottingMatlab plotting
Matlab plotting
shahid sultan
 
A* Search Algorithm
A* Search AlgorithmA* Search Algorithm
A* Search Algorithm
vikas dhakane
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
Azhar Javed
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
hodcsencet
 
String c
String cString c
String c
thirumalaikumar3
 
Programming for Problem Solving
Programming for Problem SolvingProgramming for Problem Solving
Programming for Problem Solving
Kathirvel Ayyaswamy
 
Neural Networks
Neural NetworksNeural Networks
Neural Networks
Sagacious IT Solution
 
Nonrecursive predictive parsing
Nonrecursive predictive parsingNonrecursive predictive parsing
Nonrecursive predictive parsing
alldesign
 
Chapter 6 Balagurusamy Programming ANSI in c
Chapter 6  Balagurusamy Programming ANSI  in cChapter 6  Balagurusamy Programming ANSI  in c
Chapter 6 Balagurusamy Programming ANSI in c
BUBT
 
Probability and random processes project based learning template.pdf
Probability and random processes project based learning template.pdfProbability and random processes project based learning template.pdf
Probability and random processes project based learning template.pdf
Vedant Srivastava
 
Presentation on c structures
Presentation on c   structures Presentation on c   structures
Presentation on c structures
topu93
 
Backtracking & branch and bound
Backtracking & branch and boundBacktracking & branch and bound
Backtracking & branch and bound
Vipul Chauhan
 
Graphs from Finite Groups: An Overview
Graphs from Finite Groups: An OverviewGraphs from Finite Groups: An Overview
Graphs from Finite Groups: An Overview
Yusuf Zakariya
 
Python Programming | JNTUA | UNIT 2 | Conditionals and Recursion |
Python Programming | JNTUA | UNIT 2 | Conditionals and Recursion | Python Programming | JNTUA | UNIT 2 | Conditionals and Recursion |
Python Programming | JNTUA | UNIT 2 | Conditionals and Recursion |
FabMinds
 
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
 
String & its application
String & its applicationString & its application
String & its application
Tech_MX
 
Matrices, Arrays and Vectors in MATLAB
Matrices, Arrays and Vectors in MATLABMatrices, Arrays and Vectors in MATLAB
Matrices, Arrays and Vectors in MATLAB
Abu Raihan Ibna Ali
 
Matlab Graphics Tutorial
Matlab Graphics TutorialMatlab Graphics Tutorial
Matlab Graphics Tutorial
Cheng-An Yang
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
Azhar Javed
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
hodcsencet
 
Nonrecursive predictive parsing
Nonrecursive predictive parsingNonrecursive predictive parsing
Nonrecursive predictive parsing
alldesign
 
Chapter 6 Balagurusamy Programming ANSI in c
Chapter 6  Balagurusamy Programming ANSI  in cChapter 6  Balagurusamy Programming ANSI  in c
Chapter 6 Balagurusamy Programming ANSI in c
BUBT
 
Probability and random processes project based learning template.pdf
Probability and random processes project based learning template.pdfProbability and random processes project based learning template.pdf
Probability and random processes project based learning template.pdf
Vedant Srivastava
 
Presentation on c structures
Presentation on c   structures Presentation on c   structures
Presentation on c structures
topu93
 
Backtracking & branch and bound
Backtracking & branch and boundBacktracking & branch and bound
Backtracking & branch and bound
Vipul Chauhan
 

Similar to C- Programming Assignment 3 (20)

L5 array
L5 arrayL5 array
L5 array
Santoshkumar Balkunde
 
VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2
YOGESH SINGH
 
Numerical analysis
Numerical analysisNumerical analysis
Numerical analysis
Vishal Singh
 
Muzzammilrashid
MuzzammilrashidMuzzammilrashid
Muzzammilrashid
muzzammilrashid
 
Mouse programming in c
Mouse programming in cMouse programming in c
Mouse programming in c
gkgaur1987
 
Introduction to c part 2
Introduction to c   part  2Introduction to c   part  2
Introduction to c part 2
baabtra.com - No. 1 supplier of quality freshers
 
Arrays 2d Arrays 2d Arrays 2d Arrrays 2d
Arrays 2d Arrays 2d Arrays 2d Arrrays 2dArrays 2d Arrays 2d Arrays 2d Arrrays 2d
Arrays 2d Arrays 2d Arrays 2d Arrrays 2d
LakshayBhardwaj39
 
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
 
678676286-CLASS-12-COMPUTER-SCIENCE-PRACTICAL-FILE-2023-24.pdf
678676286-CLASS-12-COMPUTER-SCIENCE-PRACTICAL-FILE-2023-24.pdf678676286-CLASS-12-COMPUTER-SCIENCE-PRACTICAL-FILE-2023-24.pdf
678676286-CLASS-12-COMPUTER-SCIENCE-PRACTICAL-FILE-2023-24.pdf
anuragupadhyay0537
 
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
 
Python Lab Manual for First year Engineering students
Python Lab Manual for First year Engineering studentsPython Lab Manual for First year Engineering students
Python Lab Manual for First year Engineering students
AkshayAgrawal34132
 
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
 
C-programs
C-programsC-programs
C-programs
SSGMCE SHEGAON
 
VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2
YOGESH SINGH
 
Numerical analysis
Numerical analysisNumerical analysis
Numerical analysis
Vishal Singh
 
Mouse programming in c
Mouse programming in cMouse programming in c
Mouse programming in c
gkgaur1987
 
Arrays 2d Arrays 2d Arrays 2d Arrrays 2d
Arrays 2d Arrays 2d Arrays 2d Arrrays 2dArrays 2d Arrays 2d Arrays 2d Arrrays 2d
Arrays 2d Arrays 2d Arrays 2d Arrrays 2d
LakshayBhardwaj39
 
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
 
678676286-CLASS-12-COMPUTER-SCIENCE-PRACTICAL-FILE-2023-24.pdf
678676286-CLASS-12-COMPUTER-SCIENCE-PRACTICAL-FILE-2023-24.pdf678676286-CLASS-12-COMPUTER-SCIENCE-PRACTICAL-FILE-2023-24.pdf
678676286-CLASS-12-COMPUTER-SCIENCE-PRACTICAL-FILE-2023-24.pdf
anuragupadhyay0537
 
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
 
Python Lab Manual for First year Engineering students
Python Lab Manual for First year Engineering studentsPython Lab Manual for First year Engineering students
Python Lab Manual for First year Engineering students
AkshayAgrawal34132
 
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
 
Ad

More from Animesh Chaturvedi (20)

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
 
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
 
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
 
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
 
Ad

Recently uploaded (20)

An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient CareAn Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
Cyntexa
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
Artificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptxArtificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptx
03ANMOLCHAURASIYA
 
Unlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web AppsUnlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web Apps
Maximiliano Firtman
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
IT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information TechnologyIT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information Technology
SHEHABALYAMANI
 
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Cyntexa
 
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
SOFTTECHHUB
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
Cybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and MitigationCybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and Mitigation
VICTOR MAESTRE RAMIREZ
 
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
Ivano Malavolta
 
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptxTop 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
mkubeusa
 
AI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of DocumentsAI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of Documents
UiPathCommunity
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
May Patch Tuesday
May Patch TuesdayMay Patch Tuesday
May Patch Tuesday
Ivanti
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent LasterAI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
Agentic Automation - Delhi UiPath Community Meetup
Agentic Automation - Delhi UiPath Community MeetupAgentic Automation - Delhi UiPath Community Meetup
Agentic Automation - Delhi UiPath Community Meetup
Manoj Batra (1600 + Connections)
 
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdfKit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Wonjun Hwang
 
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient CareAn Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
Cyntexa
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
Artificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptxArtificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptx
03ANMOLCHAURASIYA
 
Unlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web AppsUnlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web Apps
Maximiliano Firtman
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
IT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information TechnologyIT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information Technology
SHEHABALYAMANI
 
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Cyntexa
 
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
SOFTTECHHUB
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
Cybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and MitigationCybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and Mitigation
VICTOR MAESTRE RAMIREZ
 
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
Ivano Malavolta
 
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptxTop 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
mkubeusa
 
AI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of DocumentsAI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of Documents
UiPathCommunity
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
May Patch Tuesday
May Patch TuesdayMay Patch Tuesday
May Patch Tuesday
Ivanti
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent LasterAI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdfKit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Wonjun Hwang
 

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(); }
  翻译: