Friday 25 June 2021

C programs Structs problems

 # include<stdio.h>

# include<string.h>
struct employee{
    int code;
    float salary;
    char name[15];

};
 int main(){ 
struct employee e1,e2,e3;

printf("enter the employee Id ");
scanf("%d"&e1.code);
printf("enter the employee salary "); 
scanf("%f"&e1.salary);
printf("enter the employee name ");
scanf("%s"&e1.name);

printf("enter the employee Id ");
scanf("%d"&e2.code);
printf("enter the employee salary ");
scanf("%f"&e2.salary);
printf("enter the employee name ");
scanf("%s"&e2.name);

printf("enter the employee Id ");
scanf("%d"&e3.code);
printf("enter the employee salary ");
scanf("%f"&e3.salary);
printf("enter the employee name ");
scanf("%s"&e3.name);

     
     return 0
}


# include<stdio.h> 
# include<string.h>
struct employees{
    int code;
    float salary;
    char name[15];

};
void show(struct employees e){

printf("employees id is %d\n",e.code);
printf("employees salary is %f\n",e.salary);
printf("employees name is %s\n",e.name);

}

 int main(){ 
     struct employees e1={100,123.25,"Upendra"};
     show(e1);

     
     return 0
}



#include <stdio.h>
#include<string.h>
struct employees
{
    int code;
    float salary;
    char name[15];
};
int main()
{
    struct employees e1;
    struct employees *ptr = &e1;
    ptr->code = 120;
    ptr->salary = 120.254
    strcpy(ptr->name,"Upendra");
    
    printf("employees id is %d  \n",e1.code);
    printf("employees id is %f \n",e1.salary);
    printf("employees id is %s  \n",e1.name);
    

    return 0;
}



#include <stdio.h>
#include <string.h>
struct employees
{
    int code;
    float salary;
    char name[50];
};

int main()
{

    struct employees facebook[10];
    facebook[0].code=250;
    facebook[0].salary=253.25;
   strcpy (facebook[0].name,"Upendra");
    facebook[1].code=250;
    facebook[1].salary=253.25;
   strcpy (facebook[1].name,"Upendra");
    facebook[2].code=250;
    facebook[2].salary=253.25;
   strcpy (facebook[2].name,"Upendra");
    facebook[3].code=250;
    facebook[3].salary=253.25;
   strcpy (facebook[3].name,"Upendra");
   printf("Done");

    return 0;
}




# include<stdio.h> 
# include<string.h>
struct employee{
    int code;
    float salary;
    char name[15];

};


 int main(){ 
     struct employee e1;
     e1.code=125;
     e1.salary=256.30;
     strcpy(e1.name,"Upendra");
     printf("Employee id is %d\n",e1.code);
     printf("Employee salary is %.2f\n",e1.salary);
     printf("Employee Name is %s\n",e1.name);
    
     
     

     
     return 0
}




# include<stdio.h> 
#include<string.h>
typedef struct employees
{
    int code;
    float salary;
    char name[15];
   
}emp;

 int main(){ 
 emp e1;
    emp *ptr = &e1;
    ptr->code = 120;
    ptr->salary = 120.254
    strcpy(ptr->name,"Upendra");
    
    printf("employees id is %d  \n",e1.code);
    printf("employees id is %f \n",e1.salary);
    printf("employees id is %s  \n",e1.name);
    
     
     return 0
}



# include<stdio.h> 
# include<string.h>
typedef struct student_marks{
    int marks;
    char name[15];
    char subjects[10];
}marks;


 int main(){ 
     marks m1;
     marks *ptr=&m1;
     ptr->marks=45;
   strcpy(ptr->subjects,"Maths");
   strcpy(ptr->name,"Upendra");
   printf("%d \n",m1.marks);
   printf("%s \n",m1.subjects);
   printf("%s \n",m1.name);
     
     


     
     return 0
}



# include<stdio.h> 
typedef struct points_function{
    float x;
    float y;
}points;

void display(points p){
    printf("the points are (x,y) is (%d,%d) \n ",p.x,p.y);


}
 int main(){ 
     points p[5];
     for (int i = 0i < 5i++)
     {
        printf("enter the number in x axis of point %d:",i+1);
        scanf("%f",&p[i].x);
        printf("enter the number in y axis of point %d:",i+1);
        scanf("%f",&p[i].y);
     }
     for (int i = 0i < 5i++)
     {
        display(p[i]);
     }
     



     
     return 0
}



