Saturday 18 July 2020

fseek demo program

Q : Write a file statement to place a file pointer (fp) at the beginning of the record number (say R), where record size is B bytes.


Answer : 

#include<stdio.h>

#include<conio.h>

/*============================

     Girfa Student Help

     fseek demo

==============================*/

Friday 17 July 2020

Structure for Employee

A programmer wants to use two variables session and info. Variable session can take three values (morning, afternoon, evening) ly. Using variable info, the programmer wants to access information empname and empid of 30 employees. Name the appropriate data type used for each variable session and info and declare the variables.

Answer : 



#include<stdio.h>
#include<conio.h>
/*============================
     Girfa Student Help
     structure data type
==============================*/

Difference and similarity between continue and break | C Language

Write down one similarity and one dissimilarity between break and continue statements.


Similarity


The main difference between break and continue statements in C language is that a break origins the innermost enclosing loop or switch to be exited immediately. Whereas, the continue statement origins the next iteration of the enclosing for, while, or do loop to begin. The continue statement in while and do loops takes the control to the loop's test-condition immediately, whereas in the for loop it takes the control to the increment step of the loop.

Thursday 16 July 2020

Min Max find program 2d-array using function | C Language

Q : Write a function fnmat() which takes matrix, m, n as arguments where matrix is of size mXn with m as rows and n as columns. Function should return the maximum and minimum elements of the matrix. Elements of matrix are of integer type.


Answer : 


#include<stdio.h>
#include<conio.h>
#define ROW 5
#define COL 5
/*============================
     Girfa Student Help
     Find max,min 2d-array using function
==============================*/
void fnmat(int ar[ROW][COL],int,int);
void main()
{
     int ar[ROW][COL],r,c,i,j;
     clrscr();
     printf("Enter row & columns for array entry>> ");
     scanf("%d%d",&r,&c);
     if(r>ROW)
           printf("Given row is greater than row capacity of %d",ROW);
     else if(c>COL)
           printf("Given column is greater than column capacity of %d",COL);
     else
     {
           for(i=0;i<r;i++)
           {
                for(j=0;j<c;j++)
                {
                     printf("Enter number for ar[%d][%d]>> ",i+1,j+1);
                     scanf("%d",&ar[i][j]);
                }
           }
           clrscr();
           /* Printing array */
           for(i=0;i<r;i++)
           {
                for(j=0;j<c;j++)
                     printf("\t%d",ar[i][j]);
                printf("\n");
           }
           fnmat(ar,i,j);
     }
     getch();
}
void fnmat(int ar[ROW][COL],int r,int c)
{
     int i,j,min,max;
     min=max=ar[0][0];
     for(i=0;i<r;i++)
     {
           for(j=0;j<c;j++)
           {
                if(min>ar[i][j])
                     min=ar[i][j];
                else
                     max=ar[i][j];
           }
     }
     printf("\n\n\tMix=%d\n\tMax=%d",min,max);
}


POW function | C Language

Q : Write a function fnpow() in C to compute xy where x is float and y is integer. Function will return the result and takes x, y as arguments.

Answer :

#include<stdio.h>
#include<conio.h>
/*============================
     Girfa Student Help
     User defined pow function
==============================*/

Wednesday 15 July 2020

Difference between Union & Structure


SN.
Structure
Union
1
Struct keyword is used to make structure variable
Union  keyword is used to make structure variable
2
Structure is user defined data type which is used frequently to represent real word data type presentation.
Union is also a user defined data type which is used to achieve specific need.
3
Structure allocates memory for its all member.
Union allocates memory only for the biggest data member.
4
All member data can be hold at same time in a structure variable.
Only one data from member can be hold at a time.
5
Several members can be initialized at ones.
Only first member can be initialized.


Tuesday 14 July 2020

File writing program append mode using Command Line Argument

Q : Write a program using command line parameters to append one text file to another text file.?


Answer : 



