Posts

Showing posts from July, 2020

Count the no of lowercase letters in a text file bca.txt in C

Image
Write a program in C to count the no of lowercase letters in a text file bca.txt This program reads one character at a time by using fgetc() function until the EOF (end of file) returns. Then it checks whether the current character is lowercase or not. If it is a lowercase letter it increments the value of c by 1. It also displays the contents of file named bca.txt. And finally print the total number of lowercase letters present in the file, which is the main purpose to write the program Program #include<stdio.h> #include<conio.h> void main()  {   FILE *fptr;   char ch;   int c=0;   if((fptr=fopen("bca.txt","r"))==NULL)    printf("File doesn't exist\n");   else    {     while((ch=fgetc(fptr))!=EOF)      {       if(ch>=97&&ch<=122) c++;       printf("%c",ch);      }    }    printf("\nTotal lowercase letter in bca.txt file is %d",c);   fclose(fptr);  } Sample Text (bca.txt) My name is Gaurav Pali. My higher

Input Function In Python

Image
Input Function In Python TRY THE FOLLOWING COMMANDS ONE BY ONE print("Enter your name") name=input() print("My name is "+name)   name=input("Enter your name") print("My name is "+name)   name=input("Enter your name\n") print("My name is "+name)   a=input("Enter a Number") print(a)   a=input("Enter a Number\n") print("Value of a is "+a)   a=input("Enter First Number\n") b=input("Enter Second Number\n") c=a+b print("Sum of a and b is "+c)   a=int(input("Enter First Number\n")) b=int(input("Enter Second Number\n")) c=a+b print("Sum of a and b is "+c)   a=int(input("Enter First Number\n")) b=int(input("Enter Second Number\n")) c=a+b print("Sum of a and b is "+str(c))   a=float(input("Enter First Number\n")) b=float(input("Enter Second Number\n")) c=a+b print("Sum of a and b is "+str(

Write A Program To Perform The Addition Of 3x3 Matrices Using An Array

Image
M3-R4 O-Level Jan-20 Subjective Type M3-R4 : PROGRAMMING & PROBLEM SOLVING THROUGH ‘C’ LANGUAGE PART-2 /*Write a program to perform the addition of 3x3 matrices using an array*/ /* M3-R4 Q-6(B)*/ #include<stdio.h> #include<conio.h> void main()  {   int mat1[3][3],mat2[3][3],mat3[3][3]; /*Declare 3 Matrices of 3X3*/   int i,j;   clrscr();   printf("Enter the elements in matrix 1\n");   for(i=0;i<3;i++)    for(j=0;j<3;j++)     scanf("%d",&mat1[i][j]);    printf("Enter the elements in matrix 2\n");   for(i=0;i<3;i++)    for(j=0;j<3;j++)     scanf("%d",&mat2[i][j]);  /*Perform addition of matrix 1 and matrix 2 */   for(i=0;i<3;i++)    for(j=0;j<3;j++)     mat3[i][j]=mat1[i][j]+mat2[i][j];   printf("Result after addition of matrix 1 and matrix 2\n");   for(i=0;i<3;i++)    {     for(j=0;j<3;j++)     printf("%d ",mat3[i][j]);     printf("\n");    }   getch();  } To read a

Write A Program in C To Swap Two Numbers Without Using Third Variable

Image
Write A Program in C To Swap Two Numbers Without Using Third Variable M3-R4 O-Level Jan-20  Subjective Programming Based Question M3-R4 : PROGRAMMING & PROBLEM SOLVING THROUGH ‘C’ LANGUAGE PART-1 To read about click on the following link Write A Program To Find Factorial Of Given Number Using Recursive Function https://learncomputerpci.blogspot.com/2020/07/write-program-to-find-factorial-of.html#more First Method /*Write A Program in C To Swap Two Numbers Without Using Third Variable */ #include<stdio.h> #include<conio.h> void main()  {   int num1,num2;   clrscr();   printf("Enter first number\n");   scanf("%d",&num1);   printf("Enter Second number\n");   scanf("%d",&num2);   /*you can also use scanf("%d%d",&num1,&num2) to input num1 and num2 */   printf("Before Swapping num1=%d and num2=%d\n",num1,num2);   /* Let num1=10 and num2=20 */   num1=num1+num2;    /* Value of num1 will be updated

Write A Program To Find Factorial Of Given Number Using Recursive Function

Image
Write A Program To Find Factorial Of Given Number Using Recursive Function M3-R4 O-Level Jan-20 Subjective Programming Based Question 8 (A) M3-R4 : PROGRAMMING & PROBLEM SOLVING THROUGH ‘C’ LANGUAGE PART-1 Note: To read about   M3 R4 O-Level Jan-20 MCQ https://learncomputerpci.blogspot.com/2020/07/m3-r4-o-level-jan-20-mcq-with-answers.html M3 R4 O-Level Jan-20 TRUE OR FALSE https://learncomputerpci.blogspot.com/2020/07/m3-r4-o-leveljan-20-true-or-false-m3.html M3 R4 O-Level Jan-20 MATCH THE FOLLOWING https://learncomputerpci.blogspot.com/2020/07/m3-r4-o-leveljan-20-match-following-m3.html M3 R4 O-Level Jan-20 FILL IN THE BLANKS https://learncomputerpci.blogspot.com/2020/07/m3-r4-o-level-jan-20-fill-in-blanks.html

Write a program in C to check whether the number is prime or not.

Image
/*Write a program in C to check whether the number is prime or not.*/ /*Note: Prime numbers are those numbers which is divisible by 1 or itself */ /* Solution 1: */ #include<stdio.h> #include<conio.h> void main()  {    int num,i=2;        /* Variables Declaration of integer type num and i  and             initialize the value of i*/    clrscr();                        /* Function to clear the console screen */    printf("Enter a number\n");  /* General message for the user */    scanf("%d",&num);      /* Input a number by the user/through the keyboard*/    while(i<num)              /* Starting of while loop */         {       if(num%i==0)        /* Check whether the input number is divisible by i */        {          printf("%d is not a prime number",num); /* Print message if num is                     divided  by current value of i */          break;  /* If the above condition matches, it comes out from the loop */        }       i++;

M3-R4 O-Level Jan-20 FILL IN THE BLANKS

Image
M3-R4 O-Level Jan-20 FILL IN THE BLANKS M3-R4: PROGRAMMING & PROBLEM SOLVING THROUGH ‘C’ LANGUAGE PART-1   4. Each statement below has a blank space to fit one of the word(s) or phrase(s) in the list below. Enter your choice in the “OMR” answer sheet supplied with the question paper,following instructions therein (1x10=10)   A. New line B. Increment C. sizeof D. Overlooking E. Bell F math.h G. Dot H. Structured I islower() J. And K. Union L. Link M. &&           4.1 C language was implemented at the __________ laboratories. 4.2 C language is well suited for __________ programming. 4.3 The operator "++'' is known as __________ operator. 4.4 The __________

M3-R4 O-Level Jan-20 MATCH THE FOLLOWING

Image
M3-R4 O-Level Jan-20 MATCH THE FOLLOWING M3-R4: PROGRAMMING & PROBLEM SOLVING THROUGH ‘C’ LANGUAGE PART-1 Note:   To read about  M3-R4 O-Level Jan-20 FILL IN THE BLANKS Click on the following link: https://learncomputerpci.blogspot.com/2020/07/m3-r4-o-level-jan-20-fill-in-blanks.html 3.      Match words and phrases in column X with the closest related meaning/ word(s)/phrase(s) in column Y. Enter your selection in the "OMR" answer sheet supplied with the question paper, following instructions therein. (1x10=10)   X Y 3.1 It is an unconditional jump statement. A. Exit controlled loop 3.2 Function that concatenate strings. B. Shift Left 3.3 It is used to link the related expression together. C. sizeof 3.4 Symbol ‘=’ D. Character test function 3.5 getw() E.

M3-R4 O-Level Jan-20 TRUE Or FALSE

Image
M3-R4 O-Level Jan-20 TRUE Or FALSE M3-R4: PROGRAMMING & PROBLEM SOLVING THROUGH ‘C’ LANGUAGE PART-1   Note:   To read about  M3-R4 O-Level Jan-20 MATCH THE FOLLOWING Click on the following link: https://learncomputerpci.blogspot.com/2020/07/m3-r4-o-leveljan-20-match-following-m3.html 2. Each statement below is either TRUE or FALSE. Choose the most appropriate one and ENTER in the “OMR” answer sheet supplied with the question paper, following instructions therein. (1x10=10)   2.1 In C, upper and lower cases letter are same. Answer: False 2.2 = is used for comparison, whereas, == is used for assignment of two quantities. Answer: False 2.3 A function can be defined inside another function. Answer: False 2.4 In switch statement, the default case is optional. Answer: True 2.5 strlen() function counts the number of characters in a given string and returns      the integer value. Answer: True 2.6 The continue statement cannot be used with switch statement. Answer:  True 2