Thursday 16 July 2020

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
==============================*/

Sunday 28 June 2020

Sum of lower triangular program | C language

Q : Write a ‘C’ Program to find Sum of lower triangular elements in a matrix.


Answer : 


Lower triangular


Lower triangular matrix is a special square matrix whole all elements above the main diagonal is zero.



Delete a number by given position from array program | C Language

Q : Write a program to delete an element from a given location of an array of integers.

Answer : 


#include<stdio.h>
#include<conio.h>
#define MAX 50
/*============================
     Girfa Student Help
     Remove from array by given index
==============================*/

Link List vs Array

Q :Define array and link list. Give one example for each showing its usage


Answer :


Define Link List

struct node
{
     int data;
     struct node *next;
}
int ar[5];

Saturday 27 June 2020

Whatsapp button for website


Add whatsup button at bottom right side of your website. Button will show when user scroll down because it can disturb your home page opening view. When user will click on whatsapp button it will redirect to whatsapp message mode to the given number.

<style>
    /* ========= CSS ==========*/
    .g-whatsapp {
        display: none;
        position: fixed;
        bottom: 20px;
        right: 30px;
        z-index: 99;
        cursor: pointer;
    }
</style>