#include <stdio.h>
typedef struct vector
{
    int x;
    int y;

vec;

vec sumVector(vec v1,vec v2){
    vec results;
    results.x=v1.x+v2.x;
    results.y=v1.y+v2.y;
    printf("the sum of x axis of vector is %d \n",results.x);
    printf("the sum of y axis of vector is %d \n",results.y);


}
int main(){
    vec v1v2sum;
    v1.x = 20;
    v1.y = 40;
    v2.x = 10;
    v2.y = 50;
    sum= sumVector(v1,v2);


    return 0;
}


#include <stdio.h>
typedef struct complex_no
{
    int real;
    int complex;

com;
void dispaly(com c){
    printf("the value of real part of complex num is %d \n"c);
    printf("the value of imaginary part of complex num is %d \n"c);
}

int main()
{
    com cnums[5];
    for (int i = 0i < 5i++)
    {
        printf("Enter the value of real %d num:\n"i + 1);
        scanf("%d",&cnums[i].real);
        printf("Enter the value of imaginary  %d num:\n"i + 1);
        scanf("%d",&cnums[i].complex);
    }
    for (int i = 0i < 5i++)
    {
        dispaly(cnums[i]);
    }

    return 0;
}



#include <stdio.h>
#include <string.h>
typedef struct bank_account
{
    int Account_number;
    char Name[20];
    float deposit;
    char Branch[25];
account;

void display(account *cint b)
{
    for (size_t i = 0i < 5i++)
    {
        printf("the Acount number of customer %d is: %d \n"i + 1, (*c).Account_number);
        printf("the Name of customer %d is: %s \n"i + 1, (*c).Name);
        printf("the Amount Desposited by of customer %d is: %f \n"i + 1, (*c).deposit);
        printf("the Branch of customer %d is:%s \n"i + 1, (*c).Branch);
    }
}

int main()
{
    account customer[5];
    for (int i = 0i < 5i++)
    {
        printf("Enter the Account number of Customer %d:\n"i + 1);
        scanf("%d"&customer[i].Account_number);
        printf("Enter the Name of Customer %d:\n"i + 1);
        scanf("%s"&customer[i].Name);
        printf("Enter the Amount Deposit by of Customer %d:\n"i + 1);
        scanf("%f"&customer[i].deposit);
        printf("Enter the Branch of Customer %d:\n"i + 1);
        scanf("%s"&customer[i].Branch);
    }
    display(customer5);

    return 0;
}



#include <stdio.h>
typedef struct timestamp
{
    int date;
    int month;
    int year;
    int hours;
    int minutes;
    int seconds;
time;
void display(time c)
{
    printf("the Timestamp is %d-%d-%d\t%d:%d:%d\n"c.datec.monthc.yearc.hoursc.minutesc.seconds);
}
int Time_comp(time c1,time c2){
if (c1.seconds>c2.seconds)
{
    return 1;
}
else if (c1.seconds<c2.seconds)
{
    return -1;
}
else if (c1.minutes>c2.minutes)
{
   return 1;

}
else if (c1.minutes<c2.minutes)
{
    return -1;
}
else if (c1.hours>c2.hours)
{
    return 1;
}
else if (c1.hours<c2.hours)
{
    return -1;
}
else if (c1.year>c2.year)
{
    return 1;
}
else if (c1.year<c2.year)
{
    return -1;
}
else if (c1.month>c2.month)
{
    return 1;
}
else if (c1.month<c2.month)
{
    return -1;
}
else if (c1.date>c2.date)
{
    return 1;
}
else if (c1.date<c2.date)
{
    return -1;
}

return 0;





}

int main()
{

    time T1 = {25062020126012};
    time T2 = {25062020126012};
    display(T1);
    display(T2);
    int c = Time_comp(T1T2);
    printf("the value return after comparison is %d",c);

    return 0;
}




Thursday 27 May 2021

C arrays problems

 

#include <stdio.h>

int main()
{

    int arry[10]={25,56,25,2,3,4,7,7,9,10};
    int *ptr;
    ptr = &arry[0];
     ptr++;
     ptr++;
    printf("the value of element is %d",*ptr);

    return 0;
}


#include <stdio.h>

int main()
{

    int array[10];
    int *ptr;
    ptr = array;
    ptr = ptr + 2;
    if (ptr == &array[2])
    {
        printf("the pointer point to same add");
    }
    else
    {
        printf("the pointer doesn't  point to same add");
    }

    return 0;
}


#include <stdio.h>

int main()
{

    int s[3];
    printf("the value is %d",*(s+0));

    return 0;
}


# include<stdio.h> 

 int main(){ 
int mul[10];
for (int i = 0i < 10i++)
{
    mul[i]=5*(i+1);

}
for (int i = 0i < 10i++)
{
    printf("5*%d=%d\n",i+1,mul[i]);
    
}

     
     return 0
}



#include <stdio.h>

int main()
{

    int number;
    printf("Enter the value of table U want?:");
    scanf("%d", &number);
    int mul[10];
    for (int i = 0i < 10i++)
    {

        mul[i] = number * (i + 1);
    }
    for (int i = 0i < 10i++)
    {

        printf("the value of table %d * %d = %d \n"number, (i + 1), mul[i]);
    }

    return 0;
}


#include <stdio.h>
void reverse(int *arrayint n)
{
    int temp;
    for (int i = 0i <( n / 2); i++)
    {
        temp = array[i];
        array[i] = array[n - i - 1];
        array[n - i - 1] = temp;
    }
}
int main()
{
    int array[7] = {1234567};
    reverse(array7);
    for (int i = 0i < 7 ; i++)
    {
        printf("the value is %d\n",array[i]);
    }

    return 0;
}


# include<stdio.h> 
void count(int *arr,int n){
   
    

}
 int main(){ 

     int arr[10];
     count(arr,10);
     return 0
}


#include <stdio.h>

int main()
{
    int i,j;
    int mul[3][10];
    for (i = 0; i < 3; i++)
    {
       for ( j = 0; j< 10; i++)
       {
           mul[i][j]=2*(j+1);
           mul[i][j]=7*(j+1);
           mul[i][j]=9*(j+1);


       }
       
    }
    for (i = 0; i < 3; i++)
    {
       for ( j = 0; j< 10; i++)
       {
         printf("the value of %d *%d = %d \t \t ",2,(j+1),mul[i][j]);
         printf("the value of %d *%d = %d \t \t ",7,(j+1),mul[i][j]);
         printf("the value of %d *%d = %d \t \t ",9,(j+1),mul[i][j]);


       }
       
    }
    

    return 0;
}



#include <stdio.h>

int main()
{
    int marks[3][3];
    for (int i = 0i < 3i++)
    {
        for (int j = 0j < 3j++)
        {
            printf("Enter the marks of student %d and subject %d:"i + 1j + 1);
            scanf("%d", &marks[i][j]);
        }
    }

    for (int i = 0i < 3i++)
    {
        for (int j = 0j < 3j++)
        {
            printf("the marks is %d \n",marks[i][j]);
           
        }
    }


    return 0;
}



# include<stdio.h> 

 int main(){ 
int marks[4];
for (int i = 0; i < 5; i++)
{
    printf("Enter the marks of students %d:",i+1);
    scanf("%d",&marks[i]);
}
for (int i = 0; i < 5; i++)
{
    printf(" the value   of marks is : %d \n",marks[i]);
   
}
     
     return 0
}



#include <stdio.h>

int main()
{

    int array[] = {25657895200};
    int *ptr;
    // ptr = array[0];
    ptr= array;
    for (int i = 0; i < 5; i++)
    {
        printf("the value of elments %d is %d \n",i+1,*(ptr+i));
    }
    
    return 0;
}



#include <stdio.h>

int main()
{
    int arry[]={25,65,85,98,748};
    for (int i = 0i < 5i++)
    {
        printf("the value of element %d is %d \n",i+1,arry[i]);
    }
    

    return 0;
}


#include <stdio.h>

int main()
{
    int marks[4];
    printf("Enter the marks of students:");
    scanf("%d",&marks[0]);
    printf("Enter the marks of students:");
    scanf("%d",&marks[1]);
    printf("Enter the marks of students:");
    scanf("%d",&marks[2]);
    printf("Enter the marks of students:");
    scanf("%d",&marks[3]);
    printf("Enter the marks of students:");
    scanf("%d",&marks[4]);

    printf("You have Entered the marks %d %d %d and %d ",marks[0],marks[1],marks[2],marks[3],marks[4]);


    return 0;
}



#include <stdio.h>

int main()
{
    int arr[3][2];
    

    return 0;
}



#include <stdio.h>

int main()
{
    int arr[3][4][5];
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            for (int k = 0; k < 5; k++)
            {
                printf("the add of arr[%d][%d][%d] is %d \n",i,j,k,&arr[i][j][k]);
            }
            
        }
        
    }
    

    return 0;
}



#include <stdio.h>

int main()
{

int marks[5];
int *ptr;
ptr=marks;
for (int  i = 0; i < 5; i++)
{
    printf("Enter the marks of student %d :\n",i+1);
    scanf("%d",ptr);
    ptr++;
}
for (int  i = 0; i < 5; i++)
{
    printf("the marks of student %d : %d \n",i+1,marks[i]);
    
}

    return 0;
}



#include <stdio.h>
void printarr(int ptr[]int n)
{
    for (int i = 0i < ni++)
    {
        printf("the value of elemnts %d is %d \n"i + 1ptr[i]);
    }
    ptr[2] = 520;
}
int main()
{
    int arr[5] = {12345};
    printarr(arr5);
    printf("%d"arr[2]);
    printarr(arr5);

    return 0;
}



#include <stdio.h>

int main()
{
    int marks[4];
    printf("Enter the marks of student 1:");
    scanf("%d",&marks[0]);
    printf("Enter the marks of student 2:");
    scanf("%d",&marks[1]);
    printf("Enter the marks of student 3:");
    scanf("%d",&marks[2]);
    printf("Enter the marks of student 4:");
    scanf("%d",&marks[3]);
    printf("The marks of students is %d %d %d and %d",marks[0],
    marks[1],marks[2],marks[3]);

    

    return 0;
}



#include <stdio.h>
void printTable(int *mulTableint numint n)
{
  printf("the multiplication table of %d \n  ", num);
  for (int i = 0; i < n; i++)
  {
    mulTable[i] = num * (i + 1);
  }
  for (int i = 0; i < n; i++)
  {
  printf("%d*%d=%d\n", num, (i + 1), mulTable[i]);
  }
  printf("*****************************************\n \n ");
}
int main()
{

  int mulTable[3][10];
  printTable(mulTable[0], 210);
  printTable(mulTable[1], 710);
  printTable(mulTable[2], 910);

  return 0;
}



#include <stdio.h>

int main()
{
    int n_student;
    int n_subject;
    printf("Enter the no of student:");
    scanf("%d", &n_student);
    printf("Enter the no of subject:");
    scanf("%d", &n_subject);
    int marks[n_student][n_subject];
    for (int i = 0i < n_studenti++)
    {
        for (int j = 0j < n_subjectj++)
        {
            printf("Enter the marks of student %d in subject %d:"i + 1j + 1);
            scanf("%d",&marks[i][j]);
        }
    }
    for (int i = 0i < n_studenti++)
    {
        for (int j = 0j < n_subjectj++)
        {
            printf("the marks of student %d in subject %d:%d\n"i + 1j + 1,marks[i][j]);
            
        }
    }

    return 0;
}



#include <stdio.h>
void positiveCount(int ptr[]int n)
{
    int n_integer = 0;
    for (int i = 0; i < n; i++)
    {
        if (ptr[i] > 0)
        {

            n_integer++;
        }
    }
    printf("No . of Positive integers are %d", n_integer);
}
int main()
{
    int arr[16] = {-1, -2, -30123456,-4,-5,54,-56,96,-85};
    positiveCount(arr, 16);

    return 0;
}



#include <stdio.h>
void printTable(int *mulTableint numint n)
{

    for (int i = 0; i < n; i++)
    {
        mulTable[i] = num * (i + 1);
    }
    for (int i = 0; i < n; i++)
    {
        printf("%d*%d=%d \n", num, (i + 1), mulTable[i]);
    }
}
int main()
{
    int m, n, num;
    printf("Enter the m rows :\n");
    scanf("%d", &m);
    printf("Enter the n column :\n");
    scanf("%d", &n);
    int mulTable[m][n];
    printf("Enter the which munber Table U want:\n");
    scanf("%d", &num);
    for (int i = 0; i < m; i++)
    {
        printTable(mulTable[m], num, n);
        
        printf("Enter the which number Table U want:\n");
        scanf("%d", &num);
        
        
        
        
    }

    return 0;
}



#include <stdio.h>

int main()
{
  int arr[3];
  int *ptr;
  ptr = arr;
  if (ptr == arr)
  {
    printf("the add lies in same add \n");
  }
  else
  {
    printf("the add lies in diff add");
  }

  return 0;
}



#include <stdio.h>

int main()
{
    int marks[5];
    for (int i = 0; i < 5; i++)
    {
        printf("Enter the marks of student %d :", i + 1);
        scanf("%d", &marks[i]);
    }
    for (int i = 0; i < 5; i++)
    {
        printf("the marks of student %d  is %d \n", i + 1marks[i]);
    }

    return 0;
}



# include<stdio.h> 
void reverse(int *arr,int n){
    int temp;
    for (int i = 0; i < (n/2); i++)
    {
      temp=arr[i];
      arr[i]=arr[n-i-1];
      arr[n-i-1]=temp;
    }
    
}
 int main(){ 
     int arr[7]={1,2,3,5,6,7,8};
     reverse(arr,7);
     for (int i = 0; i <7; i++)
    {
      printf("the value is %d \n",arr[i]);
    }

     
     return 0
}

position in CSS

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>position</title>
    <style>
        .container{
border2px solid red;
width900px;
 height3444px;
 border-radius15px;      }
.box{
    border2px solid black;
    color:black;
    background-colorwhite;
    width100px;
    height100px;
    margin5px;
    floatleft;
padding5px;
border-radius10px;


}
#box2{
    positionfixed;
}
#box3{
position:sticky;
top2px;

}


    </style>
