NPTEL PROGRAMMING ASSIGNMENTS
Problem Solving Through Programming in C
Week-07: Program-01
Due Date of Submission 2022-03-17, 23:59 ISTWrite a C Program to Count Number of Uppercase and Lowercase Letters in a given string. The given string may be a word or a sentence.
#include<stdio.h>int main() { int upper = 0, lower = 0; char ch[100]; scanf(" %[^\n]s", ch);
Week-07 Program-02
Example: For a matrix
4 5 6
6 7 3
1 2 3
The output will be
15
16
6
#include <stdio.h>
int main()
{
int matrix[20][20];
int i,j,r,c;
scanf("%d",&r); //Accepts number of rows
scanf("%d",&c); //Accepts number of columns
for(i=0;i< r;i++) //Accepts the matrix elements from the test case data
{
for(j=0;j< c;j++)
{
scanf("%d",&matrix[i][j]);
}
}
Week-07 Program-03
If the given matrix are
2 3 5 and 1 5 2
4 5 6 2 3 4
6 5 7 3 3 4
Then the output will be
1 -2 3
2 2 2
3 2 3
(The elements of the output matrix are separated by one blank space)
#include <stdio.h>
int main()
{
int matrix_A[20][20], matrix_B[20][20], matrix_C[20][20];
int i,j,row,col;
scanf("%d",&row); //Accepts number of rows
scanf("%d",&col); //Accepts number of columns
for(i=0; i<row; i++)
{
for(j=0; j<col; j++)
{
scanf("%d", &matrix_A[i][j]);
}
}
for(i=0; i<row; i++)
{
for(j=0; j<col; j++)
{
scanf("%d", &matrix_B[i][j]);
}
}
Week-07 Program-04