#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main(int argc,char *argv[])
{
     FILE *infile,*outfi

Monday 13 July 2020

Bitwise Operator Complete solution

Bitwise operators are used to perform bit operations. Decimal values are converted into binary values which are the sequence of bits and bit wise operators work on these bits. Bit wise operators in C language are given below.

1. & (bitwise AND)
2. | (bitwise OR) 
3. ~ (bitwise NOT)
4. ^ (XOR)
5. << (left shift) 
6. >> (right shift).

Link List Disadvantage


  • If fix element is required for an operation then link list is not a good option because it’s consumed more memory to manage the dynamic address for the list.
  • Random traversal is not possible in link list due to dynamic memory allocation which is unpredictable and scarred in memory.
  • Reverse traversing is not possible in a single link list because only the next pointer is used to point next element.
  • Manual delete is required because link list uses memory in heap section.
  • Infinite traversal occurred in a circular list if not handled properly.
  • More Time and memory required compare to array.

Pointer and Array Relationship


Pointers and arrays have a special relationship in C Language.Name of an array is constant pointer which point first element of array and an array is represented by a variable that is associated with the address of its first storage location. A pointer is also the address of a storage location with a defined type, so name permits the use of the array [ ] index notation with both pointer variables and array variables. For example, the following two references in C language are equivalent in meaning:

Q = &a[0];                                                           trace(Q[2]);
trace(Q[2]);

Saturday 11 July 2020

Greatest find CM:MM with structure | C Language

Q :  Define a structure Distance having two data members: cm and mm in integer. The program enters three variables and find which distance is the largest among them.


Answer 



#include<stdio.h>
#include<conio.h>
/*============================
     Girfa Student Help
     Find greatest cm:mm using structure
==============================*/

Recursion



Recursion



As we know C language is a building block of functions that means anything you are doing is achieved through some kind of function call. So learning about function is very important. Recursion is a concept when a function calls by itself from its function body.






Friday 10 July 2020

Krishnamurti Number Program | C Language

Krishnamurti Number


Q : Write a program to print all the Krishnamurti number from 1 to n. Here, n is user dependent. A             Krishnamurti number is a number whose sum of factorial of individual digits equals the number.         For example, 145 = 1! + 4! + 5! = 1 + 24+ 120 = 145.

Answer :


#include<stdio.h>
#include<conio.h>
/*============================
     Girfa Student Help
     Krishnamurti number
==============================*/
int fact(int);
void main()
{

2D-Multiplication with function | C Language

Q : Write a function to display the multiplication table of the number.

Answer : 

#include<stdio.h>
#include<conio.h>
/*============================
     Girfa Student Help
     Multiplication 2d array using function
==============================*/
void multi(int ar1[3][3],int ar2[3][3],int ar3[3][3])
{

Element delete program from array | C Language

Q :  Write a program that accept an array of 10 integers and a number to be deleted from the array if found. Represent deleted element with -1 and display final array. If not found print appropriate message.


Answer :

#include<stdio.h>
#include<conio.h>
/*============================
     Girfa Student Help
     Delete operation in array
==============================*/
void main()
{

Tuesday 7 July 2020

Get single row from MYSQL | PHP

Get a single row for editing or another purpose from MySql using PHP.



$conn=mysqli_connect("localhost","root","","girfadb");
$sql="select   name, phone  FROM  stu where  id=101";
$row=$conn->query($sql)->fetch_assoc() or die("<h1>Error</h1>". mysqli_error($conn));
echo $row['name'];
echo $row['phone'];
mysqli_close($conn);

Monday 6 July 2020

Record input and search program structure | C Language

Q : Write a ‘C’ program to read following details of 50 students.
      Student Name, Student Roll No, Class 
 Display total number of students studying in class “BCA”.

Answer : 



#include<stdio.h>
#include<conio.h>
#include "mylib.h"
/*============================
     Girfa Student Help
     Structure entry & search count
==============================*/
struct data
{
     int roll;
     char name[20];
     char cls[50];
};

Sunday 5 July 2020

Change/return more than value from function | C Language

Q : Write down three different methods used for referencing multiple values from a function.


Answer : you can return only one value from function using return statement but you can change multiple values from a function using a pointer, array, and structure. The following program will show you a demo. 




#include<stdio.h>
#include<conio.h>
#include "mylib.h"
/*============================
     Girfa Student Help
     Multiple value set from function
==============================*/
struct data
{
     int roll;
     int marks;
};

Create your own header file | C language

create  a blank file and  add following code

int sum(int a, int b)
{
     return(a + b);
}

save this file named with myheader.h

create  a new file and call your function  as given below

#include<stdio.h>

#include<conio.h>

#include "mylib.h"

/*============================

     Girfa Student Help

     Substring wihout using library function

==============================*/

void main()

{

  clrscr();

  printf("\n\t%d",sum(1,2));

  getch();

}


Tuesday 30 June 2020

Substring program without library function | C Language

Q : Write a ‘C’ Program to find substring of string without using Library Function.

Answer :

#include<stdio.h>
#include<conio.h>
#define MAX 50
/*============================
     Girfa Student Help
     Substring wihout using library function
==============================*/