Problem Solving Through Programming in C Week 7: Programming Assignments Jan-Jun 2022

   NPTEL PROGRAMMING ASSIGNMENTS


Problem Solving Through Programming in C

Week-07: Program-01

Due Date of Submission 2022-03-17, 23:59 IST
Write 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);

 

 


   printf("Uppercase Letters : %d\n", upper); /*prints number of uppercase letters */
   printf("Lowercase Letters : %d", lower); /*prints number of lowercase letters */
 
   return (0);
}




Week-07 Program-02

Due Date of Submission 2022-03-17, 23:59 IST
Write a C program to find the sum of all elements of each row of a matrix.
 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

Due Date of Submission 2022-03-17, 23:59 IST
Write a C program to find subtraction of two matrices i.e. matrix_A  - matrix_B = matrix_C.
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

Due Date of Submission 2022-03-17, 23:59 IST
Write a C program to print Largest and Smallest Word from a given sentence. If there are two or more words of same length, then the first one is considered. A single letter in the sentence is also consider as a word.

#include<stdio.h>
#include<string.h>
int main()
{
    char str[100]={0},substr[100][100]={0};  
scanf("%[^\n]s", str);


 

 


Post a Comment (0)
Previous Post Next Post