About Me

My photo
Vijayapur, Karnataka, India
I am interested in Teaching.

Tuesday 7 January 2020

Module Wise Important Questions on "C for Problem Solving " for first and second semester B.E. Examination (VTU, Belagavi)

Module-1

Block diagram of a computer with explanation of each part in brief.

List of input devices with explanation in brief about each.

List of output devices with explanation in brief about each.

Generations of Computers

Types of Computers

What is computer network? list its advantages.

Write differences between LAN, WAN and MAN

Discuss network topologies (bus, star, ring and mesh) with diagram and examples.

Do not forget to send feedback or comment.

Module-2

Structure of a c program with programming example.

C-tokens (list and explain in brief)

What is identifier? Discuss rules for defining identifiers with valid and invalid examples for each rule.

What is variable? Discuss its declaration and initialization with syntax and examples.

What are formatted input and output functions(scanf and printf)? Discuss with syntax and examples.

What are unformatted input and output functions? Discuss with syntax and examples.

List and discuss the following operators with explanation and examples.

Arithmetic
Relational
Logical
increment and decrement
Conditional operator
Bitwise operators
Special operators (comma and sizeof)

What is typecast(type conversion)? Discuss implicit and explicit type conversions with examples.

Write c programs for following.

To find simple interest (algorithm, flowchart, pesudocode, program)

To find area and circumference of a circle (algorithm, flowchart, pseudocode, program)

To find area and perimeter of rectangle.

To find area of triangle by reading breadth and height of it.

To find area of triangle by reading 3 sides of it (a,b,c)

To swap to values using temporary variable.

To swap to values without using temporary variable.

Do not forget to send feedback or comment.

Module-3

Discuss the following conditional(decision making/selection/branching) statements with syntax, flowchart and examples.
simple if
if else
nested if
else if ladder
switch

Discuss the following loop statements with syntax, flowchart and examples.
while
do while
for

Write differences between while and do while statements.

Write differences between break and continue statements.

Discuss the following storage classes used in C with examples.

automatic variables
global variables
static variables
register variables

Programs:
To check for leap year
To check, whether the number N is even or odd number.
To check, whether the number is PALINDROME or not.
To find factorial of N
GCD and LCM using Euclid's algorithm.
To print first N fibonacci numbers.

Do not forget to send feedback or comment.

Module-4

What is one dimensional array? Discuss its declaration and initialization with syntax and examples.

What is two dimensional array? Discuss its declaration and initialization with syntax and examples.

What is string? Discuss its declaration and initialization with syntax and examples.

Discuss all string handling functions with syntax and examples.

Programs:
Bubble sort
Linear search
Binary search
Sum and Avg of N numbers
Find maximum and minimum of N numbers

Do not forget to send feedback or comment.

Module-4

Discuss the 3 elements of user defined functions with syntax and examples.

Discuss categories of function with examples.

What are actual and formal parameters?Discuss with examples.

Discuss parameter passing mechanism. (call by value and call by reference)

What is recursive function?Give example.

Programs:
Function to check for prime number.
Function to find length of a string.


Do not forget to send feedback or comment.

Module-5

What is structure?Discuss declaration of structure and structure variable with syntax and examples.

What is array of structure?Give programming example.

What is nested structure?Give example.

Discuss structures and functions with example.

What is pointer? Discuss its declaration and initialization with syntax and examples.

What is dynamic memory allocation? Discuss memory allocation functions like malloc(), calloc(), realloc(), fee().

What are pre-processors? Discuss three types with examples.

Programs:

Swap two values using pointers.

Standard deviation

C Program to print Pascals Triangle (Click below link)
https://drive.google.com/file/d/1gv62LCGTury6zdevYFfRUUrPRME17fxV/view?usp=sharing

Note: Send your feedback to cs.kusur@gmail.com or Write comments.
     

Important C programs to be practice for C for Problem Solving I or II Semester B.E. Examination, VTU, Belagavi

C program to calculate simple interest.

#include<stdio.h>
void main()
{
float p, t, r, si;
printf("Enter principle amount, rate of interest and time period ");
scanf("%f%f%f",&p, &t, &r);
si=(p * t * r)/100;
printf(" Simple Interest=%f",si);
}

C program to calculate area and circumference of a circle

#include<stdio.h>
void main()
{
float r, area, cir;
printf("Enter radius of a circle ");
scanf("%f",&r);
area=3.142 * r * r;
cir=2 * r *r;
printf("\n Area of circle = %f ",area);
printf("\n Circumference of circle = %f ",cir);

}

C program to calculate area and perimeter of a rectangle

#include<stdio.h>
void main()
{
float l, b, area, per;
printf("Enter length and breadth of rectangle ");
scanf("%f%f",&l,&b);
area= l * b;
per=2 * (l+b);
printf("\n Area of rectangle = %f ",area);
printf("\n Perimeter of rectangle  = %f ",per);
}

