Pages

Wednesday, 19 September 2012

Modal Question and Programming C Language

Practical Question paper of C Language

Loop


Miscellaneous

One Dimension Practical model question paper

Q 1. Write a  program to shift array element with previous one (Left-Sifting) . Last element will replace with first element ?

Q 2. Write a program to count even and odd number in an array?

Q 3.Write a program to make three array name mArry, even & odd move array value in even & odd array respect to this type ?

Q 4.Write a program to find smallest and highest number from an array?

Q 5. Write a program to print an array in reverse order?

Q 6. Write a program to print only consecutive number of an array?

Q 7. Write a program to implement union and intersection?

Q 8. Write a program to merge two array into a single array?

Q 9.Write a program to spilt an array into two equal parts ?

Q 10. Write a program to input Fibonacci into array?

Q 11.Write a program to find out prime number between given range and saved these number into array. Range should be up-to 1 to 10000 ?

Q 12.Write a program to input 10 numbers and print each element with multiply by its equivalent index position?

Q 13. Write a program to print an array value without using loop ?

Q 14.Write a program search a number in array ?

Q 15.Write a program to print an array value skip by one index?

Q 17. Write a program to input ASCII value and print its equivalent character.Using 7 bit ASCII/

One Dimension Character Array  Programs

1. Write a program to count Vowels and consonant?

2. Write a program to count no. of word in an array?

3. Write a program to convert lower case character into upper case

4. Write a program to print only consecutive appeared character

5. Write a program to implement concatenation?

6.  Write a program to implement substring function type functionality without using library function.

7. Write a program to input small letter if capital letter is there ignore that

8. Write a program accept any case input and convert it small case

9. Write a program input character only and display error message on any other input?

10. Write a program to search a substring and print its index

11. Write a program to search a word and reverse that

12. Write a program implement encryption i.e. change each character to two character forward. i.e.   A-> C,B->E

13. Write a program to implement following format
              G                                              GIRFA
              GI                                             GIRF
              GIR                                          GIR
              GIRF                                        GI
              GIRFA                                     G

14. Write a program to implement abbreviation i.e.
Input : Ashok Kumar Yadav
Output : A.K. Yadav

15. Write a program to implement find and replace all functionality

16. Write a program to check whether a string is palindrome or  not

17. Write a program reverse a string

18. Write a program to reverse each word into array

19. Write a program to input string password. i.e.(A Small and Capital character , A number and a special symbol)

20. Write a program to check validity of an email address. (an email can have only one @ symbol after that . is required and no space is allowed)

21. Write a program count frequency of each character individually.
22. Write a program to convert number to word?
   i.e.    123
            One Hundred Three Only


Prime Number

#include<stdio.h>
void main()
{
int i,j,k;
printf("Enter number>> ");
scanf("%d",&i);
j=2;
while(j<i)
{
if(i%j==0)
break;
j++;
}
if(i==j)
printf("Prime");
else
printf("Not Prime");
}

Reverse A number

#include<stdio.h>
void main()
{
int i,j,k,m=0;
printf("Enter number>> ");
scanf("%d",&i);
k=i;
while(i>0)
{
j=i%10;
i=i/10;
m=m*10+j;

}
printf("Reverse number is %d",m);
}
Armstrong Number

void main()
{
int i,j,k,m=0;
printf("Enter number>> ");
scanf("%d",&i);
k=i;
while(i>0)
{
j=i%10;
i=i/10;
m=m+j*j*j;

}
if(k==m)
printf("\nArmstrong");
else
printf("\nNot Armstrong");
}

Fibonacci Series


#include<stdio.h>
void main()
{
   int a,b,c;
  c=1;
  a=0;
  b=0;
   while(c<200)
   {
   a=b;
   b=c;
  c=a+b;
  printf("%d\t",a);
   }
}

Factorial number using Recursive function

       #include<stdio.h>
       int fact(int n)
      {
   if(n==0)
  return(1);
   else
  return(n*fact(n-1));
      }
      void main()
     {
    int a;
    printf("enter a number>> ");
    scanf("%d",&a);
    printf("\n\tFactorial=%d",fact(a));
    }
Print your name without using semicolon

     #include<stdio.h>
     void main()
    {
       if(printf("Hello Girfa"))
          {
          }
    }

Palindrome

A palindrome is a word, phrase, number, or other sequence of units that may be read the same way in either direction, with general allowances for adjustments to punctuation and word dividers.

/* Without Using Library function */
void main()
{
    char nm1[20],nm2[20];
    int i,j;
    printf("Enter your text>> ");
    gets(nm1);
       for(i=0;nm1[i]!='\0';i++);
    /* Assine first string in second in reverse order */
      for(i--,j=0;i>=0;i--,j++)
        nm2[j]=nm1[i];

    /* Checking whether both're same or not */
       for(i=0;nm1[i]!='\0';i++);
    for(j=0;nm1[j]==nm2[j] && nm1[j]!='\0';j++);
    if(j==i)
        printf("Palindrom");
    else
        printf("Not Palindrom");
}

/* Using Library String.h function
void main()
{
    char nm1[20],nm2[20];
    int i,j;
    printf("Enter your text>> ");
    gets(nm1);
    strcpy(nm2,nm1);
    strrev(nm2);
    if(strcmp(nm1,nm2)==0)
        printf("Palindrom");
    else
        printf("Not Palindrom");
  }

Multiplication of 2D Array (Matrix)

#include<stdio.h>
#define row 2
#define col 2
void main()
{
/* *********Multiplication Rule ***********
  First Arrar Column must be same as Second Array row
  otherwise multiplication can't take place
  By Girfa
*/
int a[row][col],b[row][col],cc[row][col],r,c,k,sum=0;
clrscr();
printf("\n*****Enter Data for first Array*****\n");
for(r=0;r<2;r++)
{
for(c=0;c<2;c++)
{
printf("Enter [%d][%d]'st number>>  ",r+1,c+1);
scanf("%d",&a[r][c]);
}
}
printf("\n*****Enter Data for Second Array*****\n");
for(r=0;r<2;r++)
{
for(c=0;c<2;c++)
{
printf("Enter [%d][%d]'st number>>  ",r+1,c+1);
scanf("%d",&b[r][c]);
}
}
for(r=0;r<2;r++)
{
for(c=0;c<2;c++)
{
cc[r][c]=0;
}
}
for(r=0;r<2;r++)
{
for(c=0;c<2;c++)
{

  for(k=0;k<2;k++)
  {
sum=sum+a[r][k]*b[k][c];
  }
  cc[r][c]=sum;
  sum=0;
}
}
clrscr();
printf("\n***** first Array*****\n");
for(r=0;r<2;r++)
{
for(c=0;c<2;c++)
{
printf("\t%d",a[r][c]);
}
printf("\n");
}
printf("\n***** Second Array*****\n");
for(r=0;r<2;r++)
{
for(c=0;c<2;c++)
{
printf("\t%d",b[r][c]);
}
printf("\n");
}
printf("\n***** Result *****\n");
for(r=0;r<2;r++)
{
for(c=0;c<2;c++)
{
printf("\t%d",cc[r][c]);
}
printf("\n");
}
getch();

No comments:

Post a Comment