1. Question:How to pass two dimensional array to a function in c 

    Answer
    #include <stdio.h>
    #define M 3
    #define N 5
    void fstore2D(int a[][N]);
    void fretrieve2D(int a[][N]);
    int main(){
      int a[M][N];
      printf("Input data in matrix (%d X %d)\n", M, N);
      fstore2D(a);
      fretrieve2D(a);
      return 0;
    }
    void fstore2D(int a[][N]){
        int i, j;
        for (i = 0; i < M; ++i){
        for (j = 0; j < N; ++j)
             scanf("%d", &a[i][j]);
        }
    }
    void fretrieve2D(int a[][N]){
       int i, j;
       for ( i = 0; i < M; ++i ){
           for ( j = 0; j < N; ++j)
                printf("%6d ", a[i][j]);
           printf("\n");
       }
    }






    1. Report
  2. Question:Write a c program which takes password from users 

    Answer
    #include<stdio.h>
    #define MAX 500
    
    int main(){
    
        char password[MAX];
        char p;
        int i=0;
    
        printf("Enter the password:");
       
        while((p=getch())!= 13){
             password[i++] = p;
             printf("*");
        }
    
        password[i] = '\0';
        if(i<6)
             printf("\nWeak password");
        printf("\nYou have entered: %s",password);
        return 0;
    }
    Sample output: Enter the password:******* You have entered: fgt67m,






    1. Report
  3. Question:Write a scanf function in c programming language which accept sentence from user 

    Answer
    #include<stdio.h>
    #define MAX 500
    
    int main(){
    
        char arr[MAX];
    
        printf("Enter any sentence which can include spaces.\n");
        printf("To exit press enter key.\n");
        scanf("%[^\n]s",arr);
    
        printf("You had entered: \n");
        printf("%s",arr);
    
        return 0;
    }
    Sample output: Enter any sentence which can include spaces. To exit press enter key. May I help you? You had entered: May I help you?






    1. Report
  4. Question:Write a scanf function in c programming language which accept paragraph from users 

    Answer
    #include<stdio.h>
    #define MAX 500
    
    int main(){
    
        char arr[MAX];
    
        printf("Enter any paragraph which can include spaces or new line.\n");
        printf("To exit press the tab key.\n");
        scanf("%[^\t]s",arr);
    
        printf("You had entered: \n");
        printf("%s",arr);
    
        return 0;
    }
    Sample output: Enter any paragraph which can include spaces or new line. To exit, press the tab key. C is powerful language. I am learning c from cquestionbank.blogspot.com You had entered: C is powerful language. I am learning c from cquestionbank.blogspot.com






    1. Report
  5. Question:Print prime numbers between 1-300 using break and continue in c 

    Answer
    #include <math.h>
    #include <stdio.h>
    main(){
      int i, j;
      i = 2;
      while ( i < 300 ){
         j = 2;
         while ( j < sqrt(i) ){
             if ( i % j == 0 )
                break;
             else{
                ++j;
                continue;
             }
          }
          if ( j > sqrt(i) )
                printf("%d\t", i);
          ++i;
      }
      return 0;
    }






    1. Report
Copyright © 2025. Powered by Intellect Software Ltd