</head>
<body>
    <div class="container">
    <div class="box" id="box1">1</div>
    <div class="box" id="box2">Chat With Us</div>
    <div class="box" id="box3">fruits 
        grapes
        orange
    </div>
    <div class="box" id="box4">4</div>
    </div>
</body>
</html>

CSS Display property

 

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS Display property</title>
    <style>
        * {
            box-sizingborder-box;
        }

        img {
            displayblock;
            marginauto;

            width100px;


        }

        h3 {
            font-familymonospace;
            text-aligncenter;
            margin0px;


        }

        header {
            border2px solid red;
            marginauto;

        }

        .box {

            border2px solid blue;
            background-colorrgb(243238248);
            margin3px auto;
            padding25px;
            displayinline-block;
            width30%;
            box-sizingborder-box;
        }

        .container {
            marginauto;
            width1200px;
        }

        .box h3 {
            text-alignleft;
        }
    </style>
</head>

<body>
    <header class="top">
        <img src="https://c1.sfdcstatic.com/content/dam/blogs/ca/Blog%20Posts/anatomy-of-a-blog-post-deconstructed-open-graph.jpg"
            alt="img blogs with pcs">
        <h3>Welcome To Upendra Blogs</h3>
    </header>
    <div class="container">
        <div class="box">
            <h3 class="heading">heading</h3>
            <p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Corrupti cum ad obcaecati voluptatem facere,
                ullam, placeat recusandae voluptatum repudiandae magni vel repellat quae? Dolore molestiae aliquid,
                possimus velit necessitatibus numquam ad sit ullam vel.</p>
        </div>
        <div class="box">
            <h3 class="heading">heading</h3>
            <p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Corrupti cum ad obcaecati voluptatem facere,
                ullam, placeat recusandae voluptatum repudiandae magni vel repellat quae? Dolore molestiae aliquid,
                possimus velit necessitatibus numquam ad sit ullam vel.</p>
        </div>
        <div class="box">
            <h3 class="heading">heading</h3>
            <p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Corrupti cum ad obcaecati voluptatem facere,
                ullam, placeat recusandae voluptatum repudiandae magni vel repellat quae? Dolore molestiae aliquid,
                possimus velit necessitatibus numquam ad sit ullam vel.</p>
        </div>


    </div>

</body>

</html>

Python if / else

 Python if / else a1 = int ( input (" Enter the number: \n ")) a2 = int ( input (" Enter the number: \n ")) a3 = int ( i...