Tricks to solve the O level Practical paper

Quick revision of all o level exam and practical with solved c language last 10 years paper book released  at now on amzon buy now this book...

ONLY FOR DIRECT STUDENT


IF YOUR PROJECT NOT SUBMIT THEN DON'T WORRY SEND YOUR NIELIT I'D CARD


TO MY WHATSAPP NUMBER--8299417586 AND I WILL SEND YOU PROJECT FREE .. 


This book is the fourth edition of the series of 'O' level exams.

This book covers all the 'O' level exam with C language Practical i.e --

M1-R4: IT TOOLS & BUSINESS SYSTEMS
M2-R4: INTERNET TECHNOLOGY AND WEB DESIGN
M3- R4: C LANGUAGE
M4-R4: ICT RESOURCE
C Programs and Practical Question - (Hands Written Notes Of Previous Year Solved paper )

This book is made of most Important topic with complete details that has been asked in 'O' level Exam at the last 10 years. After reading this book you will not need to read any other books.


Write a ‘C’ program to list of keywords which must be sorted in increasing order in the table.
#include<stdio.h>
int power(int,int);
void main()
{

     char keyword[][15]={"char","do","extern","if","return","static","union","while","case","default","enum","goto","register","
sizeof",
            "typedef","volatile","break","continue","else","for","long","signed","switch","void","auto","const","double",
             "float","int","short","struct","unsigned"};
     int i,j;
     char tmp[15];
     printf("\nUnsorted Keyword Array\n\n");
     for(i=0;i<32;i++)
          printf("[%s] ",keyword[i]);

     for(i=0;i<32;i++)
     {
          for(j=0;j<32-i-1;j++)
          {
               if(strcmp(keyword[j],keyword[j+1])>0)
               {
                    strcpy(tmp,keyword[j]);
                    strcpy(keyword[j],keyword[j+1]);
                    strcpy(keyword[j+1],tmp);
               }
          }
     }
     printf("\n\nSorted Keyword Array\n\n");
     for(i=0;i<32;i++)
          printf("[%s] ",keyword[i]);
}

Write  a C program to write a line of string at a text file

#include <stdio.h>
#include <stdlib.h>  /* For exit() function */
int main()
{
   char sentence[1000];
   FILE *fptr;

   fptr = fopen("program.txt", "w");
   if(fptr == NULL)
   {
      printf("Error!");
      exit(1);
   }
  
   printf("Enter a sentence:\n");
   gets(sentence);

   fprintf(fptr,"%s", sentence);
   fclose(fptr);
   return 0;
}
Dangling Pointer with example
A pointer pointing to a memory location that has been deleted (or freed) is called dangling pointer.




Wild Pointer with example
A pointer which has not been initialized to anything (not even NULL) is known as wild pointer. The pointer may be initialized to a non-NULL garbage value that may not be a valid address.
int main()
{
    int *p;  /* wild pointer */
  
    int x = 10;
  
    // p is not a wild pointer now
    p = &x;
  
    return 0;
}
Write a function which accepts an array of size n containing integer values and returns average of all values. Call the function from main program.

#include<stdio.h>

int avg(int [],int);

