Mr. Chidanand S. Kusur, Asst. Professor, Department of Computer Science and Engineering, BLDEAs V. P. Dr. P. G. H. College of Engineering and Technology, Vijayapur-03, Karnataka, India. ~ send your feedback to cs.kusur@gmail.com
About Me
Wednesday 30 December 2020
Wednesday 23 December 2020
Assignment 1....for I and K Division I Sem BLDEAs Engineering College, Vijayapur.....
Write the same and submit.....
Tuesday 8 September 2020
Tips to get jobs after the successful completion of Engineering Course OR How to well settle after Engineering course?
Monday 24 August 2020
Tips to pass the C for Problem Solving Back Subject for I and II sem B.E. (VTU, Belagavi)
Dear students,
Always explain more about the asked question and underline the important points.
Do not forget to write SYNTAX and do not forget draw FLOWCHART
Draw BOX around syntax.
Give more examples for asked questions. You can write core part of a program or entire program.
Prepare some programming examples for each topic.
To calculate simple interest
To calculate are and perimeter of rectangle
Largest of two numbers.
Largest of three numbers.
To check for leap year
To find roots of quadratic equation.
To check for PALINDROME
To print first N fibonacci numbers.
To find matrix multiplication
To implement BUBBLE SORT
To read and display N students information using array of structure
Programming example for dynamic memory allocation.
To swap (interchange) two values using pointer.
Note: If you these programming questions then well and good. Otherwise use these programs as EXAMPLES for respective topics.
Worst case assume that, for one page answer you get 1 marks.
The you need to write minimum 20 pages (front and back 40 pages) to pass the subject. (Safer Side)
Eventhough, you write less pages with quality points,,, you pass...
All teachers are interested to PASS you...But...you need to write more with quality points, syntax, flowchart and programming examples. Most of the students will not do.
All teachers are good...Everyone wants to PASS you...no one is interested to FAIL you..So, please write more.
For Exam preparation...prepare in REVERSE order i.e.
Module-5 Important topics.
Preprocessor, Pointer, Dynamic Memory Allocation, Structure, Array of Structure
Module-4 Important Topics
Functions, Types, Categories, Actual and Formal Parameters, Call by value and Call by reference, Recursive functions
Module-3 Important Topics
1D array
2D array
Bubble sort program, Matrix Multiplication
Module-2 Important Topics
simple if, if else, nested if, else if ladder, switch
while , do while and for
break , continue, goto
Module-1 Important Topics.
Block diagram of computer
Types of computers
Generations of computers
Input and Output devices.
C tokens
Structure of C Program
Formatted Input and Output Functions
Operators(arithmetic, relational, logical, increment and decrement, bitwise, condition, special)
....
ALL THE BEST
Important C programs for C for Problem Solving for I and II sem of Engineering Students (As per VTU)
C program to calculate simple interest.
# include<stdio.h>
void main()
{
float p, t, r, si;
printf("Enter P T R ");
scanf("%f%f%f",&p,&t,&r);
si=(p*t*r)/100;
printf("\n Simple Interest is %f", si);
}
Output:
Enter P T R
100 5 5 [Enter Key]
Simple Interest is
25.00
C program to calculate area and perimeter of rectangle.
# include<stdio.h>
void main()
{
float l, b, area, per;
printf("Enter length and breadth of rectangle ");
scanf("%f%f", &l, &b);
area=l*b;
per=2*(l+b);
printf("\n Area of rectangle is %f", area);
printf("\n Perimeter rectangle is %f", per);
}
Output:
Enter length and breadth of rectangle
10 20 [Enter Key]
Area of rectangle is 200.00
Perimeter of rectangle is 60.00
C program to check for PALINDROME or not.
# include<stdio.h>
void main()
{
int n, rem, rev=0, temp;
printf("Enter a number to be check ");
scanf("%d",&n);
temp=n;while (n!=0)
{rem=n%10;rev=(rev*10)+rem;n=n/10;}
if (rev==temp)printf("\n PALINDROME");
elseprintf("\n NOT Palindrome ");
}
Output:
Enter a number to be check
123NOT Palindrome
# include<stdio.h>
void main()
{
int n, rem, rev=0, temp;
printf("Enter a number to be check ");
scanf("%d",&n);
Output:
Output:
Enter a number to be check
121PALINDROME
Monday 17 August 2020
C for Problem Solving (Tips and Important Questions to pass the this subject) Module Wise Important Questions (I and II Sem VTU Syllabus)
Module-1 ( Use my YouTube Channel for explanation) CHIDANAND S KUSUR
Explain the "Structure of Computer" with neat block diagram. [2 + 3 + 5 =10 Marks]
Tips:
Write What is computer? ...You get 2 marks
Draw diagram: 3 marks
Input Unit
System Unit : Memory Unit + [ALU + CU]
Output Unit
Explanation of All Units: 5 marks
List of input devices with explanation in brief about each.
List of output devices with explanation in brief about each.
Generations of Computers
Types of Computers
What are C tokens? List and explain all in brief. (2 m + 1 m + 6 m = 9 marks)
What are C tokens? 2 marks
List: 1 mark
Keywords
Identifiers
Constants
Strings
Operators
Special Symbols
Explain all the above 6 : 6 marks
What are formatted I/O functions? List and discuss with syntax and examples.
(2 m + 3 m + 3 m = 8 m)
What are formatted I/O functions? 2 marks
scanf() : Explanation, Syntax, Examples (3 m)
printf() : Explanation, Syntax, Examples (3 m)
What are identifiers? Write rules for defining identifiers with valid and invalid examples for each rule.
Explain "Structure of C Program" with programming example.
[Documentation Part]
[Preprocessor Part]
[Global Part]
int main()
{
declaration part;
executable part;
return (0);
}
[User defined function]
Explain all the above parts with examples.
Give one programming example that covers all the parts.
Write C programs for following
To calculate simple interest
si=(p*t*r)/100;
input: p, t, r
output: si
To find area and perimeter of rectangle.
area=(l*b)
p=2*(l+b)
To find area and circumference of a circle
area=3.142*r*r
cir=2*3.142*r
To find area of triangle by reading breadth and height
area=0.5*breadth*height
To find area of triangle by reading three sides of it.
s=(a+b+c)/2
area=sqrt((s-a)*(s-b)*(s-c))
Module -2
Discuss the following decision making or selection or branching or conditional statements with syntax, flowchart and examples.
simple if
if else
nested if
else if ladder (cascaded if)
switch
Note:
Explain all the above with explanation (1 mark) syntax (2 marks) flowchart (2 marks) Examples (2 marks) for all
Discuss following loop statements with syntax , flowchart and examples.
while
do while
for
Write differences between while and do while
Write differences between break and continue statements.
Write C programs for following
Largest of three numbers
To check for leap year or not
To check for PALINDROME
To check for PRIME number
To find factorial of N
To find GCD and LCM of two numbers
Module 3
What is 1D array? Discuss its declaration and initialization with syntax and examples.
What is 2D array? Discuss its declaration and initialization with syntax and examples.
Module 4
Discuss the three elements of user defined function with syntax and examples.
What are actual and formal parameters?Give example.
Discuss 4 categories of function with programming examples.
Write difference between call by value and call by reference
What is recursive function?Give example.
Module 5
What is structure?Discuss defining structure and structure variables with syntax and examples.
What array of structure?Give programming example.
What is nested structure?Give example.
What is pointer?Discuss its declaration and syntax with examples.
What is dynamic memory allocation?Give programming example.
Discuss malloc, calloc, realloc, free with examples.
Write C program to swap two values using pointers.
Write C program to read and display N students information using array of structure.
What are preprocessors?Discuss three types with examples.
Answer:
Preprocessors are the pre processing tools.
These will be executed before the COMPILATION of C program.
There are helpful to add HEADER files, define SYMBOLIC constants , add EXTERNAL C files and to write compatible C programs.
Types of Preprocesors:
1. Macro substitution directives.
There are helpful to define symbolic constants.
Examples:
#define PI 3.142
# define MAX 100
# define MIN 0
# define N 50
# define SIZE 100
2. File inclusion directives.
There are helpful to add header files in C programs. So that, we can access the contents of these header files. Although, helps to add other external C files. So that, we can access the sub programs (user defined functions) to do specific task in current program.
Examples:
# include<stdio.h>
#include<math.h>
#include "string.h"
#include "alloc.h"
#include "d:\\demo\\p1.c"
3. Compiler control directives.
There are helpful to write portable C programs. i.e. helps to run the same C program on different hardware platform.
Example:
#if (MACHINE==HCL)
#define file "hcl.h"
elif (MACHINE==WIPRO)
#define file "wipro.h"
elif (MACHINE==DELL)
#define file "dell.h"
endif
#include file
All the best!
Put faith on you....This time you can.....
All the best
Write more in exam
Underline important points.
Practice programs, if you wont get in exam, write as examples.
Explanation Syntax and Examples ....compulsory for all questions
All the best.....
NOTE: SEND FEEDBACK
WRITE COMMENTS
WATCH MY YOUTUBE CHANNEL CHIDANAND S KUSUR AND SUBSCRIBE
9739762682
cs.kusur@gmail.com
Sunday 5 July 2020
Sunday 28 June 2020
Sunday 21 June 2020
Saturday 20 June 2020
Monday 15 June 2020
Tuesday 9 June 2020
Sunday 7 June 2020
Monday 1 June 2020
Sunday 31 May 2020
Saturday 30 May 2020
Thursday 28 May 2020
Wednesday 27 May 2020
Tuesday 26 May 2020
Monday 25 May 2020
Sunday 24 May 2020
Friday 22 May 2020
Monday 18 May 2020
Sunday 17 May 2020
Friday 15 May 2020
Thursday 14 May 2020
Wednesday 13 May 2020
Sunday 10 May 2020
Saturday 9 May 2020
Thursday 7 May 2020
Wednesday 6 May 2020
Tuesday 5 May 2020
Monday 4 May 2020
Sunday 3 May 2020
Saturday 2 May 2020
Friday 1 May 2020
Thursday 30 April 2020
Wednesday 29 April 2020
Tuesday 28 April 2020
Monday 27 April 2020
Sunday 26 April 2020
Saturday 25 April 2020
Friday 24 April 2020
Thursday 23 April 2020
Wednesday 22 April 2020
Tuesday 21 April 2020
Monday 20 April 2020
Saturday 18 April 2020
Friday 17 April 2020
Thursday 16 April 2020
Wednesday 15 April 2020
Tuesday 14 April 2020
Sunday 12 April 2020
Saturday 11 April 2020
Friday 10 April 2020
Wednesday 8 April 2020
Tuesday 7 April 2020
Monday 6 April 2020
Sunday 5 April 2020
Saturday 4 April 2020
Friday 3 April 2020
Thursday 2 April 2020
Wednesday 1 April 2020
Tuesday 31 March 2020
Monday 30 March 2020
Saturday 28 March 2020
Lecture (Class) on "Input and Output Functions in C"
Read it very slowly and try to understand.
Read minimum 3 times or more
Lecture on Input and Output Functions in C
...Take care...
Assignment - 1 Submission Sheet
Those who have sent the assignment to my e mail ID cs.kusur@gmail.com, kindly, fill this form.
Assignment-1 Submission Sheet
Take care....
Wednesday 25 March 2020
Saturday 21 March 2020
Tuesday 17 March 2020
Monday 16 March 2020
Assignment-1 on Python (For VI Semester Mechanical Engineering Students)
Hints:
(4 LED OF I(ndian) HP G(as) 2M(aintenance)
"Python is a high level, interpreted and object oriented programming language."
Features:
Easy
Expressive
Free and Opensource
High level language
Portable
Object Oriented
Extensible
Embedded
Interpreted
Large standard library
GUI Programming
Dynamically Typed
Multi Threaded
Garbage collection
Maintenance is easier
List and explain in brief about the applications of Python.
Hint: DR 3SSSW ABCD ENG DP
Applications:
Web development
Desktop GUI applications
Scientific and Numeric Applications
Software Development
Education
Business Applications
Database Access Applications
Network Programming
Games and 3D Graphics Applications
Artificial Intelligence and Machine Learning Applications
Prototyping
3D CAD application
Computer Vision applications
Robotics
Data Analysis, etc.
Discuss with examples about to two working modes with Python.
Interactive mode and Script mode
What is variable? List the rules to declare a variable in Python. Demonstrate with examples.
Explain the rules of precedence of operators in Python with examples.
What is debugging ? Discuss types of errors.
bug means error in computer program.
The process of removing errors from written program is called debugging.
Explain following three types of errors.
syntax error
runtime error
semantic error
What is functions in Python? Discuss function definition and function call with examples.
Write a Python program to find volume of a sphere.
Hint: (volume=(4/3)*(3.142)*radius*radius*radius
Write a python program to find addition, subtraction, multiplication and division of two integers.
Write a python program to find largest of two integers.
Write a python program to check for leap year or not leap year.
Write a python program to convert temperature reading from Fahrenheit to Celsius.
Write a function to find square and cube of a number in python.
Write a function to print following grid on display.
+ - - - - + - - - - +
| - - - - | - - - - |
| - - - - | - - - - |
Saturday 14 March 2020
Class Ranks for the subject C for Problem Solving I Sem G Division
Congratulations to all,
You need to improve your results for the II semester.
Yours goal must be VTU ranks or scoring out of out in all subjects.
Click on below link....
Class Rank for the subject C for Problem Solving for I Sem. Division
All the best for forthcoming semesters.......
Wednesday 11 March 2020
Assignment-1 C Program for Problem Solving II Semester "A" division
My notes is available in Pixel Print zerox centre with previous year question papers.
Reading my notes is not compulsory. My notes will be act as reference for you.
Dear students, read VTU recommended books, read - understand - represent in your own sentences with quality points.
This preparation helps for IA and VTU main exam.
This preparation must be as if you are preparing for IA or VTU main exam.
You can write answers in ruled pages or notes book or assignment books.
Even you can submit zerox copies to me by retaining original copy with you.
All the best...for first IA.
Wednesday 4 March 2020
Thursday 27 February 2020
Tuesday 25 February 2020
Wednesday 19 February 2020
Sunday 16 February 2020
"Introduction Class" for II Sem. 'A'
Hearty welcome to second semester of your engineering course.
Be positive.
Everyday is a new opportunity for us to re-correct our yesterday's mistake to move ahead to reach our destiny.
Be inspired. Inspire others.
Read for knowledge.
Once, you gain knowledge apply it. (Then, value will come for the knowledge.)
Be regular to classes. You need to give APPLICATION for yours every ABSENT to classes with genuine reason. It is mandatory.
Listen to all teachers.
Give respect to all teachers.
Wish the teachers, when they come in front of you.
Do not use mobile phones in class rooms.
Do not each chewgum or other else in class rooms. It disturbs teachers to teach topics.
For any activity in class, take permission from teacher.
To enter the running class, you need to ask, Excuse me sir!, May I come in....
Follow RULES of college.
Wear ID cards in class room.
Wear Formal dress with smiling face.
Be healthy with good thoughts in your mind.
Ours beauty depends upon our good thoughts.
Our institute has one vision to provide Efficient Engineers to deal with the societal technical problems.
To convert this dream in to reality, our institute has Institute Mission. (Action to convert Institute Vision in to reality)
As a part of Institute Vision and Institute Mission, all departments in our college has individual Department Vision and Department Mission.
Programme means: to which branch, you have taken admission.
i.e. Computer Science and Engineering is a Program.
We have Program Educational Objectives (PEOs), as well as Program Outcomes (POs)
As a part of Department Mission, all teachers are teaching subjects(courses) with some objective, which are called Course Learning Objectives.
All our Institute Vision and Institute Mission, Department Vision and Department Vision are working fine to make your Family Vision and Family Mission successful. i.e. to convert yours dreams into reality.
Our college is accredited by NBA, NAAC and ISO. i.e. to provide Outcome Based Education(OBE) to you....So, be happy...be inspired...recall yours dreams and work...listen to all teachers. We are here, we are working for you to convert your dream in to reality. (Indirectly our dream will be converted into reality).
ALL THE BEST...
Let us start...
Friday 17 January 2020
Tuesday 7 January 2020
Module Wise Important Questions on "C for Problem Solving " for first and second semester B.E. Examination (VTU, Belagavi)
Block diagram of a computer with explanation of each part in brief.
List of input devices with explanation in brief about each.
List of output devices with explanation in brief about each.
Generations of Computers
Types of Computers
What is computer network? list its advantages.
Write differences between LAN, WAN and MAN
Discuss network topologies (bus, star, ring and mesh) with diagram and examples.
Do not forget to send feedback or comment.
Module-2
Structure of a c program with programming example.
C-tokens (list and explain in brief)
What is identifier? Discuss rules for defining identifiers with valid and invalid examples for each rule.
What is variable? Discuss its declaration and initialization with syntax and examples.
What are formatted input and output functions(scanf and printf)? Discuss with syntax and examples.
What are unformatted input and output functions? Discuss with syntax and examples.
List and discuss the following operators with explanation and examples.
Arithmetic
Relational
Logical
increment and decrement
Conditional operator
Bitwise operators
Special operators (comma and sizeof)
What is typecast(type conversion)? Discuss implicit and explicit type conversions with examples.
Write c programs for following.
To find simple interest (algorithm, flowchart, pesudocode, program)
To find area and circumference of a circle (algorithm, flowchart, pseudocode, program)
To find area and perimeter of rectangle.
To find area of triangle by reading breadth and height of it.
To find area of triangle by reading 3 sides of it (a,b,c)
To swap to values using temporary variable.
To swap to values without using temporary variable.
Do not forget to send feedback or comment.
Module-3
Discuss the following conditional(decision making/selection/branching) statements with syntax, flowchart and examples.
simple if
if else
nested if
else if ladder
switch
Discuss the following loop statements with syntax, flowchart and examples.
while
do while
for
Write differences between while and do while statements.
Write differences between break and continue statements.
Discuss the following storage classes used in C with examples.
automatic variables
global variables
static variables
register variables
Programs:
To check for leap year
To check, whether the number N is even or odd number.
To check, whether the number is PALINDROME or not.
To find factorial of N
GCD and LCM using Euclid's algorithm.
To print first N fibonacci numbers.
Do not forget to send feedback or comment.
Module-4
What is one dimensional array? Discuss its declaration and initialization with syntax and examples.
What is two dimensional array? Discuss its declaration and initialization with syntax and examples.
What is string? Discuss its declaration and initialization with syntax and examples.
Discuss all string handling functions with syntax and examples.
Programs:
Bubble sort
Linear search
Binary search
Sum and Avg of N numbers
Find maximum and minimum of N numbers
Do not forget to send feedback or comment.
Module-4
Discuss the 3 elements of user defined functions with syntax and examples.
Discuss categories of function with examples.
What are actual and formal parameters?Discuss with examples.
Discuss parameter passing mechanism. (call by value and call by reference)
What is recursive function?Give example.
Programs:
Function to check for prime number.
Function to find length of a string.
Do not forget to send feedback or comment.
Module-5
What is structure?Discuss declaration of structure and structure variable with syntax and examples.
What is array of structure?Give programming example.
What is nested structure?Give example.
Discuss structures and functions with example.
What is pointer? Discuss its declaration and initialization with syntax and examples.
What is dynamic memory allocation? Discuss memory allocation functions like malloc(), calloc(), realloc(), fee().
What are pre-processors? Discuss three types with examples.
Programs:
Swap two values using pointers.
Standard deviation
C Program to print Pascals Triangle (Click below link)
https://drive.google.com/file/d/1gv62LCGTury6zdevYFfRUUrPRME17fxV/view?usp=sharing
Note: Send your feedback to cs.kusur@gmail.com or Write comments.
Important C programs to be practice for C for Problem Solving I or II Semester B.E. Examination, VTU, Belagavi
#include<stdio.h>
void main()
{
float p, t, r, si;
printf("Enter principle amount, rate of interest and time period ");
scanf("%f%f%f",&p, &t, &r);
si=(p * t * r)/100;
printf(" Simple Interest=%f",si);
}
C program to calculate area and circumference of a circle
#include<stdio.h>
void main()
{
float r, area, cir;
printf("Enter radius of a circle ");
scanf("%f",&r);
area=3.142 * r * r;
cir=2 * r *r;
printf("\n Area of circle = %f ",area);
printf("\n Circumference of circle = %f ",cir);
}
C program to calculate area and perimeter of a rectangle
#include<stdio.h>
void main()
{
float l, b, area, per;
printf("Enter length and breadth of rectangle ");
scanf("%f%f",&l,&b);
area= l * b;
per=2 * (l+b);
printf("\n Area of rectangle = %f ",area);
printf("\n Perimeter of rectangle = %f ",per);
}
C program to calculate area or triangle by reading its breadth and height (Inputs: b and h)
#include<stdio.h>
void main()
{
float b, h, area;
printf("Enter breadth and height of a rectangle ");
scanf("%f%f",&b, &h);
area= 0.5 * b * h;
printf("\n Area of triangle = %f ",area);
}
C program to calculate area or triangle by reading 3 sides of triangle (a,b,c)
#include<stdio.h>
#include<math.h>
void main()
{
float a, b, c, s, area;
printf("Enter 3 sides of triangle ");
scanf("%f%f%f", &a, &b, &c);
s=(a+b+c)/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
printf("\n Area of triangle = %f ",area);
}
Do not forget to send feedback or comment.
C program to swap (interchange) the contents of two variables using temporary variable .
#include<stdio.h>
void main()
{
int a,b, temp;
printf("Enter two integers a and b ");
scanf("%d%d",&a,&b);
printf(" \n Before Swap ");
printf(" \n a=%d b=%d ",a,b);
temp=a;
a=b;
b=temp;
printf(" \n After Swap ");
printf(" \n a=%d b=%d ",a,b);
}
C program to check, whether the year is LEAP year or not.
# include<stdio.h>
void main()
{
int year;
printf("Enter year to be check");
scanf("%d",&year);
if ( (year%4==0) && (year%100!=0) || (year %400==0) )
printf("Leap Year");
else
printf("Not Leap Year");
}
Note:
If you get this programming question then write the above program.
If you won't get question on it; then us it as example for if else statement.
Do not forget to send feedback or comment.
C program to find largest of two numbers.
#include<stdio.h>
void main()
{
int a,b;
printf("Enter two numbers");
scanf("%d%d",&a,&b);
if (a>b)
printf(" %d is largest",a);
else
printf("%d is largest",b);
}
Note: Use this program as example for if else statement used in C.
C program to find largest of three numbers.
#include<stdio.h>
void main()
{
int a,b,c;
printf("Enter three numbers");
scanf("%d%d%d",&a,&b,&c);
if (a>b && a>c)
printf(" %d is largest",a);
else if (b>a && b>c)
printf("%d is largest",b);
else
printf("%d is largest",c);
}
Do not forget to send feedback or comment.
C program to explain the working of switch statement
#include<stdio.h>
void main()
{
int ch;
printf("Enter your choice [1 2 3 ?] ");
scanf("%d",&c);
switch(ch)
{
case 1:
printf("\n You have selected first choice");
break;
case 2:
printf("\n You have selected second choice");
break;
case 3:
printf("\n You have selected third choice");
break;
default:
printf("\n Sorry! Invalid choice ");
break;
}
}
C program to check a number for palindrome or not.
#include<stdio.h>
void main()
{
int num, rem, rev=0,temp;
printf("Enter number to be check ");
scanf("%d",&num);
temp=num;
while (num !=0)
{
rem=num%10;
rev=(rev*10)+rem;
num=num/10;
}
if (temp = = rev)
printf("\n Palidrome");
else
printf("\n Not palindrome");
}
Do not forget to send feedback or comment.
C program to find factorial of number n
#include<stdio.h>
void main()
{
int n, i, prod=1;
printf("Enter a number ");
scanf("%d",&n);
for(i=1; i<=n; i++)
{
prod=prod*i;
i=i+1;
}
printf("\n Factorial is %d", prod);
}
C program to implement BUBBLE sort technique
#include<stdio.h>
void main()
{
int n, i, j, temp ;
int a[100];
printf("Enter number of elements ");
scanf("%d",&n);
printf("\n Enter %d numbers to be sort ",n);
for(i=0; i<n; i++)
{
scanf("%d", &a[i]);
}
for(i=0;i<n;i++)
{
for(j=0;j<n-i-1;j++)
{
if(a[j]>=a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
printf("\n After Bubble Sort");
for(i=0; i<n; i++)
{
printf("\n %d", a[i]);
}
}
Do not forget to send feedback or comment.
C program to implement ADDITION OF TWO MATRICES
#include<stdio.h>
void main()
{
int m,n,p,q;
int i, j;
in a[100][100],b[100][100],c[100][100];
printf("Enter the order of matrx A ");
scanf("%d%d",&m,&n);
printf("Enter the order of matrx B ");
scanf("%d%d",&p, &q);
if (m = = n && p = = q)
{
printf("\n Matrix Addition is possible ");
printf("\n Enter elements of matrix A ");
for(i=0; i<m; i++)
{
for(j=0;j<n;j++)
{
scanf("%d", &a[i][j]);
}
}
printf("\n Enter elements of matrix B ");
for(i=0; i<p; i++)
{
for(j=0;j<q;j++)
{
scanf("%d", &b[i][j]);
}
}
for(i=0; i<m; i++)
{
for(j=0;j<n;j++)
{
c[i][j]=a[i][j] +b[i][j];
}
}
printf("\n Resultant Matrix C ");
for(i=0; i<m; i++)
{
for(j=0;j<n;j++)
{
printf(" %d ", c[i][j]);
}
printf("\n");
}
}
else
printf("\n Addition is not possible");
}
C program to implement MULTIPLICATION OF TWO MATRICES
In order to find matrix multiplication, the columns of first matrix must be equal to rows of second matrix.
#include<stdio.h>
void main()
{
int m,n,p,q;
int i,j,k;
in a[100][100],b[100][100],c[100][100];
printf("Enter the order of matrx A ");
scanf("%d%d",&m,&n);
printf("Enter the order of matrx B ");
scanf("%d%d",&p, &q);
if (n = = p)
{
printf("\n Matrix Multiplication is possible ");
printf("\n Enter elements of matrix A ");
for(i=0; i<m; i++)
{
for(j=0;j<n;j++)
{
scanf("%d", &a[i][j]);
}
}
printf("\n Enter elements of matrix B ");
for(i=0; i<p; i++)
{
for(j=0;j<q;j++)
{
scanf("%d", &b[i][j]);
}
}
for(i=0; i<m; i++)
{
for(j=0;j<n;j++)
{
c[i][j]=0;
for(k=0;k<n;k++)
{
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
}
}
printf("\n Resultant Matrix C ");
for(i=0; i<m; i++)
{
for(j=0;j<q;j++)
{
printf(" %d ", c[i][j]);
}
printf("\n");
}
}
else
printf("\n Matrix Multiplication is not possible");
}
C program to find length of a string without using built in function
#include<stdio.h>
void main()
{
char str[50];
int length=0;
printf("Enter a string ");
scanf("%s",str);
for(i=0; str[i]!='\0' ; i++)
{
length=length+1;
}
printf("\n String length is %d", length);
}
C program to read and display N students information (Roll No, Name, Average Marks) using arrays of structure.
#include<stdio.h>
struct student
{
int rno;
char name[50];
float avg;
};
void main()
{
struct student s[50];
int n, i;
printf("Enter number of students ");
scanf("%d", &n);
printf("\n Enter roll number, name and average marks of %d students", n);
for(i=0;i<n;i++)
{
scanf("%d %s %f",&s[i].rno, s[i].name,&s[i].avg);
}
printf("\n Student Details \n");
for(i=0;i<n;i++)
{
printf ("\n %d %s %f", s[i].rno, s[i].name, s[i].avg);
}
}
C program to swap two numbers using pointers and functions.
#include<stdio.h>
void swap(int *x, int *y);
void main()
{
int x=7, y=3;
printf("\n Before Swap \n");
printf("x=% y=%d",x,y);
swap(&x, &y);
printf("\n After Swap \n");
printf("x=% y=%d",x,y);
}
void swap(int *x, int *y)
{
int temp;
temp=*x;
*x=*y;
*y=temp;
}
Note: Do not forget to send Feedback/Comments.
I upload other programs shortly......
-
Module wise most expected questions on " Unix and Shell Programming " Module-1 1. Explain in brief about " UNIX Arc...
-
Module 4: Laboratory Component: M4/L2 Java code to solve Travelling Sales Person problem using Dynamic programming. import java.ut...
-
Design and implement the presence of Hamiltonian Cycle in an undirected Graph G of n vertices. import java.util.*; cl...
-
Module-4 Laboratory Component: Write Java program to solve 0/1 Knapsack problem using Dynamic Programming method. import java.util.S...
-
Dear students, You are hereby informed to follow the following instructions to get good marks in Practical Examinations. Wear the formal and...