C program to calculate area or triangle by reading its breadth and height (Inputs: b and h)

#include<stdio.h>
void main()
{
float b, h, area;
printf("Enter breadth and height of a rectangle ");
scanf("%f%f",&b, &h);
area= 0.5 * b * h;
printf("\n Area of triangle  = %f ",area);
}

C program to calculate area or triangle by reading 3 sides of  triangle (a,b,c)

#include<stdio.h>
#include<math.h>
void main()
{
float a, b, c, s, area;
printf("Enter 3 sides of triangle  ");
scanf("%f%f%f", &a, &b, &c);
s=(a+b+c)/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
printf("\n Area of triangle  = %f ",area);
}



Do not forget to send feedback or comment.

C program to swap (interchange) the contents of two variables using temporary variable .

#include<stdio.h>
void main()
{
int a,b, temp;

printf("Enter two integers a and b ");
scanf("%d%d",&a,&b);

printf(" \n Before Swap  ");
printf(" \n a=%d b=%d  ",a,b);

temp=a;
a=b;
b=temp;

printf(" \n After Swap  ");
printf(" \n a=%d b=%d  ",a,b);

}
C program to check, whether the year is LEAP year or not.

# include<stdio.h>
void main()
{
int year;
printf("Enter year to be check");
scanf("%d",&year);
         if ( (year%4==0) && (year%100!=0) || (year %400==0) )
                     printf("Leap Year");
         else
                      printf("Not Leap Year");
}


Note:
If you get this programming question then write the above program.
If you won't get question on it; then us it as example for if else statement.

Do not forget to send feedback or comment.

C program to find largest of two numbers.

#include<stdio.h>
void main()
{
int a,b;
printf("Enter two numbers");
scanf("%d%d",&a,&b);
         if (a>b)
                     printf(" %d is largest",a);
         else
                      printf("%d is largest",b);
}

Note: Use this program as example for if else statement used in C.



C program to find largest of three  numbers.

#include<stdio.h>
void main()
{
int a,b,c;
printf("Enter three numbers");
scanf("%d%d%d",&a,&b,&c);
         if (a>b  && a>c)
                     printf(" %d is largest",a);
         else if (b>a && b>c)
                      printf("%d is largest",b);
         else
                      printf("%d is largest",c);
}

Do not forget to send feedback or comment.

C program to explain the working of switch statement

#include<stdio.h>
void main()
{
int ch;
printf("Enter your choice [1 2 3 ?] ");
scanf("%d",&c);

switch(ch)
{
case 1:
          printf("\n You have selected first choice");
          break;
case 2:
          printf("\n You have selected second choice");
          break;
case 3:
          printf("\n You have selected third choice");
          break;
default:
          printf("\n Sorry! Invalid choice ");
          break;
}


}


C program to check a number for palindrome or not.

#include<stdio.h>
void main()
{
int num, rem, rev=0,temp;

printf("Enter number to be check ");
scanf("%d",&num);

temp=num;

while (num !=0)
{
rem=num%10;
rev=(rev*10)+rem;
num=num/10;
}

if (temp = = rev)
      printf("\n Palidrome");
else
     printf("\n Not palindrome");

}

Do not forget to send feedback or comment.

C program to find factorial of number n

#include<stdio.h>
void main()
{
int n, i, prod=1;

printf("Enter a number ");
scanf("%d",&n);

for(i=1; i<=n; i++)
{
prod=prod*i;
i=i+1;
}   

printf("\n Factorial is %d", prod);

}


C program to implement BUBBLE sort technique