main()
{
    int a[100], n,i,avrg;
    printf("\nEnter number of terms=");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    avrg=avg(a,n);
    printf("\nThe average=%d",avrg);
}
int avg(int a[],int n)
{
    int i,s=0;
    for(i=0;i<n;i++)
    {
        s=s+a[i];
    }
    return s/n;

#include<stdio.h>
#include<conio.h>
int avg(int[],int);
void main()
{
     int ar[5],i;
     clrscr();
     for(i=0;i<5;i++)
     {
          printf("Enter %d number
>> ",i+1);
          scanf("%d",&ar[i]);
     }
     printf("\n\tAverage = %d",avg(ar,5));
     getch();
}
int avg(int ar[],int s)
{
     int i=0,sum=0;
     for(i=0;i<s;i++)
          sum+=ar[i];
     return(sum/s);;

}


Write a function which accepts an array of size n containing integer values and returns average of all values. Call the function from main program.

#include<stdio.h>

int avg(int [],int);

main()
{
    int a[100], n,i,avrg;
    printf("\nEnter number of terms=");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    avrg=avg(a,n);
    printf("\nThe average=%d",avrg);
}
int avg(int a[],int n)
{
    int i,s=0;
    for(i=0;i<n;i++)
    {
        s=s+a[i];
    }
    return s/n;

#include<stdio.h>
#include<conio.h>
int avg(int[],int);
void main()
{
     int ar[5],i;
     clrscr();
     for(i=0;i<5;i++)
     {
          printf("Enter %d number
>> ",i+1);
          scanf("%d",&ar[i]);
     }
     printf("\n\tAverage = %d",avg(ar,5));
     getch();
}
int avg(int ar[],int s)
{
     int i=0,sum=0;
     for(i=0;i<s;i++)
          sum+=ar[i];
     return(sum/s);;

}

Write a function to display the multiplication table of the number.
#include<stdio.h>
void table(int);
void main()
{
     int i;
     printf("Enter number>> ");
     scanf("%d",&i);
     table(i);
    

}
void table(int n)
{
     int i;
     for(i=1;i<=10;i++)
          printf("\n%d*%d=%d",n,i,n*i);

}

Write a program to determine the sum of the following series:
    S = 1 – 3 + 5 – 7 + ...(n terms)

#include<stdio.h>

main()
{
    int n, s=0,i,sign=1;
    printf("\nEnter value of n=");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        s=s+sign*(2*i-1);    
        sign=sign*(-1);
    }
    printf("\nThe sum of the series=%d",s);
}

Write a function that returns 1 if the two matrices passed to it as argument are equal and 0 otherwise
#include<stdio.h>

int IsEqual(int [][100],int,int, int[][100],int,int);
main()
{
    int m1[100][100],m2[100][100],r1,r2,c1,c2,i,j;
    printf("\nEnter row and column number of the first matrix=");
    scanf("%d%d",&r1,&c1);
    printf("\nEnter the elements of the first matrix\n");
    for(i=0;i<r1;i++)
    {
        for(j=0;j<c1;j++)
        {
            scanf("%d",&m1[i][j]);
        }
    }
    printf("\nThe first matrix\n");
    for(i=0;i<r1;i++)
    {
        for(j=0;j<c1;j++)
        {
            printf("%6d",m1[i][j]);
        }
        printf("\n");
    }
    printf("\nEnter row and column number of the second matrix=");
    scanf("%d%d",&r2,&c2);
    printf("\nEnter the elements of the first matrix\n");
    for(i=0;i<r2;i++)
    {
        for(j=0;j<c2;j++)
        {
            scanf("%d",&m2[i][j]);
        }
    }
    printf("\nThe second matrix\n");
    for(i=0;i<r2;i++)
    {
        for(j=0;j<c2;j++)
        {
            printf("%6d",m2[i][j]);
        }
        printf("\n");
    }
    if(IsEqual(m1,r1,c1,m2,r2,c2)==1)
        printf("\nThe matrices are equal");
    else
        printf("\nThe matrices are not equal");
}

int IsEqual(int a[][100],int r1,int c1, int b[][100],int r2,int c2)
{
    int i,j;
    if(r1!=r2 || c1!=c2)
        return 0;
    for(i=0;i<r1;i++)
    {
        for(j=0;j<c1;j++)
        {
            if(a[i][j]!=b[i][j])
            {
                return 0;
            }
        }
    }
    return 1;

}

Write a program to copy a file into another file.
#include <stdio.h>
main()
{
    FILE *fp1, *fp2;
    char ch;
    fp1 = fopen("abc.txt", "r");
    fp2 = fopen("xyz.txt", "w");
    while((ch = getc(fp1)) != EOF)
        putc(ch, fp2);
    fclose(fp1);
    fclose(fp2);
    getch();
}

using a switch statement, write a function to count the number of vowels and number of blanks
in a character array passed to it as an argument.
#include<stdio.h>
#define MAX 20
void count(char*);
void main()
{
     char ch[MAX];
     printf("\n\tEnter String>> ");
     gets(ch);
     count(ch);
}
void count(char *str)
{
     int i,vowel=0,blank=0;
     for(i=0;str[i]!='\0';i++)
     {
           switch(str[i])
           {
                case 'a':
                case 'A':
                case 'e':
                case 'E':
                case 'i':
                case 'I':
                case 'o':
                case 'O':
                case 'u':
                case 'U':
                      vowel++;
                      break;
                case ' ':
                      blank++;
                      break;
           }
     }
     printf("\n\tVowel=%d\n\tBlank=%d",vowel,blank);
}

Write a program to display all the prime numbers between two positive integers m and n. The values of m and n are to be taken from the user.
Solution : 

#include<stdio.h>
void main()
{
     int n,m,p;
     printf("Enter range starting number>> ");
     scanf("%d",&m);

     printf("Enter range ending number>> ");
     scanf("%d",&n);
     if(m>n)
           printf("\n\tRange start should be less than range end");
     else
     {
           while(m<=n)
           {
                p=2;
                while(p<m)
                {
                      if(m%p==0)
                           break;
                      p++;

                }
                if(p==m)
                      printf("\t%d",p);
                m++;
           }
     }
}

Write a C program to read a line and print it reverse using recursive function.
Solution : 

#include<stdio.h>
#include<string.h>
#include<process.h>
void print(int len,char str[])
{
 int n=len;
 if(n==-1)
  exit(1);
 else
 {
  printf("%c",str[n]);
  print(n-1,str);
 }
}
void main()
{
 char ch[100];
 int len,i;
 printf("Enter a line>> ");
 gets(ch);
 len=strlen(ch);
 print(len,ch);

}

Write a C program to read a line and print it reverse using recursive function.
Solution : 

#include<stdio.h>
#include<string.h>
#include<process.h>
void print(int len,char str[])
{
 int n=len;
 if(n==-1)
  exit(1);
 else
 {
  printf("%c",str[n]);
  print(n-1,str);
 }
}
void main()
{
 char ch[100];
 int len,i;
 printf("Enter a line>> ");
 gets(ch);
 len=strlen(ch);
 print(len,ch);

}

Write a C program to modify the constant variable.
Solution : 

#include<stdio.h>
void main()
{
 const int a=1;
 int *p;
 p=&a;
 printf("\n%d",a);
 *p=2;
 printf("\n%d",a);
}

Write a program to calculate number of vowels (a, e, i, o, u) separately in the entered string.
#include<stdio.h>
#include<conio.h>
void main()
{
     char ch[200];
     int a,e,i,o,u,index;
     a=i=o=u=e=0;
     clrscr();
     printf("Enter your string>> ");
     gets(ch);
     for(index=0;ch[index]!='\0';index++)
     {
           switch(ch[index])
           {
                case 'a' :
                     a++;
                     break;
                case 'A' :

                     a++;
                     break;

                case 'e':
                     e++;
                     break;
                case 'E':
                     e++;
                     break;

                case 'o':
                     o++;
                     break;
                case 'O':
                     o++;
                     break;

                case 'i':
                     i++;
                     break;
                case 'I':
                     i++;
                     break;

                case 'u':
                     u++;
                     break;
                case 'U':
                     u++;
                     break;

           }
     }
     printf("\nVowel frequency\nA=%d\nE=%d\nI=%d\nO=%d\nU=%d",a,e,i,o,u);
     getch();


}


Comments

Popular posts from this blog

Notepad, Wordpad and Paint

O LEVEL- INTERNET TECHNOLOGY & WEB DESIGN

O LEVEL- INTERNET TECHNOLOGY & WEB DESIGN