#include<stdio.h>
void main()
{
int n, i, j, temp ;
int a[100];

printf("Enter number of elements  ");
scanf("%d",&n);

printf("\n Enter %d numbers to be sort ",n);

for(i=0; i<n; i++)
{
scanf("%d", &a[i]);


for(i=0;i<n;i++)
{
    for(j=0;j<n-i-1;j++)
   {
                 if(a[j]>=a[j+1])
                {
                 temp=a[j];
                 a[j]=a[j+1];
                 a[j+1]=temp;
                 }
   }
}

printf("\n After Bubble Sort");

for(i=0; i<n; i++)
{
printf("\n %d", a[i]);



}

Do not forget to send feedback or comment.


C program to implement ADDITION OF TWO MATRICES 

#include<stdio.h>
void main()
{

int m,n,p,q;
int i, j;
in a[100][100],b[100][100],c[100][100];

printf("Enter the order of matrx A ");
scanf("%d%d",&m,&n);

printf("Enter the order of matrx B ");
scanf("%d%d",&p, &q);

if (m = = n  && p = = q)
{

printf("\n Matrix Addition is possible ");

printf("\n Enter elements of matrix A  ");
       for(i=0; i<m; i++)
       {
            for(j=0;j<n;j++)
            {
             scanf("%d", &a[i][j]);
            }
        }

printf("\n Enter elements of matrix B  ");
       for(i=0; i<p; i++)
       {
             for(j=0;j<q;j++)
            {
             scanf("%d", &b[i][j]);
             }
        }


       for(i=0; i<m; i++)
       {
               for(j=0;j<n;j++)
              {
                c[i][j]=a[i][j] +b[i][j];
              }
        }


printf("\n Resultant Matrix C  ");
       for(i=0; i<m; i++)
       {
                   for(j=0;j<n;j++)
                   {
                    printf(" %d ", c[i][j]);
                    }
         printf("\n");
        }

}
else
printf("\n Addition is not possible");
}

C program to implement MULTIPLICATION  OF TWO MATRICES 
In order to find matrix multiplication, the columns of first matrix must be equal to rows of second matrix.


#include<stdio.h>
void main()
{

int m,n,p,q;
int i,j,k;
in a[100][100],b[100][100],c[100][100];

printf("Enter the order of matrx A ");
scanf("%d%d",&m,&n);

printf("Enter the order of matrx B ");
scanf("%d%d",&p, &q);

if (n = = p)
{

printf("\n Matrix Multiplication is possible ");

printf("\n Enter elements of matrix A  ");
       for(i=0; i<m; i++)
       {
            for(j=0;j<n;j++)
            {
             scanf("%d", &a[i][j]);
            }
        }

printf("\n Enter elements of matrix B  ");
       for(i=0; i<p; i++)
       {
             for(j=0;j<q;j++)
            {
             scanf("%d", &b[i][j]);
             }
        }


       for(i=0; i<m; i++)
       {
               for(j=0;j<n;j++)
              {
                c[i][j]=0;
                      for(k=0;k<n;k++)
                      {
                        c[i][j]=c[i][j]+a[i][k]*b[k][j];
                       }
              }
        }


printf("\n Resultant Matrix C  ");
       for(i=0; i<m; i++)
       {
                   for(j=0;j<q;j++)
                   {
                    printf(" %d ", c[i][j]);
                    }
         printf("\n");
        }

}
else
printf("\n Matrix Multiplication is not possible");
}

C program to find length of a string without using built in function

#include<stdio.h>
void main()
{
char str[50];
int length=0;

printf("Enter a string ");
scanf("%s",str);

for(i=0;  str[i]!='\0' ; i++)
{
length=length+1;


printf("\n String length is %d", length);

}

C program to read and display N students information (Roll No, Name, Average Marks) using arrays of structure.

#include<stdio.h>

struct student
{
int rno;
char name[50];
float avg;
};

void main()
{
struct student s[50];
int n, i;

printf("Enter number of students ");
scanf("%d", &n);

printf("\n Enter roll number, name and average marks  of %d students", n);

for(i=0;i<n;i++)
{
scanf("%d %s %f",&s[i].rno, s[i].name,&s[i].avg);
}

printf("\n Student Details \n");

for(i=0;i<n;i++)
{
printf ("\n  %d     %s      %f", s[i].rno, s[i].name, s[i].avg);
}

}


C program to  swap two numbers using pointers and functions.

#include<stdio.h>

void swap(int *x, int *y);

void main()
{
int x=7, y=3;

printf("\n Before Swap \n");
printf("x=%  y=%d",x,y);

swap(&x, &y);

printf("\n After Swap \n");
printf("x=%  y=%d",x,y);

}

void swap(int *x, int *y)
{
int temp;
temp=*x;
*x=*y;
*y=temp;
}


Note: Do not forget to send Feedback/Comments.
          I upload other programs shortly......


Tips to get good marks in Engineering Examinations.

Dear student,

First of all, you need to be happy and be proud of you.

Be cool and receive question paper.

Write your USN on question paper.

Write your name in the block and put yours signature.

Fill all remaining details correctly.

Go through all questions from entire question paper once (slowly)

First, you need to attempt that question which you feel comfort and perfect.

Answers must be neat and spacious. Underline important points.

Do not write two or more answer per page.

For 10 marks, minimum 2 pages or more.

Write question number correctly for every answer.

Maintain space between answers also.

Draw drawings, wherever necessary.

Give more examples.

Prepare all MODULES for examination. Better, prepare or revise the modules in reverse order i.e. Module -5, Module-4, Module-3, Module-2 and Module-1.

If you solve at least 2 to 4 previous old VTU question papers of that subject, no doubt, definitely, you pass the subject.

Yours objective should be score out of out in all subjects. Do not be happy with only passing marks.

Please, do not COPY in examination that spoils yours life. FAIL in subject is better than COPY.

Better FAIL, but at any cost do not copy.

Try to read subjects for knowledge, not to pass examination, if you do so, then no doubt, you pass the examination. (i.e. like do not live for eating food, instead eat food to live)

Give respect to all...i.e. to your teacher, to the subject, to the black ink pen, VTU answer booklet, all writing materials..then you get good returns.

On VTU booklet it self they printed "First be human being....Modalu Manavanagu....".....

All the best...do well in exam....

ALL IS WELL.